void Start() { gravityEngine = GravityEngine.instance; dt = gravityEngine.GetParticleDt(); // outOfBoundsSquared = gravityEngine.outOfBounds * gravityEngine.outOfBounds; gravityParticles = GetComponent <ParticleSystem>(); InitParticleData(); // Had Play() here - but after Unity 5.3 this broke. Now moved to the update loop. // Get the Init Delegate (if there is one) particlesInit = GetComponent <IGravityParticlesInit>(); if (particlesInit == null && addNBodyVelocity) { // Find the associated NBody // Can either be directly attached (particleSystem is attached directly to object with NBody) OR // can be the parent (if ParticleSystem has its own Game Object and is a child) if (GetComponent <NBody>() != null) { nbodySource = transform.gameObject; } else if (transform.parent != null && transform.parent.gameObject.GetComponent <NBody>() != null) { nbodySource = transform.parent.gameObject; } } particleBySeed = new Dictionary <uint, int>(); // determine if this is a one-time burst scenario int burstCount = 0; ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[gravityParticles.emission.burstCount]; gravityParticles.emission.GetBursts(bursts); foreach (ParticleSystem.Burst burst in bursts) { burstCount += burst.maxCount; } if (burstCount == gravityParticles.main.maxParticles) { oneTimeBurst = true; burstDone = false; } #pragma warning disable 162 // disable unreachable code warning if (debugLogs) { Debug.Log(this.name + " start: oneTimeBurst=" + oneTimeBurst + " burstCount=" + burstCount + " pc=" + gravityParticles.main.maxParticles); } #pragma warning restore 162 // self-register with NBE gravityEngine.RegisterParticles(this); #pragma warning disable 162 // disable unreachable code warning if (debugLogs) { Debug.Log("Registered with GE: self=" + transform.gameObject.name); } #pragma warning restore 162 }