Ejemplo n.º 1
0
        void OnGUI()
        {
            // Manipulator values
            GUI.Box(new Rect(0, 0, 220, 125), "Manipulator");
            GUI.Label(new Rect(10, 30, 200, 30), "Strength: " + manipulatorStrength.ToString("f1"));
            manipulatorStrength = GUI.HorizontalSlider(new Rect(10, 55, 200, 30), manipulatorStrength, 0f, 30f);
            if (GUI.Button(new Rect(10, 85, 200, 30), "Transition: " + manipulator.property.transition.ToString()))
            {
                if (manipulator.property.transition == MANIPULATORPROPERTYTRANSITIONC.Linear)
                {
                    manipulator.property.transition = MANIPULATORPROPERTYTRANSITIONC.Lerp;
                }
                else
                {
                    manipulator.property.transition = MANIPULATORPROPERTYTRANSITIONC.Linear;
                }
            }

            // Turbulence values
            GUI.Box(new Rect(240, 0, 220, 125), "Turbulence");
            GUI.Label(new Rect(250, 30, 200, 30), "Strength: " + particles.turbulenceStrength.ToString("f1"));
            particles.turbulenceStrength = GUI.HorizontalSlider(new Rect(250, 55, 200, 30), particles.turbulenceStrength, 0f, 50f);
            if (GUI.Button(new Rect(250, 85, 200, 30), "Type: " + particles.turbulenceType.ToString()))
            {
                if (particles.turbulenceType == TURBULENCETYPE.Perlin)
                {
                    particles.turbulenceType = TURBULENCETYPE.Simplex;
                }
                else
                {
                    particles.turbulenceType = TURBULENCETYPE.Perlin;
                }
            }

            // Mesh values
            GUI.Box(new Rect(Screen.width - 220, 0, 220, 125), "Mesh");
            GUI.Label(new Rect(Screen.width - 210, 30, 200, 30), "Rotation Speed: " + rotationSpeed.ToString("f1"));
            rotationSpeed = GUI.HorizontalSlider(new Rect(Screen.width - 210, 55, 200, 30), rotationSpeed, -100f, 100f);
            if (GUI.Button(new Rect(Screen.width - 210, 85, 200, 30), "Subdivide x" + subdivisionFactor.ToString()))
            {
                subdivisionFactor++; subdivisionFactor = subdivisionFactor % 4;

                // Subdivide or recreate the original mesh depending on subdivision factor
                if (subdivisionFactor == 0)
                {
                    IsoSphere.CreateMesh(gameObject, 1, proceduralMeshSize, false);
                }
                else
                {
                    SubdivideMesh.Subdivide(gameObject.GetComponent <MeshFilter>().mesh);
                }

                UpdateTargetManipulator();
            }
        }
Ejemplo n.º 2
0
        void Start()
        {
            // Create an isosphere on this GameObject (could be any type of mesh configuration)
            IsoSphere.CreateMesh(gameObject, proceduralMeshRecursion, proceduralMeshSize, false);

            // Create a Manipulator on the particle system and set it up to work as a mesh target
            if (particles != null)
            {
                // Create the new manipulator
                manipulator = PlaygroundC.ManipulatorObject(gameObject.transform, particles);

                // Set the manipulator to Property: Mesh Target and make it transition its particles
                manipulator.type          = MANIPULATORTYPEC.Property;
                manipulator.property.type = MANIPULATORPROPERTYTYPEC.MeshTarget;
                manipulator.property.meshTarget.gameObject = gameObject;
                manipulator.property.transition            = MANIPULATORPROPERTYTRANSITIONC.Linear;
            }
            else
            {
                Debug.Log("You must assign a Particle Playground system to this script.", gameObject);
            }
        }