Category:Unity V3

From PopcornFX
(Redirected from Unity V3)
Jump to: navigation, search


All our packages on the Unity asset store can be found here: https://www.assetstore.unity3d.com/en/#!/publisher/8762?aid=1101lGAz&pubref=wiki
Our official thread on the Unity forums is here : http://forum.unity3d.com/threads/popcornfx-optimized-particle-effects-plugin.297938/
You can find the documentation for the version 2.X here : Unity

Unity-logo-g.png

What's the PopcornFX Unity Plugin

The PopcornFX Unity plugin is an integration of the PopcornFX runtime libraries in the Unity game engine.
It takes advantage of Unity's Native Plugin Interface and Unity's command buffers.

The plugin actually refers to 2 distinct parts :

  • The native plugin: a C++ library that runs natively on each platform, libraries for each platform can be found in Assets/Plugins.
  • The managed plugin: a set of C# scripts that are not platform-specific and provide the interface between Unity and the native libraries. They're located in Assets/PopcornFX/Scripts/


These are both identified by their version numbers and can't be dissociated (you can't take the native part from the 3.0 plugin and use it with 3.1).
The Asset Store packages are identified with the managed version number only.

The managed scripts are provided with each version of the plugin (desktop, ios and android) and should be exactly the same (so once you've imported 3.0 from whatever package, you only strictly need the content of Assets/Plugins/ from the other packages).
All 3.0 packages have the same managed assemblies. Only the different platform-specific native libraries are exclusive to each package.

Getting Started

Setup From A New PopcornFX Project

  1. Make sure you are using the right version of the editor.
    The editor's version must match the PKFxRenderingPlugin component version.

  2. Create a new project and choose the 'Unity Project' template
    UnityProjectTemplate.png
    Set your project to be located in <Unity project's path>/YourFxProjectName

  3. Make effects!

  4. See Unity Project Setup and Use Particle Effects

Unity Project Setup

Importing for the first time / updating a project with v3.0+

  1. You only have to import the plugin package in your project

Updating a project with v2.X

  1. Make sure to upgrade your PopcornFX editor to the latest version (1.13.3) that you can download here and update your source PopcornFX project.
  2. Start by removing the folders "Assets/PopcornFX", "Assets/Resources/PackFx/" and also make sure to remove the old DLLs in "Assets/Plugins/PK-UnityPlugin*" before opening your project.
  3. Open your project and import the .unitypackage.
  4. The plugin now requires to enable unsafe code. You can add a file that contains just "-unsafe" in your assets folder and name it "smcs.rsp" ( as explained here ) or just enable it in Unity's player settings.
  5. Select the PkFXSettings.asset in the assets (it should be created when PopcornFX starts) and click on "Set Pack Fx Path" and select your PopcornFX project (where the PopcornProject.pkproj is located).
  6. Re-import the effects by clicking on "All" next to "Reimport Pack" or select which effects to import by clicking on "Choose files" (still in the PKFxSettings). make sure all the effects that are used in your projects are imported correctly.
  7. Right click on the project explorer in Unity and select PopcornFX > Update PKFX references, it should update all your scenes and prefabs so that they use the new PopcornFX component (this will keep all your attribute values and asset references).
  8. Make sure everything works fine in the editor.

The way to set the attributes and the samplers has also changed a bit. You now have to go through the PKFxFX.SetAttributeSafe (takes the name of the attribute and its value, check if the attribute exist and clamp the value) or PKFxFX.SetAttributeUnsafe (takes the attribute ID that you can retrieve on the asset by calling PKFxFxAsset.AttributeIdFromName and the attribute value, no clamp or check is done so be careful using this).

For the samplers, it works pretty much the same as before, the new function to set those is "PKFxFX.SetSamplerSafe".

How To...

Import Your Effects

In PopcornFX/Resources/PKFxSettings :

  • Set Source Path : Path of your Popcorn Project.
  • Set Destination Path : Path where you want your Effects to be in Unity.
PkFxSetting Overview

While Unity is open, It will automatically import and reimport effects located in the Pack Fx Path when they are updated.

  • This is triggered when saving inside PopcornFX editor
  • And also when updating your repository !

You can reimport manually :

  • Inside PKFxSetting, 'Reimport Pack' allows you to Import the whole pack, or to choose what effects to import.
PkFxSetting Importer
  • By selecting one effect asset and clicking the 'Reimport' button
PkFxEffect Inspector

Use Particle Effects

  1. In your scene add the PKFxRenderingPlugin component to your camera.
    UnityRenderingPluginAdd V3.gif
  2. Add a PKFxFX component
    • Either by creating a new GameObject
    UnityFXNew V3.gif
    • Or by adding the component on an existing GameObject :
    UnityFXAdd V3.gif
  3. Select a "PK Fx Fx Asset"
    UnityFXSelectAsset V3.gif
  4. Run, watch, enjoy.

Setup Particle Collisions

Setup Particle Collisions

Handle Events

Handle Events

Identify Errors (Debugging)

Identifying Errors

Animate Effect Attributes

Animating Effects Attributes

Animate Effect Attribute Samplers

Animating Effects Attribute Samplers

Manage Effects' Assets Loading

Managing FX Loading

Setup Sound Layers

Setting Up Sound Layers

Pass Custom Data to the Audio Samplers

Passing Custom Data to the Audio Samplers (Unity Plugin)

Components Reference

PKFx-Helper

PKFx-Helper Assembly

PKFx-Runtime

PKFx-Runtime Assembly

PKFxManager

PKFxManager Assembly

Plugin's Menus

Menus

Troubleshooting

Troubleshooting

Feature list

Not all features allowed by the PopcornFX SDK are implemented in the Unity plugin.
To see the current status of the Unity integration, see the Feature list.

Changelog

Changelog

Subcategories

This category has only the following subcategory.