/// <summary> /// Handler for the Sprite Exploder component's OnExploded event. This method /// sets various particle system references that will be used in later spawning. /// </summary> void SpriteExploder_OnExploded() { RemoveEventHandlers(); sortedParticleCount = SpriteExploder.GetMaxParticleCount(); if (sortedParticleCount <= 1) // If there are no particles, then call the complete event. { sortedParticleCount = 0; OnCompleted?.Invoke(); return; } particleScale = SpriteExploder.GetParticleScale(); particles = new ParticleSystem.Particle[sortedParticleCount]; UpdateCustomParticleData(); tileCountX = SpriteExploder.GetSubdivisionCountX(); tileCountY = SpriteExploder.GetSubdivisionCountY(); Texture2D texture = SpriteExploder.GetTexture(); if (tileCountX < tileCountY) { pixelSize = texture.width / tileCountX; } else { pixelSize = texture.height / tileCountY; } centerOffset = pixelSize / 2; }