Free Unity Plugin Tutorial

From PopcornFX
Jump to: navigation, search
For PK-Fx Editor version : 1.7.3 and above
Main page: Particle tutorials


This Tutorial assumes that you have already installed Unity 4.6 and PopcornFX 1.7.3

Section 1: Install the Free Unity Project

  1. Goto http://www.popcornfx.com/download/
  2. Find in the Engine Intergrations section link to "PopcornFx-UnitySamples.zip" and download the link. Otherwise use the direct link provided here. https://www.popcornfx.com/downloads/updates/get.php?id=dn4AMxj6nPyrBgiZ
  3. Save the above zip file and extract it to your C: on your drive. The folder created should be "C:\Popcorn-Unity-Samples". The folder structure in the zip file contains a unity project.
  4. Open Unity 4.6
  5. Goto File/New Project
  6. Click the Open Project tab and then Click "Open Other" button
    UnityPKFX FreePlug 01.png

  7. Navigate to "C:\Popcorn-Unity-Samples" and click Select Folder Button
    UnityPKFX FreePlug 02.png

  8. Unity will Restart and compile the project folder we just selected
  9. By Default you will have the following folder structure. Open up "Assets/PopcornFX_Samples" to reveal the sample PopcornFX Unity Scene files and Double Click "Sample_Torchfire".
    UnityPKFX FreePlug 03.png

  10. Click the "Play" button at the top of the Unity UI (Cntrl-P is Shortcut for "Play").
  11. You will see a watermarked Game window playing the sample torchfire effect!
  12. Find the Hierarchy tab and Expand the "Root" gameobject all the way to reveal "FX". Click FX to reveal the Settings for the "PKFx FX" script. this script serves as the container for a PKFX file that was generated in PopcornFX, baked, then saved in this sample project. In this case the script points to Assets/StreamingAssets/PackFX/Particles/Torchfire.pkfx.
    UnityPKFX FreePlug 04.png

  13. You can click Stop/Start/Restart to test the effects spawning behavior
  14. Custom attributes can be setup in PopcornFX so you can control any scriptable behavior in Popcorn via Unity gamecode! Try playing with "FireEvolution" and note the effects behavior.
  15. Select the Main Camera in the Hierarchy section. Take note of all the paramenters to play with. Adjust them to see what happens!
    UnityPKFX FreePlug 05.png


Section 2: Setup PopcornFX to export to our Unity project folder


In order to author effects in popcorn and see them in Unity you must setup a Popcorn Project to run in parallel with the unity project.

  1. Create a new project
    PopcornToUnity 01.png

  2. Create a folder on C: next to our Unity project call it "Popcorn-Unity-Samples-PKFX".
  3. In the PopcornFX select "Popcorn-Unity-Samples-PKFX" in the project window, then click "Settings".
    PopcornToUnity 01b.png

  4. Edit the settings :
    General > Axis System > Axis_LeftHand_Y_Up
    UnityPKFxAxisSystem.png
  5. Click Assets > Baking
  6. Type in "Unity" in the input field next to the "New" button then click "New".
    PopcornToUnity 02.png

  7. Navigate in windows to "C:/Popcorn-Unity-Samples/Assets/StreamingAssets/PackFx" and copy the path
  8. Input in newely created "Unity" text box "../Popcorn-Unity-Samples/Assets/StreamingAssets/PackFx" and click OK. *NOTE: Typically the path is formed like this. <Your Unity project's path>/Assets/StreamingAssets/PackFx
    UnityPKFxBakingSettings.png

  9. Once the PopcornFX project launcher appears. Double click "Popcorn-Unity-Samples-PKFX" in the projects list.
  10. In windows navigate to "C:/Popcorn-Unity-Samples-PKFX".
  11. Make a folder named particles.
  12. Make a folder named textures.
  13. Make a default effect in "C:/Popcorn-Unity-Samples-PKFX/particles". Name it "PKFX_test" and open it in the ParticleEditor by double clicking the new icon..
  14. In the ParticlesTree window go to Editor Properties > Backdrop > 3D Layers (Scene) > Model.
  15. In the Node Properties Windows View go to General > ResourceModel and click the trash can to remove the reference to "Meshes/CubeRoom_Default.fbx" as it will be unecessary for the baking of the particle effect to Unity.
  16. In the ParticlesTree window go to Particle Effect > Spawner > Layer_1.
  17. In the Node Properties Windows View go to General > Infinite and check the box. This will insure that it will loop in Unity. Save and Close the Editor
  18. Right click on your new effect and select Bake with dependencies
    UnityPKFxBaking.png

  19. Open the Unity project again and make a new scene.
  20. Create a Gameobject and attach PKFxFX. The scripts are located in Assets > PopcornFX > Scripts > PKFx-Runtime.
  21. With your gameobject still selected go to the inspector Click the radial button next to the FX input field.
  22. Type in "PKFX_test" in the search field and click on your asset to target it in the "PKFx FX Script".
  23. Create a Camera and attach PKFxCamera. Same location as above script.
  24. Position your Camera to view the Gameobject you just created and Press Play.
  25. See your effect play.
  26. For the paid plugin see Unity Project Setup and Use Particle Effects for more info.

Unity Project Setup

  1. Import the plugin package (without StreamingAssets/PackFx if starting from a new PopcornFX project)