void SliceEvent(Slice2D slice) { Slicer2DParticlesManager.Instantiate(); float posZ = transform.position.z - 0.1f; foreach (List <Vector2D> pointList in slice.slices) { foreach (Pair2D p in Pair2D.GetList(pointList)) { Particle2D firstParticle = Particle2D.Create(Random.Range(0, 360), new Vector3((float)p.A.x, (float)p.A.y, posZ)); Slicer2DParticlesManager.particlesList.Add(firstParticle); Particle2D lastParticle = Particle2D.Create(Random.Range(0, 360), new Vector3((float)p.B.x, (float)p.B.y, posZ)); Slicer2DParticlesManager.particlesList.Add(lastParticle); Vector2 pos = p.A.ToVector2(); while (Vector2.Distance(pos, p.B.ToVector2()) > 0.5f) { pos = Vector2.MoveTowards(pos, p.B.ToVector2(), 0.35f); Particle2D particle = Particle2D.Create(Random.Range(0, 360), new Vector3(pos.x, pos.y, posZ)); Slicer2DParticlesManager.particlesList.Add(particle); } } } }
static public void Instantiate() { if (instance != null) { return; } GameObject manager = new GameObject(); manager.name = "Slicer2D Particles"; instance = manager.AddComponent <Slicer2DParticlesManager>(); }
override public void OnInspectorGUI() { Slicer2DParticlesManager script = target as Slicer2DParticlesManager; GUISortingLayer.Draw(script.sortingLayer); if (GUI.changed) { if (EditorApplication.isPlaying == false) { EditorUtility.SetDirty(script); } } }
void Start() { if (instance == null) { instance = this; } else if (instance != this) { if (Slicer2D.Debug.enabled) { Debug.LogWarning("Slicer2D: Multiple Particle Managers Detected!"); } Destroy(this); } }