// Start void Start() { myParticleSystem = particleSystem; // Server side doesn't compute particles if(uLink.Network.isServer) { // Disable emission myParticleSystem.enableEmission = false; if(!myParticleSystem.isStopped) myParticleSystem.Stop(); // Is there a delayed explosion component? var delayedExplosion = GetComponent<DelayedExplosion>(); // Destroy this object after the standard duration of the particle system if(delayedExplosion == null) Destroy(gameObject, myParticleSystem.duration); else Destroy(gameObject, delayedExplosion.delayTime + 0.1f); // No LateUpdate on the server enabled = false; } }
static public int Stop(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); self.Stop(); pushValue(l, true); return(1); } else if (argc == 2) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); self.Stop(a1); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int Stop(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); self.Stop(); return(0); } else if (argc == 2) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); self.Stop(a1); return(0); } else if (argc == 3) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); UnityEngine.ParticleSystemStopBehavior a2; checkEnum(l, 3, out a2); self.Stop(a1, a2); return(0); } return(error(l, "No matched override function to call")); } catch (Exception e) { return(error(l, e)); } }
static public int Stop(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); self.Stop(); return(0); } else if (argc == 2) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); self.Stop(a1); return(0); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
// Use this for initialization void Start() { particles = GetComponent<ParticleSystem>(); sprite = transform.Find("default").gameObject.GetComponent<MeshRenderer>(); particles.Stop(); particles.enableEmission = false; }
static int QPYX_Stop_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 1) { UnityEngine.ParticleSystem QPYX_obj_YXQP = (UnityEngine.ParticleSystem)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.ParticleSystem)); QPYX_obj_YXQP.Stop(); return(0); } else if (QPYX_count_YXQP == 2) { UnityEngine.ParticleSystem QPYX_obj_YXQP = (UnityEngine.ParticleSystem)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.ParticleSystem)); bool QPYX_arg0_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 2); QPYX_obj_YXQP.Stop(QPYX_arg0_YXQP); return(0); } else if (QPYX_count_YXQP == 3) { UnityEngine.ParticleSystem QPYX_obj_YXQP = (UnityEngine.ParticleSystem)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.ParticleSystem)); bool QPYX_arg0_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 2); UnityEngine.ParticleSystemStopBehavior QPYX_arg1_YXQP = (UnityEngine.ParticleSystemStopBehavior)ToLua.CheckObject(L_YXQP, 3, typeof(UnityEngine.ParticleSystemStopBehavior)); QPYX_obj_YXQP.Stop(QPYX_arg0_YXQP, QPYX_arg1_YXQP); return(0); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.ParticleSystem.Stop")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
static int Stop(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem))) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1); obj.Stop(); return(0); } else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(bool))) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1); bool arg0 = LuaDLL.lua_toboolean(L, 2); obj.Stop(arg0); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.Stop")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// Use this for initialization void Start() { part = GetComponent<ParticleSystem>(); audio = GetComponent<AudioSource>(); part.Stop(); part.Clear(); }
// Use this for initialization void Start() { part = GetComponentInChildren<ParticleSystem>(); part.Stop(); game = GameObject.FindWithTag("GameController").GetComponent<GameController>(); }
// Use this for initialization void Start() { ParticulaR = fuegorojo.GetComponent<ParticleSystem>(); ParticulaA= fuegoamarillo.GetComponent<ParticleSystem>(); ParticulaR.Stop (); ParticulaA.Stop (); }
void Start() { jumpVFX = transform.Find ("character/Dust_2").GetComponent<ParticleSystem>(); jumpVFX.Stop(); pi = gameObject.GetComponent<PlayerInfo>(); accelerationRate = pi.accelerationRate; decelerationRate = pi.decelerationRate; accelerationGravity = pi.accelerationGravity; maxSpeed = pi.maxSpeed; jumpHeight = pi.jumpHeight; numberOfJumps = pi.numberOfJumps; terminalVelocity = pi.terminalVelocity; cc = GetComponent<CharacterController>(); velocity = new Vector3(0,0,0); gravityDirection = Vector3.Normalize(accelerationGravity); rayLength = 0.9f; //stop acceleration rate from being more than max speed accelerationRate = accelerationRate > maxSpeed ? maxSpeed : accelerationRate; animator = gameObject.transform.FindChild("character").GetComponent<Animator>(); mesh = transform; gameObject.GetComponent<AudioSource>().Pause(); gameObject.GetComponent<AudioSource>().loop = false; gameObject.GetComponent<AudioSource>().volume = 1000.0f; }
protected override void Awake() { base.Awake(); waterSpray = transform.FindChild("WaterSpray").gameObject; particles = waterSpray.GetComponent<ParticleSystem>(); particles.Stop(); }
public override void OnEnter() { ps = Fsm.GetOwnerDefaultTarget(gameObject).GetComponent<ParticleSystem>(); if (delay.Value <= 0) { if (clear.Value) { stopWithClear.Value = false; ps.Clear(); } else { ps.Stop(); ps.Clear(); } if(finishEvent != null) Fsm.Event(finishEvent);{ Finish(); return; } } startTime = Time.realtimeSinceStartup; timer = 0f; }
void Start() { system = GetComponent<ParticleSystem>(); system.Stop(); active = false; }
void Start() { setDisable(); getitem = GameObject.Find("getitem_particle").GetComponent<ParticleSystem>(); getitem.Stop(); }
// Use this for initialization void Start() { body = transform.Find("body").gameObject; animator = body.GetComponent<Animator>(); particles = GetComponent<ParticleSystem>(); particles.Stop(); particles.enableEmission = false; }
// Use this for initialization void Start() { //Debug.Log(transform.parent.gameObject.GetComponent<MotionClass>()); // DinoMotion = transform.parent.gameObject.GetComponent<DinoMoveScript>(); // Debug.Log(DinoMotion); RunningDust = gameObject.GetComponent<ParticleSystem>(); RunningDust.Stop(); }
void Awake() { _spriteRenderer = GetComponentInChildren<SpriteRenderer>(); _spPS = ((GameObject)Instantiate(candyParticlePrefab)).GetComponent<ParticleSystem>(); _spPS.transform.parent = transform; _spPS.transform.localPosition = new Vector3(0.15f, 0, transform.position.z + 0.1f); _spPS.Stop(); _CC2D = GetComponent<CharacterController2D>(); }
public void Awake() { _particleInstance = (GameObject.Instantiate(_particlePrefab.gameObject) as GameObject).GetComponent<ParticleSystem>(); _particleInstance.transform.SetParent(transform); _particleInstance.playOnAwake = false; _particleInstance.Stop(); _particleInstance.gameObject.GetComponent<CFX_AutoDestructShuriken>().OnlyDeactivate = true; _particleInstance.gameObject.SetActive(false); }
// Use this for initialization void Start() { body = transform.Find("Cylinder").gameObject; particles = GetComponent<ParticleSystem>(); particles.Stop(); particles.enableEmission = false; }
void Awake() { effectTransform = transform.Find("Light Speed Effect"); lightSpeedEffect = effectTransform.particleSystem; lightSpeedEffect.Stop(); lastFramePosition = transform.position; defaultEffectPosition = lightSpeedEffect.transform.localPosition; }
// Use this for initialization void Start() { transform.localScale = new Vector3 (0,0,0); partSys = phySys.GetComponent<ParticleSystem>(); partSys2 = phySys2.GetComponent<ParticleSystem>(); partSys.Stop (); partSys2.Stop(); }
public void LevelIncrease() { levelUp = GameObject.Find ("Level_Up_Popup").GetComponent<ParticleSystem> (); levelUp.Stop(); level++; levelUp.enableEmission = true; levelUp.Play(); }
// Use this for initialization void Start() { sprite = GetComponent<SpriteRenderer>(); ps = GetComponent<ParticleSystem>(); ps.Stop(); Messenger.AddListener("take damage", takeDamage); }
static int _m_Stop(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.ParticleSystem __cl_gen_to_be_invoked = (UnityEngine.ParticleSystem)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 1) { __cl_gen_to_be_invoked.Stop( ); return(0); } if (__gen_param_count == 2 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)) { bool withChildren = LuaAPI.lua_toboolean(L, 2); __cl_gen_to_be_invoked.Stop(withChildren); return(0); } if (__gen_param_count == 3 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2) && translator.Assignable <UnityEngine.ParticleSystemStopBehavior>(L, 3)) { bool withChildren = LuaAPI.lua_toboolean(L, 2); UnityEngine.ParticleSystemStopBehavior stopBehavior; translator.Get(L, 3, out stopBehavior); __cl_gen_to_be_invoked.Stop(withChildren, stopBehavior); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.ParticleSystem.Stop!")); }
void Start() { ps = GetComponent<ParticleSystem>(); ps.Stop(); RandSize(); ps.Play(); //StartCoroutine(SetTime()); }
void Awake() { _sbPS = ((GameObject)Instantiate(sugarBrickParticlePrefab)).GetComponent<ParticleSystem>(); _sbPS.transform.parent = transform; _sbPS.transform.localPosition = new Vector3(0, 0, transform.position.z); _sbPS.Stop(); _spriteRenderer = GetComponent<SpriteRenderer>(); _CC2D = GetComponent<CharacterController2D>(); }
// Use this for initialization void Start() { particles = GetComponent<ParticleSystem>(); sprite = GetComponent<SpriteRenderer>(); particles.Stop(); particles.enableEmission = false; target = GetClosestEnemy (); }
void Awake() { particles = GetComponent<ParticleSystem>(); particles.Stop(); rend = GetComponent<Renderer>(); control = transform.parent.gameObject.GetComponent<HandClickControl>(); color = rend.material.GetColor("_TintColor"); isLeftHand = transform.position.x >= 0; }
void Start() { vuurtje = GetComponentInChildren<ParticleSystem>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>(); pigModel = GameObject.FindGameObjectWithTag("PigModel"); pigColor = GameObject.FindGameObjectWithTag("PigColor"); vuurtje.Stop(); ColorUtility.TryParseHtmlString("#492200FF", out newColor); }
// Use this for initialization protected override void Start() { base.Start(); curChargeDuration = chargeDuration; canGetPush = false; landingIndicator = transform.FindChild("orpi_indicator").GetComponent<ParticleSystem>(); if(landingIndicator.isPlaying) landingIndicator.Stop(); }
private void Awake() { _transform = transform; _gameObject = gameObject; _rigidBody2D = GetComponent<Rigidbody2D>(); _collider = GetComponent<CircleCollider2D>(); _particleSystem = GetComponent<ParticleSystem>(); _particleSystem.Stop(); }
void play(ParticleSystem ps, ParticleInfos pi){ //ps.duration = pi.duration / music.tempo * 60; ps.Stop (); ps.startSize = pi.size; ps.startSpeed = pi.speed; if(pi.quantity > 0) ps.Emit (pi.quantity); ps.emissionRate = pi.timeQuantity; ps.Play (); }
void Awake() { if (GetComponent<Collider2D>() == null) { throw new InvalidOperationException("Flow requires a Collider2D component"); } if (strength <= 0) { Debug.LogWarning("Flow: strength should be a positive value, but it is set to " + strength); } if (duration <= 0) { Debug.LogWarning("Flow: duration should be a positive value, but it is set to " + duration); } bubbles = GetComponentInChildren<ParticleSystem>(); bubbles.Stop(); }
void Start() { particles = GetComponentInChildren<ParticleSystem>(); if (particles == null) { Debug.Log("Cannot find particles for warhead"); } particles.Stop(); transform.rotation = Quaternion.Euler(0.0f, 0.0f, 15.0f); }
void Start() { if (flame != null) { flame.intensity = 0.0f; particle = flame.GetComponent<ParticleSystem> (); if (particle.isPlaying) { particle.Stop (); } } }
static public int Stop(IntPtr l) { try { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); self.Stop(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int Stop(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if(argc==1){ UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l); self.Stop(); pushValue(l,true); return 1; } else if(argc==2){ UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l); System.Boolean a1; checkType(l,2,out a1); self.Stop(a1); pushValue(l,true); return 1; } else if(argc==3){ UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l); System.Boolean a1; checkType(l,2,out a1); UnityEngine.ParticleSystemStopBehavior a2; a2 = (UnityEngine.ParticleSystemStopBehavior)LuaDLL.luaL_checkinteger(l, 3); self.Stop(a1,a2); pushValue(l,true); return 1; } pushValue(l,false); LuaDLL.lua_pushstring(l,"No matched override function Stop to call"); return 2; } catch(Exception e) { return error(l,e); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public static void ClusterStop(this UnityEngine.ParticleSystem ps) { var observer = validateCheck(ps); if (observer == null) { return; } ps.Stop(); FduParticleSystemOP op = new FduParticleSystemOP(); op.operation = FduParticleSystemOP.Operation.stop; observer.addOperation(op); }
static public int Stop__Boolean(IntPtr l) { try { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); self.Stop(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public static void ClusterStop(this UnityEngine.ParticleSystem ps, bool withChildren) { var observer = validateCheck(ps); if (observer == null) { return; } ps.Stop(withChildren); FduParticleSystemOP op = new FduParticleSystemOP(); op.operation = FduParticleSystemOP.Operation.stop; op.paras = new object[1]; op.paras[0] = withChildren; observer.addOperation(op); }
static int Stop(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.ParticleSystem.Register"); #endif try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); obj.Stop(); return(0); } else if (count == 2) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.Stop(arg0); return(0); } else if (count == 3) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); UnityEngine.ParticleSystemStopBehavior arg1 = (UnityEngine.ParticleSystemStopBehavior)ToLua.CheckObject(L, 3, typeof(UnityEngine.ParticleSystemStopBehavior)); obj.Stop(arg0, arg1); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.Stop")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void Init(P5Particle[] p5particles) { particles = p5particles; maxParticles = particles.Length; if (psys == null) { psys = this.gameObject.AddComponent <UnityEngine.ParticleSystem>() as UnityEngine.ParticleSystem; } psys.GetComponent <Renderer>().material = mat; psys.playOnAwake = false; psys.enableEmission = false; psys.loop = false; psys.Stop(); renderParticles = new UnityEngine.ParticleSystem.Particle[maxParticles]; for (int i = 0; i < maxParticles; i++) { renderParticles[i] = new UnityEngine.ParticleSystem.Particle(); } Reset(); }
static int Stop(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); obj.Stop(); return(0); } else if (count == 2) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.Stop(arg0); return(0); } else if (count == 3) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); UnityEngine.ParticleSystemStopBehavior arg1 = (UnityEngine.ParticleSystemStopBehavior)LuaDLL.luaL_checknumber(L, 3); obj.Stop(arg0, arg1); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.Stop")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// Build voxel object public override float Build(Storage voxels, Bounds bounds, Informer informer, object parameter) { // Check for given array if (voxels != null) { int width = voxels.Width; int height = voxels.Height; int depth = voxels.Depth; int sides = voxels.FacesCount; int x, y, z; // Check for non-empty array if (width * height * depth * sides > 0) { if (particles == null) { // Calculate total scaling for one block globalScaling = new Vector3(2.0f * bounds.extents.x / (float)width, 2.0f * bounds.extents.y / (float)height, 2.0f * bounds.extents.z / (float)depth); // Check for given template container containing a particle system and its renderer if (template != null && template.GetComponent <UnityEngine.ParticleSystem>() != null && template.GetComponent <Renderer>() != null && template.GetComponent <Renderer>().GetType() == typeof(ParticleSystemRenderer) && ((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh != null) { // Calculate offset and scaling vector for a particle mesh offset = -((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh.bounds.center; scaling.x = 0.5f / ((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh.bounds.extents.x; scaling.y = 0.5f / ((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh.bounds.extents.y; scaling.z = 0.5f / ((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh.bounds.extents.z; offset.x *= scaling.x; offset.y *= scaling.y; offset.z *= scaling.z; scaling.x *= globalScaling.x; scaling.y *= globalScaling.y; scaling.z *= globalScaling.z; } else { // Unset translation und scaling offset = Vector3.zero; scaling = Vector3.one; } // Add offset for half voxel offset += new Vector3(0.5f * globalScaling.x, 0.5f * globalScaling.y, 0.5f * globalScaling.z); // Move to match position of the original object offset += bounds.center - gameObject.transform.position - bounds.extents; // Create array to store particles to particles = new UnityEngine.ParticleSystem.Particle[voxels.Count]; particlesCount = 0; // Calculate size of one particle particleSize = Mathf.Max(globalScaling.x, Mathf.Max(globalScaling.y, globalScaling.z)) * sizeFactor; } // Check for main container if (particles != null) { // Process all voxels z = currentDepth; //for (z = currentDepth; z < currentDepth + 1; ++z) { y = currentHeight; //for (y = currentHeight; y < currentHeight + 1; ++y) { for (x = 0; x < width; ++x) { // Retrieve material for current coordinate Material material = voxels.GetMaterial(x, y, z); // Check for valid voxel if (material != null) { // Calculate current voxel position Vector3 currentPosition = new Vector3((float)x * globalScaling.x + offset.x, (float)y * globalScaling.y + offset.y, (float)z * globalScaling.z + offset.z); // Set particle properties particles[particlesCount].position = currentPosition; particles[particlesCount].startColor = material.color; particles[particlesCount].remainingLifetime = 1000; particles[particlesCount].startLifetime = 0; particles[particlesCount].randomSeed = 0; particles[particlesCount].rotation = 0; particles[particlesCount].startSize = particleSize; particles[particlesCount].velocity = Vector3.zero; particles[particlesCount].angularVelocity = 0; // Increase number of particles ++particlesCount; } } } // Increase to next height line if (++currentHeight >= height) { // Increase to next depth slice ++currentDepth; currentHeight = 0; } } // Return current progress when building has not been finished if (currentDepth < depth) { return((float)currentDepth / (float)depth); } } } } // Check for particles if (particles != null && particlesCount > 0) { GameObject particlesContainer; // Clone existing or create new container if (template != null) { particlesContainer = (GameObject)Instantiate(template); particlesContainer.name = targetName; particlesContainer.SetActive(true); } else { particlesContainer = new GameObject(targetName); } if (particlesContainer != null) { // Copy position and unset scale and rotation particlesContainer.transform.localPosition = gameObject.transform.position; particlesContainer.transform.localScale = Vector3.one; particlesContainer.transform.localRotation = Quaternion.identity; // Add particles system UnityEngine.ParticleSystem particleSystem = particlesContainer.GetComponent <UnityEngine.ParticleSystem>(); if (particleSystem == null) { particleSystem = particlesContainer.AddComponent <UnityEngine.ParticleSystem>(); } if (particleSystem != null) { // Add particle system renderer, if there is none ParticleSystemRenderer particleSystemRenderer = particlesContainer.GetComponent <ParticleSystemRenderer>(); if (particleSystemRenderer == null) { particleSystemRenderer = particlesContainer.AddComponent <ParticleSystemRenderer>(); // Set render properties if (particleSystemRenderer != null) { particleSystemRenderer.cameraVelocityScale = 0; particleSystemRenderer.lengthScale = 0; particleSystemRenderer.maxParticleSize = 1000; particleSystemRenderer.velocityScale = 0; } } UnityEngine.ParticleSystem.EmissionModule emission = particleSystem.emission; emission.rateOverTime = new UnityEngine.ParticleSystem.MinMaxCurve(10, new AnimationCurve()); emission.enabled = true; // Set properties for static particles var mainModule = particleSystem.main; mainModule.playOnAwake = false; mainModule.maxParticles = particlesCount; mainModule.simulationSpeed = 1; mainModule.startSpeed = 0; mainModule.startLifetime = 1; mainModule.startSize = bounds.extents.magnitude * 2; mainModule.startDelay = 0; mainModule.gravityModifier = 0; mainModule.simulationSpace = ParticleSystemSimulationSpace.Local; // Force a simulation to calculate boundaries particleSystem.Simulate(particleSystem.main.startLifetime.constant); // Set particles particleSystem.SetParticles(particles, particlesCount); // Stop automatic simulation particleSystem.Stop(); emission.enabled = false; } #if UNITY_EDITOR // Add object creation undo operation if (!Application.isPlaying) { UnityEditor.Undo.RegisterCreatedObjectUndo(particlesContainer, "\"" + targetName + "\" Creation"); } #endif // Execute informer callback if (informer != null) { informer(new UnityEngine.Object[] { particlesContainer }, parameter); } } } // Reset current processing data currentDepth = 0; currentHeight = 0; particles = null; return(1); }