/// <summary> /// Spawns the particles at the given location. /// </summary> /// <param name="parent">The parent actor (can be null to link it to the first loaded scene).</param> /// <param name="transform">The spawn transform.</param> /// <param name="duration">The effect playback duration (in seconds).</param> /// <param name="autoDestroy">If set to <c>true</c> effect be be auto-destroyed after duration.</param> /// <returns>The spawned effect.</returns> public ParticleEffect Spawn(Actor parent, Transform transform, float duration = float.MaxValue, bool autoDestroy = false) { if (WaitForLoaded()) { throw new Exception("Failed to load " + ToString() + '.'); } var system = Content.CreateVirtualAsset <ParticleSystem>(); if (!system) { throw new Exception("Failed to create virtual particle system."); } system.Init(this, duration); var effect = ParticleEffect.New(); effect.Transform = transform; effect.ParticleSystem = system; SceneManager.SpawnActor(effect, parent); if (autoDestroy && duration < float.MaxValue) { Destroy(effect, duration); } return(effect); }
/// <summary> /// Spawns the particles at the given location. /// </summary> /// <param name="parent">The parent actor (can be null to link it to the first loaded scene).</param> /// <param name="transform">The spawn transform.</param> /// <param name="autoDestroy">If set to <c>true</c> effect be be auto-destroyed after duration.</param> /// <returns>The spawned effect.</returns> public ParticleEffect Spawn(Actor parent, Transform transform, bool autoDestroy = false) { if (WaitForLoaded()) { throw new Exception("Failed to load " + ToString() + '.'); } var effect = ParticleEffect.New(); effect.Transform = transform; effect.ParticleSystem = this; SceneManager.SpawnActor(effect, parent); if (autoDestroy) { Destroy(effect, Duration); } return(effect); }