Exemplo n.º 1
0
 // Default Constructor
 public ParticleLoader()
 {
     scaledVersion = generatedBody.scaledVersion;
     particle      = PlanetParticleEmitter.Create(scaledVersion);
 }
            /// <summary>
            /// Renders the Window
            /// </summary>
            protected override void Render(Int32 id)
            {
                // Call base
                base.Render(id);

                // Scroll
                BeginScrollView(250, Utils.GetScrollSize<PlanetParticleEmitter>() + distance * 7, 20);

                // Get the list
                if (particles == null)
                {
                    particles = new List<GameObject>();
                    foreach (Transform t in from Transform t in Current.scaledBody.transform where t.name.EndsWith("Particles") select t)
                        particles.Add(t.gameObject);
                }

                // Index
                index = 0;

                // Menu
                Enabled(() => position > 0, () => Button("<<", () => position--, new Rect(20, index * distance + 10, 30, 20))); index--;
                Button(Localization.LOC_KITTOPIATECH_PARTICLEEDITOR_ADD, () =>
                {
                    // Add a new Particle System
                    PlanetParticleEmitter.Create(Current.scaledBody).colorAnimation = new [] { Color.white, Color.white, Color.white, Color.white, Color.white };

                    // Get all particles
                    particles = new List<GameObject>();
                    foreach (Transform t in from Transform t in Current.scaledBody.transform where t.name.EndsWith("Particles") select t)
                        particles.Add(t.gameObject);
                    position = particles.Count - 1;
                }, new Rect(60, index * distance + 10, 250, 20)); index--;
                Enabled(() => position < particles.Count - 1, () => Button(">>", () => position++, new Rect(320, index * distance + 10, 30, 20))); index++;

                // Render the Particle Editor
                if (particles.Count <= 0) return;

                // Assign
                particle = particles[position].GetComponent<PlanetParticleEmitter>();

                // Loop through all the Fields
                RenderObject(particle);

                // Color Array
                Int32 buttonOffset = 20;
                for (Int32 i = 0; i < 5; i++)
                {
                    Int32 i1 = i;
                    Button(Localization.LOC_KITTOPIATECH_PARTICLEEDITOR_COLOR + " " + (i + 1), () => {
                        UIController.Instance.SetEditedObject(KittopiaWindows.Color, particle.colorAnimation[i1], c => particle.colorAnimation[i1] = c);
                        UIController.Instance.EnableWindow(KittopiaWindows.Color);
                    }, new Rect(buttonOffset, index*distance + 10, 60, 20));
                    buttonOffset += 65; index--;
                }
                index += 2;

                // Rebuild the Ring
                Button(Localization.LOC_KITTOPIATECH_PARTICLEEDITOR_UPDATE, () =>
                {
                    typeof(PlanetParticleEmitter).GetMethod("Start", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(particle, null);
                    particle.targetTransform = null;
                });

                // Delete Ring
                Button(Localization.LOC_KITTOPIATECH_PARTICLEEDITOR_REMOVE, () =>
                {
                    UnityEngine.Object.Destroy(particles[position]);
                    particles = null;
                    position = 0;
                });

                // End Scroll
                EndScrollView();
            }