PKFxManager
The PKFxManager (PKFxManager.cs) is the singleton in charge of the interop between C# and C++.
It allow direct control of effects, attributes, samplers and general PopcornFX state.
Return type | Description |
void | ProfilerEnable(bool onOff) Used to start or stop the PopcornFX native profiling. |
void | ProfilerWriteReport(string path) Writes the latest PopcornFX profiling data on disk. |
void | ResetAllEffects() Kill all existing effects. This can be used when changing scenes if you don’t want lingering effects from the previous scene. |
void | ResetAndUnloadAllEffects() Same thing as ResetAllEffects() except that this also completly unload the effect assets from the PopcornFX runtime. |
Property type | Description | Default value |
float | TimeMultiplier Time multiplier applied to the particle update. frameDt = Time.smoothDeltaTime * TimeMultiplier | 1.0f |
bool | UseFixedDT If true , uses Time.fixedDeltaTime instead of Time.smoothDeltaTime for particle update.frameDt = Time.fixedDeltaTime * TimeMultiplier | false |
Code sample
Here is a simple code sample showing how to switch between a project scenes without lingering effects:
using UnityEngine; using UnityEngine.SceneManagement; public class ChangeLevelOnKeyPressed : MonoBehaviour { void Update() { // Switch to the next scene when pressing tabulation. if (Input.GetKeyDown(KeyCode.Tab)) { // This will kill all the existing particles in the current scene to avoid lingering effects in-between scenes. PopcornFX.PKFxManager.ResetAllEffects(); // Now we can load another scene: Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadSceneAsync((scene.buildIndex + 1) % SceneManager.sceneCountInBuildSettings); } } }