Exemplo n.º 1
0
    private void DrawManipulatorGUI(int index)
    {
        m_ManipulatorObject = m_ParticleTool.manipulators[index];

        GUILayout.BeginVertical(new GUIStyle("HelpBox"));
        EditorGUILayout.ObjectField(new GUIContent("Manipulator"), m_ManipulatorObject.transform, typeof(Transform), false);
        EditorGUI.indentLevel++;
        m_ManipulatorObject.transform.localPosition = EditorGUILayout.Vector3Field(new GUIContent("Position"), m_ManipulatorObject.transform.localPosition);
        m_ManipulatorObject.transform.localRotation = Quaternion.Euler(EditorGUILayout.Vector3Field(new GUIContent("Rotation"), m_ManipulatorObject.transform.localRotation.eulerAngles));
        m_ManipulatorObject.transform.localScale    = EditorGUILayout.Vector3Field(new GUIContent("Scale"), m_ManipulatorObject.transform.localScale);
        EditorGUI.indentLevel--;
        m_ManipulatorObject.type  = (MANIPULATORTYPE)EditorGUILayout.EnumPopup(new GUIContent("Type"), m_ManipulatorObject.type);
        m_ManipulatorObject.shape = (MANIPULATORSHAPE)EditorGUILayout.EnumPopup(new GUIContent("Shape"), m_ManipulatorObject.shape);
        if (m_ManipulatorObject.shape == MANIPULATORSHAPE.Box)
        {
            EditorGUI.indentLevel++;
            m_ManipulatorObject.bounds = EditorGUILayout.BoundsField(new GUIContent("Box Scale"), m_ManipulatorObject.bounds);
            EditorGUI.indentLevel--;
        }
        m_ManipulatorObject.size           = EditorGUILayout.Slider(new GUIContent("Size"), m_ManipulatorObject.size, 0, m_ManipulatorObject.size * 2);
        m_ManipulatorObject.strength       = EditorGUILayout.Slider(new GUIContent("Strength"), m_ManipulatorObject.strength, 0, m_ManipulatorObject.size);
        m_ManipulatorObject.smoothStrength = EditorGUILayout.Slider(new GUIContent("Smooth Strength"), m_ManipulatorObject.smoothStrength, 0, 1);
        m_ManipulatorObject.smoothDistance = EditorGUILayout.Slider(new GUIContent("Smooth Distance"), m_ManipulatorObject.smoothDistance, 0, 1);
        GUILayout.Space(5);
        if (GUILayout.Button("Delete Manipulator"))
        {
            DeleteManipulator(m_ManipulatorObject);
        }
        GUILayout.Space(5);
        GUILayout.EndVertical();
    }
Exemplo n.º 2
0
    void LateUpdate()
    {
        Vector3 manipulatorPosition;
        //Vector3 particlePosition;
        Color startColor;


        if (ActiveManipulator())
        {
            manipulatorObject   = manipulators[manipulatorInstance];
            manipulatorPosition = manipulatorObject.transform.position;

            particleSystem.GetParticles(particles);
            for (int i = 0; i < particles.Length; i++)
            {
                startColor = particles[i].startColor;
                //particlePosition = particles[i].position;  // particlePosition = GetParticlePosition(particles[i]);
                if (manipulatorObject.IsParticleInRange(particles[i], manipulatorObject.transform, manipulatorObject.shape))
                {
                    //manipulatorObject.particlesInRange.Add(particles[i]);
                    particles[i].velocity   = GetForce(particles[i], manipulatorObject, manipulatorObject.type);
                    particles[i].startColor = Color.red;
                }
            }

            //  Do calculations on all particles affected.  Once particles die, need to recalculate cause once particle dies, it can't find the particle.
            // for (int j = 0; j < manipulatorObject.particlesInRange.Count; j ++){
            //  particles[j].startColor = Color.red;
            // }

            particleSystem.SetParticles(particles, particles.Length);
        }
    }
Exemplo n.º 3
0
    public Vector3 GetForce(ParticleSystem.Particle particle, ManipulatorObjectC manipulator, MANIPULATORTYPE type)
    {
        Vector3 manipulatorPosition = manipulator.transform.position;


        Vector3 force               = Vector3.zero;
        Vector3 particlePosition    = particle.position;
        float   manipulatorDistance = Vector3.Distance(manipulatorPosition, particlePosition) / manipulator.smoothDistance;
        float   manipulatorStrength = manipulator.strength * manipulator.size;
        float   mStrengthModifier   = manipulatorStrength / manipulatorDistance;
        float   time = Time.deltaTime * (mStrengthModifier / manipulator.smoothStrength);

        switch (type)
        {
        case MANIPULATORTYPE.Attraction:
            force = Vector3.Lerp(particle.velocity, (manipulatorPosition - particlePosition) * mStrengthModifier, time);
            break;

        case MANIPULATORTYPE.Repellent:
            force = Vector3.Lerp(particle.velocity, (particlePosition - manipulatorPosition) * mStrengthModifier, time);
            break;

        case MANIPULATORTYPE.VortexAttraction:
            force = Vector3.Lerp(particle.velocity, ((manipulatorPosition - particlePosition) * mStrengthModifier - Vector3.Cross(transform.forward, manipulatorPosition - particlePosition) * mStrengthModifier),
                                 (Time.deltaTime * mStrengthModifier) / manipulator.smoothStrength);
            break;
        }
        return(force);
    }
Exemplo n.º 4
0
    public void CreateManipulator()
    {
        manipulatorObject = new ManipulatorObjectC();
        manipulatorObject.CreateManipulatorObject(new Vector3(0, 0, 5), Vector3.zero, particleSystem);

        manipulators.Add(manipulatorObject);
    }
Exemplo n.º 5
0
    ManipulatorObjectC manipulator;                             // Cached manipulator

    void Start()
    {
        // Get the manipulator from the particle system
        manipulator = PlaygroundC.GetManipulator(manipulatorNumber, particles);

        // Set all protected particles within specified ranges from protectedParticles
        SetProtectedParticles();
    }
	ManipulatorObjectC manipulator;							// Cached manipulator

	void Start () {

		// Get the manipulator from the particle system
		manipulator = PlaygroundC.GetManipulator(manipulatorNumber, particles);

		// Set all protected particles within specified ranges from protectedParticles
		SetProtectedParticles();
	}
	ManipulatorObjectC manipulator;				// Cached version of maipulator

	void Start () {

		// Set Cache
		if (localManipulator)
			manipulator = PlaygroundC.GetManipulator(manipulatorNumber, particles);
		else
			manipulator = PlaygroundC.GetManipulator(manipulatorNumber);
			
	}
    public static void RenderManipulatorInScene(ManipulatorObjectC thisManipulator, Color manipulatorColor)
    {
        // Draw Manipulators in Scene View
        if (thisManipulator.transform)
        {
            Handles.color = new Color(manipulatorColor.r, manipulatorColor.g, manipulatorColor.b, Mathf.Clamp(Mathf.Abs(thisManipulator.strength), .25f, 1f));
            Handles.color = thisManipulator.enabled? Handles.color : new Color(manipulatorColor.r, manipulatorColor.g, manipulatorColor.b, .2f);

            // Position
            if (Tools.current == Tool.Move)
            {
                thisManipulator.transform.position = Handles.PositionHandle(thisManipulator.transform.position, Tools.pivotRotation == PivotRotation.Global? Quaternion.identity : thisManipulator.transform.rotation);
            }
            // Rotation
            else if (Tools.current == Tool.Rotate)
            {
                thisManipulator.transform.rotation = Handles.RotationHandle(thisManipulator.transform.rotation, thisManipulator.transform.position);
            }
            // Scale
            else if (Tools.current == Tool.Scale)
            {
                thisManipulator.transform.localScale = Handles.ScaleHandle(thisManipulator.transform.localScale, thisManipulator.transform.position, thisManipulator.transform.rotation, HandleUtility.GetHandleSize(thisManipulator.transform.position));
            }

            // Sphere Size
            if (thisManipulator.shape == MANIPULATORSHAPEC.Sphere)
            {
                thisManipulator.size = Handles.RadiusHandle(Quaternion.identity, thisManipulator.transform.position, thisManipulator.size);
                if (thisManipulator.enabled && GUIUtility.hotControl > 0)
                {
                    Handles.Label(thisManipulator.transform.position + new Vector3(thisManipulator.size + 1f, 1f, 0f), "Size: " + thisManipulator.size.ToString("f2"));
                }

                // Box Bounds
            }
            else
            {
                DrawManipulatorBox(thisManipulator);
            }

            // Strength
            manipulatorHandlePosition = thisManipulator.transform.position + new Vector3(0f, thisManipulator.strength, 0f);

            Handles.DrawLine(thisManipulator.transform.position, manipulatorHandlePosition);
            thisManipulator.strength = Handles.ScaleValueHandle(thisManipulator.strength, manipulatorHandlePosition, Quaternion.identity, HandleUtility.GetHandleSize(manipulatorHandlePosition), Handles.SphereCap, 1);
            if (thisManipulator.enabled && GUIUtility.hotControl > 0)
            {
                Handles.Label(manipulatorHandlePosition + new Vector3(1f, 1f, 0f), "Strength: " + thisManipulator.strength.ToString("f2"));
            }

            Handles.color = new Color(.4f, .6f, 1f, .025f);
            Handles.DrawSolidDisc(thisManipulator.transform.position, Camera.current.transform.forward, thisManipulator.strength);
            Handles.color = new Color(.4f, .6f, 1f, .5f);
            Handles.DrawSolidDisc(thisManipulator.transform.position, Camera.current.transform.forward, HandleUtility.GetHandleSize(thisManipulator.transform.position) * .05f);
        }
    }
Exemplo n.º 9
0
//	private float m_Multiplier;

    public void Awake()
    {
        m_Sprite               = transform.GetComponentInChildren <SpriteRenderer>();
        m_LineRenderer         = transform.GetComponentInChildren <LineRenderer>();
        m_Particles            = transform.GetComponentInChildren <PlaygroundParticlesC>();
        m_ManipulatorTransform = m_Particles.transform.FindChild("Manipulator");

        m_ManipulatorObstruction = PlaygroundC.GetManipulator(0, m_Particles);
        m_ManipulatorColor       = PlaygroundC.GetManipulator(1, m_Particles);
    }
    ManipulatorObjectC manipulator;                     // Cached version of maipulator

    void Start()
    {
        // Set Cache
        if (localManipulator)
        {
            manipulator = PlaygroundC.GetManipulator(manipulatorNumber, particles);
        }
        else
        {
            manipulator = PlaygroundC.GetManipulator(manipulatorNumber);
        }
    }
Exemplo n.º 11
0
 public void DeleteManipulator(ManipulatorObjectC manipulatorObject)
 {
     if (Application.isEditor)
     {
         manipulators.Remove(manipulatorObject);
         Object.DestroyImmediate(manipulatorObject.transform.gameObject);
     }
     else
     {
         manipulators.Remove(manipulatorObject);
         Object.Destroy(manipulatorObject.transform.gameObject);
     }
 }
Exemplo n.º 12
0
 private void GetManipulatorProperty(ManipulatorObjectC manipulator)
 {
     m_ManipulatorObject = manipulator;
     //  Handles work in world space, so we need to convert position and rotation to world space
     m_Transform      = m_ManipulatorObject.transform;
     m_Position       = m_ManipulatorObject.transform.position;
     m_Rotation       = m_ManipulatorObject.transform.rotation = Tools.pivotRotation == PivotRotation.Local ? m_ManipulatorObject.transform.rotation : Quaternion.identity;
     m_Scale          = m_ManipulatorObject.transform.lossyScale;
     m_Type           = m_ManipulatorObject.type;
     m_Shape          = m_ManipulatorObject.shape;
     m_Size           = m_ManipulatorObject.size;
     m_Bounds         = m_ManipulatorObject.bounds;
     m_Strength       = m_ManipulatorObject.strength;
     m_SmoothStrength = m_ManipulatorObject.smoothStrength;
     m_SmoothDistance = m_ManipulatorObject.smoothDistance;
 }
Exemplo n.º 13
0
    public virtual void Awake()
    {
        m_PigmentCircle        = transform.FindChild("Pigment Circle").GetComponent <SpriteRenderer>();
        m_PigmentRing          = transform.FindChild("Pigment Ring").GetComponent <SpriteRenderer>();
        m_CromaticRing         = transform.FindChild("Cromatic Ring").GetComponent <SpriteRenderer>();
        m_Raycast              = transform.FindChild("Raycast");
        m_Particles            = m_Raycast.GetComponentInChildren <PlaygroundParticlesC>();
        m_ManipulatorTransform = m_Particles.transform.FindChild("Manipulator");
        m_LineRenderer         = m_Raycast.GetComponentInChildren <LineRenderer>();
        m_Output = m_Raycast.GetComponentInChildren <SpriteRenderer>();

        m_ManipulatorObstruction = PlaygroundC.GetManipulator(0, m_Particles);
        m_ManipulatorColor       = PlaygroundC.GetManipulator(1, m_Particles);

        m_ParticleRing = GetComponentInChildren <ParticleSystem>();
        m_SoundSource  = GetComponent <AudioSource>();
    }
Exemplo n.º 14
0
    void OnEnable()
    {
        if (_manipulator == null)
        {
            _manipulator = PlaygroundC.GetManipulator(manipulatorIndex, particles);
        }

        // Sanity check
        _targetPosition = target.position;
        _manipulator.particleEventEnter -= Teleport;

        // Enable the Manipulator
        _manipulator.enabled = true;

        // Assign to the event delegate of when a particle is entering the Manipulator
        _manipulator.particleEventEnter += Teleport;
    }
	void Start () {
		if (mainCam==null) {
			mainCam = Camera.main;
			mainCamTransform = mainCam.transform;
			PlaygroundParticlesC[] ps = GameObject.FindObjectsOfType<PlaygroundParticlesC>();
			foreach (PlaygroundParticlesC p in ps) {
				if (p.manipulators.Count>0) {
					manipulator = p.manipulators[0];
					break;
				}
			}
			turbulenceScript = GameObject.FindObjectOfType<PlaygroundTurbulenceOnGameObjects>();
		}
		r = GetComponent<Renderer>();
		t = transform;
		exitMaterial = r.sharedMaterial;
		camZ = -mainCamTransform.position.z+t.position.z;
	}
Exemplo n.º 16
0
    void AddRemoveInRange()
    {
        RemoveOutOfRange();

        Collider[] inRangeObjects = Physics.OverlapSphere(originTransform.position, radius, layer);
        for (int i = 0; i < inRangeObjects.Length; i++)
        {
            if (!ManipulatorHasTransform(inRangeObjects[i].transform))
            {
                ManipulatorObjectC newManipulator = PlaygroundC.ManipulatorObject(inRangeObjects[i].transform, particles);

                // Setup the added manipulator here
                newManipulator.type     = MANIPULATORTYPEC.Repellent;
                newManipulator.size     = 5f;
                newManipulator.strength = 3f;
            }
        }
    }
Exemplo n.º 17
0
    void Start()
    {
        // Mouse cursor not wanted
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
        Screen.showCursor = false;
#else
        Cursor.visible = false;
#endif


        // Make sure particle systems are inactive
        foreach (PlaygroundFxCycleItem p in particleFx)
        {
            p.particles.emit = false;
            p.particles.particleSystemGameObject.SetActive(false);
        }

        // Set initial skybox values
        skyboxColorOnLoad = RenderSettings.skybox.GetColor("_Tint");
        RenderSettings.skybox.SetColor("_Tint", Color.black);

        // Cache up!
        cam                          = Camera.main;
        camTransform                 = cam.transform;
        camFov                       = cam.fieldOfView;
        repellentManipulator         = PlaygroundC.GetManipulator(0);
        repellentManipulator.enabled = false;
        particleBlastClips           = particleBlastSound.GetComponent <SoundFxArray>().sounds;

        // Set initial camera values
        camPivot.position    = camSpline.GetPoint(0f);
        camRotation.rotation = Quaternion.LookRotation(-camRotation.position);

        // Run the intro
        StartCoroutine(FadeIn());

        // Get started right away if no user interaction is required
        if (isSelfRunning)
        {
            pressSpaceText.SetActive(false);
            StartCoroutine(Selfrunning());
        }
    }
	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);
	}
	int pickups = 0;						// As an example count the amount of pickups made

	void Start () {

		// Cache the Local Manipulator
		manipulator = PlaygroundC.GetManipulator(manipulatorIndex, particles);

		// Note that you can set the Manipulator to Type: None in case you have no intention to also modify the particles behavior
		// manipulator.type = MANIPULATORTYPEC.None;

		// Make sure we're tracking particles
		manipulator.trackParticles = true;

		// Make sure we're sending enter events
		manipulator.sendEventEnter = true;

		// Make sure we're using the fastest tracking method
		manipulator.trackingMethod = TrackingMethod.ManipulatorId;

		// Assign your function to the event delegate
		manipulator.particleEventEnter += OnManipulatorEnter;
	}
Exemplo n.º 20
0
    //public int manipulatorInstance = ParticleToolC.manipulatorInstance;

    public string DebugManipulatorObject(ManipulatorObjectC manipulatorObject)
    {
        Transform        _transform      = manipulatorObject.transform;
        MANIPULATORTYPE  _type           = manipulatorObject.type;
        MANIPULATORSHAPE _shape          = manipulatorObject.shape;
        float            _size           = manipulatorObject.size;
        Bounds           _bounds         = manipulatorObject.bounds;
        float            _strength       = manipulatorObject.strength;
        float            _smoothStrength = manipulatorObject.smoothStrength;
        float            _smoothDistance = manipulatorObject.smoothDistance;

        string manipulatorInfo = ("Manipulator:  " + manipulatorObject.transform + "\n" +
                                  "Position:  " + manipulatorObject.transform.localPosition + "\n" +
                                  "Rotation:  " + manipulatorObject.transform.localRotation + "\n" +
                                  "Type:  " + manipulatorObject.type + "\n" +
                                  "Size:  " + manipulatorObject.size + "\n" +
                                  "Strength:  " + manipulatorObject.strength + "\n");

        return(manipulatorInfo);
    }
Exemplo n.º 21
0
    public void Awake()
    {
        switch (type)
        {
        case PipeType.Entry:
//			m_Particles = GetComponentInChildren<PlaygroundParticlesC>();
            theSprite.color = new Color(0, 0, 0, 0);
            break;

        case PipeType.Exit:
            m_Raycast              = transform.FindChild("Raycast");
            m_LineRenderer         = m_Raycast.GetComponentInChildren <LineRenderer>();
            m_Particles            = GetComponentInChildren <PlaygroundParticlesC>();
            m_ManipulatorTransform = m_Particles.transform.FindChild("Manipulator");

            m_ManipulatorObstruction = PlaygroundC.GetManipulator(0, m_Particles);
            m_ManipulatorColor       = PlaygroundC.GetManipulator(1, m_Particles);
            break;
        }
    }
Exemplo n.º 22
0
    public void Awake()
    {
        m_RaycastLeft  = transform.FindChild("RaycastLeft");
        m_RaycastRight = transform.FindChild("RaycastRight");

        m_LineRendererLeft  = m_RaycastLeft.GetComponentInChildren <LineRenderer>();
        m_LineRendererRight = m_RaycastRight.GetComponentInChildren <LineRenderer>();

        m_ParticleLeft  = m_RaycastLeft.GetComponentInChildren <PlaygroundParticlesC>();
        m_ParticleRight = m_RaycastRight.GetComponentInChildren <PlaygroundParticlesC>();

        m_ManipulatorLeft  = m_ParticleLeft.transform.FindChild("Manipulator");
        m_ManipulatorRight = m_ParticleRight.transform.FindChild("Manipulator");

        m_ManipulatorObstuctionLeft  = PlaygroundC.GetManipulator(0, m_ParticleLeft);
        m_ManipulatorObstuctionRight = PlaygroundC.GetManipulator(0, m_ParticleRight);

        m_ManipulatorColorLeft  = PlaygroundC.GetManipulator(1, m_ParticleLeft);
        m_ManipulatorColorRight = PlaygroundC.GetManipulator(1, m_ParticleRight);
    }
Exemplo n.º 23
0
    int pickups = 0;                            // As an example count the amount of pickups made

    void Start()
    {
        // Cache the Local Manipulator
        manipulator = PlaygroundC.GetManipulator(manipulatorIndex, particles);

        // Note that you can set the Manipulator to Type: None in case you have no intention to also modify the particles behavior
        // manipulator.type = MANIPULATORTYPEC.None;

        // Make sure we're tracking particles
        manipulator.trackParticles = true;

        // Make sure we're sending enter events
        manipulator.sendEventEnter = true;

        // Make sure we're using the fastest tracking method
        manipulator.trackingMethod = TrackingMethod.ManipulatorId;

        // Assign your function to the event delegate
        manipulator.particleEventEnter += OnManipulatorEnter;
    }
Exemplo n.º 24
0
	void Start () {
		
		// Mouse cursor not wanted
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
		Screen.showCursor = false;
#else
		Cursor.visible = false;
#endif

		
		// Make sure particle systems are inactive
		foreach (PlaygroundFxCycleItem p in particleFx) {
			p.particles.emit = false;
			p.particles.particleSystemGameObject.SetActive (false);
		}
		
		// Set initial skybox values
		skyboxColorOnLoad = RenderSettings.skybox.GetColor ("_Tint");
		RenderSettings.skybox.SetColor ("_Tint", Color.black);
		
		// Cache up!
		cam = Camera.main;
		camTransform = cam.transform;
		camFov = cam.fieldOfView;
		repellentManipulator = PlaygroundC.GetManipulator(0);
		repellentManipulator.enabled = false;
		particleBlastClips = particleBlastSound.GetComponent<SoundFxArray>().sounds;
		
		// Set initial camera values
		camPivot.position = camSpline.GetPoint(0f);
		camRotation.rotation = Quaternion.LookRotation(-camRotation.position);
		
		// Run the intro
		StartCoroutine(FadeIn());
		
		// Get started right away if no user interaction is required
		if (isSelfRunning) {
			pressSpaceText.SetActive(false);
			StartCoroutine(Selfrunning());
		}
	}
    int highestPop;                                                     // Keep track of highest pop

    void Start()
    {
        // Cache the manipulator of bubbleParticles (at list position 0)
        manipulator = PlaygroundC.GetManipulator(0, bubbleParticles);

        // Cache the manipulator transform, this looks a bit awkward at first, however the transform of a
        // manipulator is a thread-safe wrapper class which has a variable containing the Transform component.
        // In this example scene manipulatorTransform = transform; is the same.
        manipulatorTransform = manipulator.transform.transform;

        // Hook up functions to the Event Delegates on the manipulator
        manipulator.particleEventEnter     += OnManipulatorEnter;
        manipulator.particleEventExit      += OnManipulatorExit;
        manipulator.particleEventBirth     += OnManipulatorBirth;
        manipulator.particleEventDeath     += OnManipulatorDeath;
        manipulator.particleEventCollision += OnManipulatorCollision;

        mainCamera   = Camera.main;
        popTextColor = popText.color;
        InvokeRepeating("UpdateGUI", 0, guiUpdateTime);
    }
	int highestPop;											// Keep track of highest pop
	
	void Start () {

		// Cache the manipulator of bubbleParticles (at list position 0)
		manipulator = PlaygroundC.GetManipulator (0, bubbleParticles);

		// Cache the manipulator transform, this looks a bit awkward at first, however the transform of a
		// manipulator is a thread-safe wrapper class which has a variable containing the Transform component.
		// In this example scene manipulatorTransform = transform; is the same.
		manipulatorTransform = manipulator.transform.transform;

		// Hook up functions to the Event Delegates on the manipulator
		manipulator.particleEventEnter += OnManipulatorEnter;
		manipulator.particleEventExit += OnManipulatorExit;
		manipulator.particleEventBirth += OnManipulatorBirth;
		manipulator.particleEventDeath += OnManipulatorDeath;
		manipulator.particleEventCollision += OnManipulatorCollision;

		mainCamera = Camera.main;
		popTextColor = popText.color;
		InvokeRepeating ("UpdateGUI", 0, guiUpdateTime);
	}
Exemplo n.º 27
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);
            }
        }
 void Start()
 {
     if (mainCam == null)
     {
         mainCam          = Camera.main;
         mainCamTransform = mainCam.transform;
         PlaygroundParticlesC[] ps = GameObject.FindObjectsOfType <PlaygroundParticlesC>();
         foreach (PlaygroundParticlesC p in ps)
         {
             if (p.manipulators.Count > 0)
             {
                 manipulator = p.manipulators[0];
                 break;
             }
         }
         turbulenceScript = GameObject.FindObjectOfType <PlaygroundTurbulenceOnGameObjects>();
     }
     r            = GetComponent <Renderer>();
     t            = transform;
     exitMaterial = r.sharedMaterial;
     camZ         = -mainCamTransform.position.z + t.position.z;
 }
Exemplo n.º 29
0
 public void DeleteManipulator(ManipulatorObjectC m_ManipulatorObject)
 {
     m_ParticleTool.DeleteManipulator(m_ManipulatorObject);
 }
 // Use this for initialization
 void Start()
 {
     manipulator = PlaygroundC.GetManipulator(0, GetComponent <PlaygroundParticlesC>());
 }
Exemplo n.º 31
0
	public static void RenderManipulatorProperty (ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, SerializedProperty serializedManipulatorProperty) {
		if (thisManipulatorProperty == null) thisManipulatorProperty = new ManipulatorPropertyC();
		
		thisManipulatorProperty.type = (MANIPULATORPROPERTYTYPEC)EditorGUILayout.EnumPopup(playgroundLanguage.propertyType, thisManipulatorProperty.type);
		bool guiEnabled = GUI.enabled;
		
		EditorGUILayout.Separator();
		
		// Velocity
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Velocity || thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.AdditiveVelocity) {
			thisManipulatorProperty.velocity = EditorGUILayout.Vector3Field(playgroundLanguage.particleVelocity, thisManipulatorProperty.velocity);
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.velocityStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.useLocalRotation = EditorGUILayout.Toggle(playgroundLanguage.localRotation, thisManipulatorProperty.useLocalRotation);
		} else 
			// Color
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Color) {
			thisManipulatorProperty.color = EditorGUILayout.ColorField(playgroundLanguage.particleColor, thisManipulatorProperty.color);
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.colorStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyColorInRange, thisManipulatorProperty.onlyColorInRange);
			thisManipulatorProperty.keepColorAlphas = EditorGUILayout.Toggle(playgroundLanguage.keepColorAlphas, thisManipulatorProperty.keepColorAlphas);
		} else
			// Size
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Size) {
			thisManipulatorProperty.size = EditorGUILayout.FloatField(playgroundLanguage.particleSize, thisManipulatorProperty.size);
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.sizeStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.onlySizeInRange = EditorGUILayout.Toggle(playgroundLanguage.onlySizeInRange, thisManipulatorProperty.onlySizeInRange);
		} else
			// Target
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Target) {
			
			// Target List
			bool hasNull = false;
			EditorGUILayout.BeginVertical(boxStyle);
			playgroundSettings.manipulatorTargetsFoldout = GUILayout.Toggle(playgroundSettings.manipulatorTargetsFoldout, playgroundLanguage.targets+" ("+thisManipulatorProperty.targets.Count+")", EditorStyles.foldout);
			if (playgroundSettings.manipulatorTargetsFoldout) {
				if (thisManipulatorProperty.targets.Count>0) {
					for (int t = 0; t<thisManipulatorProperty.targets.Count; t++) {
						EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
						EditorGUILayout.BeginHorizontal();
						
						GUILayout.Label(t.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
						thisManipulatorProperty.targets[t].transform = EditorGUILayout.ObjectField("", thisManipulatorProperty.targets[t].transform, typeof(Transform), true) as Transform;
						if (!thisManipulatorProperty.targets[t].available) hasNull = true;
						
						EditorGUILayout.Separator();
						if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							thisManipulatorProperty.targets.RemoveAt(t);
						}
						
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.EndVertical();
					}
				} else {
					EditorGUILayout.HelpBox(playgroundLanguage.noTargets, MessageType.Info);
				}
				
				if (hasNull)
					EditorGUILayout.HelpBox(playgroundLanguage.allTargets, MessageType.Warning);
				
				if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
					PlaygroundTransformC newPlaygroundTransform = new PlaygroundTransformC();
					newPlaygroundTransform.transform = thisManipulator.transform.transform;
					newPlaygroundTransform.Update ();
					thisManipulatorProperty.targets.Add(newPlaygroundTransform);
				}
				EditorGUILayout.Separator();
			}
			EditorGUILayout.EndVertical();
			
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange);
			thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
		} else
			// Death
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Death) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.deathStrength, thisManipulatorProperty.strength);
		} else
			// Attractor
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Attractor) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.attractorStrength, thisManipulatorProperty.strength);
		} else
			// Gravitational
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Gravitational) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.gravitationalStrength, thisManipulatorProperty.strength);
		} else
			// Repellent
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Repellent) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.repellentStrength, thisManipulatorProperty.strength);
		} else 
			// Vortex
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Vortex) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.vortexStrength, thisManipulatorProperty.strength);
		} else
			// Turbulence
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Turbulence) {
			thisManipulatorProperty.turbulenceType = (TURBULENCETYPE)EditorGUILayout.EnumPopup (playgroundLanguage.turbulenceType, thisManipulatorProperty.turbulenceType);
			EditorGUI.indentLevel++;
			thisManipulatorProperty.strength = EditorGUILayout.Slider(playgroundLanguage.strength, thisManipulatorProperty.strength, 0f, playgroundSettings.maximumAllowedTurbulenceStrength);
			thisManipulatorProperty.turbulenceScale = EditorGUILayout.Slider(playgroundLanguage.scale, thisManipulatorProperty.turbulenceScale, 0f, playgroundSettings.maximumAllowedTurbulenceScale);
			thisManipulatorProperty.turbulenceTimeScale = EditorGUILayout.Slider(playgroundLanguage.timeScale, thisManipulatorProperty.turbulenceTimeScale, 0f, playgroundSettings.maximumAllowedTurbulenceTimeScale);
			EditorGUILayout.BeginHorizontal();
			thisManipulatorProperty.turbulenceApplyLifetimeStrength = EditorGUILayout.ToggleLeft (playgroundLanguage.lifetimeStrength, thisManipulatorProperty.turbulenceApplyLifetimeStrength, GUILayout.Width (140));
			GUILayout.FlexibleSpace();
			GUI.enabled = (thisManipulatorProperty.turbulenceApplyLifetimeStrength && thisManipulatorProperty.turbulenceType!=TURBULENCETYPE.None);
			serializedManipulatorProperty.FindPropertyRelative("turbulenceLifetimeStrength").animationCurveValue = EditorGUILayout.CurveField(serializedManipulatorProperty.FindPropertyRelative("turbulenceLifetimeStrength").animationCurveValue);
			GUI.enabled = true;
			EditorGUILayout.EndHorizontal();
			EditorGUI.indentLevel--;
		} else
			// Lifetime Color
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.LifetimeColor) {
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("lifetimeColor"), new GUIContent(playgroundLanguage.lifetimeColor));
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.colorStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyColorInRange, thisManipulatorProperty.onlyColorInRange);
		} else
			// Mesh target
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.MeshTarget) {
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTarget").FindPropertyRelative("gameObject"), new GUIContent(playgroundLanguage.meshTarget));
			GUILayout.BeginVertical(boxStyle);
			EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions);
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural"), new GUIContent(
				playgroundLanguage.meshVerticesUpdate,
				playgroundLanguage.meshVerticesUpdateDescription
				));
			
			GUI.enabled = guiEnabled&&serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural").boolValue;
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTarget").FindPropertyRelative("updateNormals"), new GUIContent(
				playgroundLanguage.meshNormalsUpdate,
				playgroundLanguage.meshNormalsUpdateDescription
				));
			GUI.enabled = guiEnabled;
			GUILayout.EndVertical();
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting));
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange);
			thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
		} else
			// Skinned mesh target
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.SkinnedMeshTarget) {
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("skinnedMeshTarget").FindPropertyRelative("gameObject"), new GUIContent(playgroundLanguage.skinnedMeshTarget));
			GUILayout.BeginVertical(boxStyle);
			EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions);
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural"), new GUIContent(
				playgroundLanguage.meshVerticesUpdate,
				playgroundLanguage.meshVerticesUpdateDescription
				));
			GUI.enabled = guiEnabled&&serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural").boolValue;
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("skinnedMeshTarget").FindPropertyRelative("updateNormals"), new GUIContent(
				playgroundLanguage.meshNormalsUpdate,
				playgroundLanguage.meshNormalsUpdateDescription
				));
			GUI.enabled = guiEnabled;
			GUILayout.EndVertical();
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting));
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange);
			thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
		} else
			// State target
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.StateTarget) {
			if (thisManipulatorProperty.stateTarget.stateTransform==null)
				thisManipulatorProperty.stateTarget.stateTransform = thisManipulator.transform.transform;
			
			GUILayout.BeginVertical(boxStyle);
			Texture2D currentStateTexture = thisManipulatorProperty.stateTarget.stateTexture;
			Mesh currentStateMesh = thisManipulatorProperty.stateTarget.stateMesh;
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateTransform"), new GUIContent(playgroundLanguage.transform));
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateMesh"), new GUIContent(playgroundLanguage.mesh));
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateTexture"), new GUIContent(playgroundLanguage.texture));
			if (currentStateTexture!=thisManipulatorProperty.stateTarget.stateTexture || currentStateMesh!=thisManipulatorProperty.stateTarget.stateMesh)
				thisManipulatorProperty.stateTarget.Initialize();
			if (thisManipulatorProperty.stateTarget.stateTexture!=null)
				EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateDepthmap"), new GUIContent(playgroundLanguage.depthmap));
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateScale"), new GUIContent(playgroundLanguage.scale, playgroundLanguage.stateScaleDescription));
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("stateTarget").FindPropertyRelative("stateOffset"), new GUIContent(playgroundLanguage.offset, playgroundLanguage.stateOffsetDescription));
			if (thisManipulatorProperty.stateTarget.stateMesh==null) {
				GUILayout.BeginHorizontal();
				bool currentApplyChromaKey = thisManipulatorProperty.stateTarget.applyChromaKey;
				thisManipulatorProperty.stateTarget.applyChromaKey = EditorGUILayout.Toggle (playgroundLanguage.chromaKey, thisManipulatorProperty.stateTarget.applyChromaKey);
				GUI.enabled = guiEnabled&&thisManipulatorProperty.stateTarget.applyChromaKey;
				EditorGUIUtility.labelWidth = 1f;
				Color currentChroma = new Color(thisManipulatorProperty.stateTarget.chromaKey.r,thisManipulatorProperty.stateTarget.chromaKey.g, thisManipulatorProperty.stateTarget.chromaKey.b);
				thisManipulatorProperty.stateTarget.chromaKey = (Color32)EditorGUILayout.ColorField((Color)thisManipulatorProperty.stateTarget.chromaKey);
				EditorGUIUtility.labelWidth = 50f;
				float currentSpread = thisManipulatorProperty.stateTarget.chromaKeySpread;
				thisManipulatorProperty.stateTarget.chromaKeySpread = EditorGUILayout.Slider(playgroundLanguage.spread, thisManipulatorProperty.stateTarget.chromaKeySpread, 0, 1f);
				if (currentChroma!=new Color(thisManipulatorProperty.stateTarget.chromaKey.r,thisManipulatorProperty.stateTarget.chromaKey.g, thisManipulatorProperty.stateTarget.chromaKey.b) || currentSpread!=thisManipulatorProperty.stateTarget.chromaKeySpread || currentApplyChromaKey!=thisManipulatorProperty.stateTarget.applyChromaKey)
					thisManipulatorProperty.stateTarget.Initialize();
				GUI.enabled = guiEnabled;
				EditorGUIUtility.labelWidth = 0;
				GUILayout.EndHorizontal();
			}
			
			GUILayout.BeginHorizontal();
			if(GUILayout.Button(playgroundLanguage.refresh, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
				thisManipulatorProperty.stateTarget.Initialize();
			}
			EditorGUILayout.Separator();
			EditorGUIUtility.labelWidth = 40f;
			EditorGUILayout.PrefixLabel(playgroundLanguage.points+":");
			EditorGUIUtility.labelWidth = 0;
			EditorGUILayout.SelectableLabel(thisManipulatorProperty.stateTarget.positionLength.ToString(), GUILayout.MaxWidth(80));
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting));
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange);
			thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
		} else
			// Spline target
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.SplineTarget) {
			EditorGUILayout.BeginVertical(boxStyle);
			thisManipulatorProperty.splineTarget = (PlaygroundSpline)EditorGUILayout.ObjectField(playgroundLanguage.spline, thisManipulatorProperty.splineTarget, typeof(PlaygroundSpline), true);
			if (thisManipulatorProperty.splineTarget==null)
				EditorGUILayout.HelpBox(playgroundLanguage.newSplineMessage, MessageType.Info);
			else thisManipulatorProperty.splineTimeOffset = EditorGUILayout.Slider (playgroundLanguage.timeOffset, thisManipulatorProperty.splineTimeOffset, 0, 1f);
			EditorGUILayout.Separator();
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button (playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
				PlaygroundSpline spline = PlaygroundC.CreateSpline(thisManipulatorProperty);
				spline.transform.parent = Selection.activeTransform;
				Selection.activeGameObject = thisManipulatorProperty.splineTarget.gameObject;
			}
			GUI.enabled = thisManipulatorProperty.splineTarget!=null;
			if (GUILayout.Button (playgroundLanguage.edit, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
				Selection.activeGameObject = thisManipulatorProperty.splineTarget.gameObject;
			GUI.enabled = true;
			EditorGUILayout.EndHorizontal();
			EditorGUILayout.EndVertical();
			EditorGUILayout.Separator();
			thisManipulatorProperty.splineTargetMethod = (SPLINETARGETMETHOD)EditorGUILayout.EnumPopup(playgroundLanguage.targetMethod, thisManipulatorProperty.splineTargetMethod);
			thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange);
			thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
		} else 
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Math) {
			thisManipulatorProperty.mathProperty.property = (MATHMANIPULATORPROPERTY)EditorGUILayout.EnumPopup(playgroundLanguage.particleProperty, thisManipulatorProperty.mathProperty.property);
			thisManipulatorProperty.mathProperty.type = (MATHMANIPULATORTYPE)EditorGUILayout.EnumPopup(playgroundLanguage.type, thisManipulatorProperty.mathProperty.type);
			thisManipulatorProperty.mathProperty.clamp = (MATHMANIPULATORCLAMP)EditorGUILayout.EnumPopup(playgroundLanguage.clamp, thisManipulatorProperty.mathProperty.clamp);
			if (thisManipulatorProperty.mathProperty.clamp!=MATHMANIPULATORCLAMP.None) {
				EditorGUI.indentLevel++;
				thisManipulatorProperty.mathProperty.clampFloor = EditorGUILayout.FloatField(playgroundLanguage.floor, thisManipulatorProperty.mathProperty.clampFloor);
				thisManipulatorProperty.mathProperty.clampCeil = EditorGUILayout.FloatField(playgroundLanguage.ceil, thisManipulatorProperty.mathProperty.clampCeil);
				EditorGUI.indentLevel--;
			}
			if (thisManipulatorProperty.mathProperty.property == MATHMANIPULATORPROPERTY.Rotation || thisManipulatorProperty.mathProperty.property == MATHMANIPULATORPROPERTY.Size) {
				thisManipulatorProperty.mathProperty.value = EditorGUILayout.FloatField(playgroundLanguage.value, thisManipulatorProperty.mathProperty.value);
				thisManipulatorProperty.mathProperty.rate = EditorGUILayout.FloatField(playgroundLanguage.rate, thisManipulatorProperty.mathProperty.rate);
			} else {
				thisManipulatorProperty.mathProperty.value3 = EditorGUILayout.Vector3Field(playgroundLanguage.value, thisManipulatorProperty.mathProperty.value3);
				thisManipulatorProperty.mathProperty.rate3 = EditorGUILayout.Vector3Field(playgroundLanguage.rate, thisManipulatorProperty.mathProperty.rate3);
			}
		}
		
		EditorGUILayout.Separator();
		if (thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.None &&
		    thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Attractor &&
		    thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Gravitational &&
		    thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Repellent &&
		    thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Vortex &&
		    thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Turbulence &&
		    thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Math
		    ) {
			GUI.enabled = guiEnabled&&thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.AdditiveVelocity;
			thisManipulatorProperty.transition = (MANIPULATORPROPERTYTRANSITIONC)EditorGUILayout.EnumPopup(playgroundLanguage.transition, thisManipulatorProperty.transition);
			GUI.enabled = guiEnabled;
		}
	}
Exemplo n.º 32
0
	public static void RenderManipulatorSettings (ManipulatorObjectC thisManipulator, SerializedProperty serializedManipulator, bool isPlayground) {
		SerializedProperty serializedManipulatorAffects = serializedManipulator.FindPropertyRelative("affects");
		SerializedProperty serializedManipulatorSize;
		SerializedProperty serializedManipulatorStrength;
		SerializedProperty serializedManipulatorStrengthSmoothing;
		SerializedProperty serializedManipulatorStrengthDistance;
		
		thisManipulator.enabled = EditorGUILayout.ToggleLeft(playgroundLanguage.enabled, thisManipulator.enabled);
		GUI.enabled = thisManipulator.enabled;
		
		EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("transform").FindPropertyRelative("transform"), new GUIContent(playgroundLanguage.transform));
		if (thisManipulator.transform.available && thisManipulator.transform.transform!=null) {
			EditorGUI.indentLevel++;
			thisManipulator.transform.transform.position = EditorGUILayout.Vector3Field(playgroundLanguage.position, thisManipulator.transform.transform.position);
			thisManipulator.transform.transform.rotation = Quaternion.Euler(EditorGUILayout.Vector3Field(playgroundLanguage.rotation, thisManipulator.transform.transform.rotation.eulerAngles));
			thisManipulator.transform.transform.localScale = EditorGUILayout.Vector3Field(playgroundLanguage.scale, thisManipulator.transform.transform.localScale);
			EditorGUI.indentLevel--;
		}
		EditorGUILayout.Separator();
		EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("type"), new GUIContent(playgroundLanguage.type));
		
		// Render properties
		if (thisManipulator.type==MANIPULATORTYPEC.Property)
			RenderManipulatorProperty(thisManipulator, thisManipulator.property, serializedManipulator.FindPropertyRelative("property"));
		if (thisManipulator.type==MANIPULATORTYPEC.Combined) {
			if (thisManipulator.properties.Count>0) {
				SerializedProperty serializedManipulatorProperties = serializedManipulator.FindPropertyRelative("properties");
				int prevPropertyCount = thisManipulator.properties.Count;
				for (int i = 0; i<thisManipulator.properties.Count; i++) {
					if (thisManipulator.properties.Count!=prevPropertyCount) return;
					EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
					EditorGUILayout.BeginHorizontal();
					GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
					thisManipulator.properties[i].unfolded = GUILayout.Toggle(thisManipulator.properties[i].unfolded, thisManipulator.properties[i].type.ToString(), EditorStyles.foldout);
					
					EditorGUILayout.Separator();
					GUI.enabled = (thisManipulator.enabled&&thisManipulator.properties.Count>1);
					if(GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
						serializedManipulatorProperties.MoveArrayElement(i, i==0?thisManipulator.properties.Count-1:i-1);
					}
					if(GUILayout.Button(playgroundLanguage.downSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
						serializedManipulatorProperties.MoveArrayElement(i, i<thisManipulator.properties.Count-1?i+1:0);
					}
					GUI.enabled = thisManipulator.enabled;
					if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
						thisManipulator.properties.RemoveAt(i);
						return;
					}
					EditorGUILayout.EndHorizontal();
					
					if (thisManipulator.properties[i].unfolded)
						RenderManipulatorProperty(thisManipulator, thisManipulator.properties[i], serializedManipulatorProperties.GetArrayElementAtIndex(i));
					EditorGUILayout.EndVertical();
				}
			} else {
				EditorGUILayout.HelpBox(playgroundLanguage.noProperties, MessageType.Info);
			}
			if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
				thisManipulator.properties.Add(new ManipulatorPropertyC());
			}
		}
		
		EditorGUILayout.Separator();
		EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("shape"), new GUIContent(playgroundLanguage.shape));
		
		if (thisManipulator.shape==MANIPULATORSHAPEC.Sphere) {
			serializedManipulatorSize = serializedManipulator.FindPropertyRelative("size");
			serializedManipulatorSize.floatValue = EditorGUILayout.Slider(playgroundLanguage.size, serializedManipulatorSize.floatValue, 0, playgroundSettings.maximumAllowedManipulatorSize);
		} else {
			EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("bounds"), new GUIContent(playgroundLanguage.bounds));
		}
		
		EditorGUILayout.Separator();
		serializedManipulatorStrength = serializedManipulator.FindPropertyRelative("strength");
		serializedManipulatorStrength.floatValue = EditorGUILayout.Slider(playgroundLanguage.manipulatorStrength, serializedManipulatorStrength.floatValue, 0, playgroundSettings.maximumAllowedManipulatorStrength);
		EditorGUI.indentLevel++;
		serializedManipulatorStrengthSmoothing = serializedManipulator.FindPropertyRelative("strengthSmoothing");
		serializedManipulatorStrengthSmoothing.floatValue = EditorGUILayout.Slider(playgroundLanguage.smoothingEffect, serializedManipulatorStrengthSmoothing.floatValue, 0, playgroundSettings.maximumAllowedManipulatorStrengthEffectors);
		serializedManipulatorStrengthDistance = serializedManipulator.FindPropertyRelative("strengthDistanceEffect");
		serializedManipulatorStrengthDistance.floatValue = EditorGUILayout.Slider(playgroundLanguage.distanceEffect, serializedManipulatorStrengthDistance.floatValue, 0, playgroundSettings.maximumAllowedManipulatorStrengthEffectors);
		EditorGUI.indentLevel--;
		EditorGUILayout.Separator();
		
		GUILayout.BeginHorizontal();
		thisManipulator.applyLifetimeFilter = EditorGUILayout.ToggleLeft (playgroundLanguage.lifetimeFilter, thisManipulator.applyLifetimeFilter, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
		float minFilter = thisManipulator.lifetimeFilterMinimum;
		float maxFilter = thisManipulator.lifetimeFilterMaximum;
		EditorGUILayout.MinMaxSlider (ref minFilter, ref maxFilter, 0f, 1f);
		thisManipulator.lifetimeFilterMinimum = EditorGUILayout.FloatField(Mathf.Clamp01(minFilter), GUILayout.Width(50));
		thisManipulator.lifetimeFilterMaximum = EditorGUILayout.FloatField(Mathf.Clamp01(maxFilter), GUILayout.Width(50));
		GUILayout.EndHorizontal();
		
		GUILayout.BeginHorizontal();
		thisManipulator.applyParticleFilter = EditorGUILayout.ToggleLeft (playgroundLanguage.particleFilter, thisManipulator.applyParticleFilter, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
		minFilter = thisManipulator.particleFilterMinimum;
		maxFilter = thisManipulator.particleFilterMaximum;
		EditorGUILayout.MinMaxSlider (ref minFilter, ref maxFilter, 0f, 1f);
		thisManipulator.particleFilterMinimum = EditorGUILayout.FloatField(Mathf.Clamp01(minFilter), GUILayout.Width(50));
		thisManipulator.particleFilterMaximum = EditorGUILayout.FloatField(Mathf.Clamp01(maxFilter), GUILayout.Width(50));
		GUILayout.EndHorizontal();
		
		EditorGUILayout.Separator();
		
		thisManipulator.inverseBounds = EditorGUILayout.Toggle(playgroundLanguage.inverseBounds, thisManipulator.inverseBounds);
		
		EditorGUILayout.Separator();
		
		// Axis constraints
		GUILayout.BeginHorizontal();
		EditorGUILayout.LabelField(playgroundLanguage.axisConstraints, GUILayout.Width(Mathf.FloorToInt(Screen.width/2.2f)-46));
		
		GUILayout.Label("X", GUILayout.Width(10));
		thisManipulator.axisConstraints.x = EditorGUILayout.Toggle(thisManipulator.axisConstraints.x, GUILayout.Width(16));
		GUILayout.Label("Y", GUILayout.Width(10));
		thisManipulator.axisConstraints.y = EditorGUILayout.Toggle(thisManipulator.axisConstraints.y, GUILayout.Width(16));
		GUILayout.Label("Z", GUILayout.Width(10));
		thisManipulator.axisConstraints.z = EditorGUILayout.Toggle(thisManipulator.axisConstraints.z, GUILayout.Width(16));
		GUILayout.EndHorizontal();
		
		if (isPlayground) {
			EditorGUILayout.Separator();
			EditorGUILayout.PropertyField(serializedManipulatorAffects, new GUIContent(playgroundLanguage.affects));
		}
		
		EditorGUILayout.Separator();
		
		GUILayout.BeginVertical(boxStyle);
		GUILayout.BeginHorizontal();
		thisManipulator.sendEventsUnfolded = GUILayout.Toggle(thisManipulator.sendEventsUnfolded, playgroundLanguage.events, EditorStyles.foldout, GUILayout.ExpandWidth(false));
		if (thisManipulator.trackParticles) {
			thisManipulator.sendEventsUnfolded =  GUILayout.Toggle(thisManipulator.sendEventsUnfolded, thisManipulator.particles.Count+" "+playgroundLanguage.particles, EditorStyles.label, GUILayout.ExpandWidth(true));
		} else {
			thisManipulator.sendEventsUnfolded =  GUILayout.Toggle(thisManipulator.sendEventsUnfolded, "("+playgroundLanguage.off+")", EditorStyles.label, GUILayout.ExpandWidth(true));
		}
		GUILayout.EndHorizontal();
		if (thisManipulator.sendEventsUnfolded) {
			thisManipulator.trackParticles = EditorGUILayout.Toggle (playgroundLanguage.trackParticles, thisManipulator.trackParticles);
			EditorGUI.indentLevel++;
			GUI.enabled = thisManipulator.trackParticles;
			thisManipulator.trackingMethod = (TrackingMethod)EditorGUILayout.EnumPopup(playgroundLanguage.trackingMethod, thisManipulator.trackingMethod);
			thisManipulator.sendEventEnter = EditorGUILayout.Toggle (playgroundLanguage.sendEnterEvents, thisManipulator.sendEventEnter);
			thisManipulator.sendEventExit = EditorGUILayout.Toggle (playgroundLanguage.sendExitEvents, thisManipulator.sendEventExit);
			thisManipulator.sendEventBirth = EditorGUILayout.Toggle (playgroundLanguage.sendBirthEvents, thisManipulator.sendEventBirth);
			thisManipulator.sendEventDeath = EditorGUILayout.Toggle (playgroundLanguage.sendDeathEvents, thisManipulator.sendEventDeath);
			thisManipulator.sendEventCollision = EditorGUILayout.Toggle (playgroundLanguage.sendCollisionEvents, thisManipulator.sendEventCollision);
			GUI.enabled = true;
			EditorGUI.indentLevel--;
		}
		GUILayout.EndVertical();
		
	}
    public static void RenderManipulatorProperty(ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, SerializedProperty serializedManipulatorProperty)
    {
        if (thisManipulatorProperty == null) thisManipulatorProperty = new ManipulatorPropertyC();

        thisManipulatorProperty.type = (MANIPULATORPROPERTYTYPEC)EditorGUILayout.EnumPopup(playgroundLanguage.propertyType, thisManipulatorProperty.type);
        bool guiEnabled = GUI.enabled;

        EditorGUILayout.Separator();

        // Velocity
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Velocity || thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.AdditiveVelocity) {
            thisManipulatorProperty.velocity = EditorGUILayout.Vector3Field(playgroundLanguage.particleVelocity, thisManipulatorProperty.velocity);
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.velocityStrength, thisManipulatorProperty.strength);
            thisManipulatorProperty.useLocalRotation = EditorGUILayout.Toggle(playgroundLanguage.localRotation, thisManipulatorProperty.useLocalRotation);
        } else
        // Color
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Color) {
            thisManipulatorProperty.color = EditorGUILayout.ColorField(playgroundLanguage.particleColor, thisManipulatorProperty.color);
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.colorStrength, thisManipulatorProperty.strength);
            thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyColorInRange, thisManipulatorProperty.onlyColorInRange);
            thisManipulatorProperty.keepColorAlphas = EditorGUILayout.Toggle(playgroundLanguage.keepColorAlphas, thisManipulatorProperty.keepColorAlphas);
        } else
        // Size
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Size) {
            thisManipulatorProperty.size = EditorGUILayout.FloatField(playgroundLanguage.particleSize, thisManipulatorProperty.size);
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.sizeStrength, thisManipulatorProperty.strength);
            thisManipulatorProperty.onlySizeInRange = EditorGUILayout.Toggle(playgroundLanguage.onlySizeInRange, thisManipulatorProperty.onlySizeInRange);
        } else
        // Target
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Target) {

            // Target List
            bool hasNull = false;
            EditorGUILayout.BeginVertical(boxStyle);
            playgroundSettings.manipulatorTargetsFoldout = GUILayout.Toggle(playgroundSettings.manipulatorTargetsFoldout, playgroundLanguage.targets+" ("+thisManipulatorProperty.targets.Count+")", EditorStyles.foldout);
            if (playgroundSettings.manipulatorTargetsFoldout) {
                if (thisManipulatorProperty.targets.Count>0) {
                    for (int t = 0; t<thisManipulatorProperty.targets.Count; t++) {
                        EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
                        EditorGUILayout.BeginHorizontal();

                        GUILayout.Label(t.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
                        thisManipulatorProperty.targets[t].transform = EditorGUILayout.ObjectField("", thisManipulatorProperty.targets[t].transform, typeof(Transform), true) as Transform;
                        if (!thisManipulatorProperty.targets[t].available) hasNull = true;

                        EditorGUILayout.Separator();
                        if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
                            thisManipulatorProperty.targets.RemoveAt(t);
                        }

                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.EndVertical();
                    }
                } else {
                    EditorGUILayout.HelpBox(playgroundLanguage.noTargets, MessageType.Info);
                }

                if (hasNull)
                    EditorGUILayout.HelpBox(playgroundLanguage.allTargets, MessageType.Warning);

                if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
                    PlaygroundTransformC newPlaygroundTransform = new PlaygroundTransformC();
                    newPlaygroundTransform.transform = thisManipulator.transform.transform;
                    newPlaygroundTransform.Update ();
                    thisManipulatorProperty.targets.Add(newPlaygroundTransform);
                }
                EditorGUILayout.Separator();
            }
            EditorGUILayout.EndVertical();

            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength);
            thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange);
            thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
        } else
        // Death
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Death) {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.deathStrength, thisManipulatorProperty.strength);
        } else
        // Attractor
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Attractor) {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.attractorStrength, thisManipulatorProperty.strength);
        } else
        // Gravitational
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Gravitational) {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.gravitationalStrength, thisManipulatorProperty.strength);
        } else
        // Repellent
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Repellent) {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.repellentStrength, thisManipulatorProperty.strength);
        } else
        // Vortex
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Vortex) {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.vortexStrength, thisManipulatorProperty.strength);
        } else
        // Turbulence
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Turbulence) {
            thisManipulatorProperty.turbulenceType = (TURBULENCETYPE)EditorGUILayout.EnumPopup (playgroundLanguage.turbulenceType, thisManipulatorProperty.turbulenceType);
            EditorGUI.indentLevel++;
            thisManipulatorProperty.strength = EditorGUILayout.Slider(playgroundLanguage.strength, thisManipulatorProperty.strength, 0f, playgroundSettings.maximumAllowedTurbulenceStrength);
            thisManipulatorProperty.turbulenceScale = EditorGUILayout.Slider(playgroundLanguage.scale, thisManipulatorProperty.turbulenceScale, 0f, playgroundSettings.maximumAllowedTurbulenceScale);
            thisManipulatorProperty.turbulenceTimeScale = EditorGUILayout.Slider(playgroundLanguage.timeScale, thisManipulatorProperty.turbulenceTimeScale, 0f, playgroundSettings.maximumAllowedTurbulenceTimeScale);
            EditorGUILayout.BeginHorizontal();
            thisManipulatorProperty.turbulenceApplyLifetimeStrength = EditorGUILayout.ToggleLeft (playgroundLanguage.lifetimeStrength, thisManipulatorProperty.turbulenceApplyLifetimeStrength, GUILayout.Width (140));
            GUILayout.FlexibleSpace();
            GUI.enabled = (thisManipulatorProperty.turbulenceApplyLifetimeStrength && thisManipulatorProperty.turbulenceType!=TURBULENCETYPE.None);
            serializedManipulatorProperty.FindPropertyRelative("turbulenceLifetimeStrength").animationCurveValue = EditorGUILayout.CurveField(serializedManipulatorProperty.FindPropertyRelative("turbulenceLifetimeStrength").animationCurveValue);
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel--;
        } else
        // Lifetime Color
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.LifetimeColor) {
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("lifetimeColor"), new GUIContent(playgroundLanguage.lifetimeColor));
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.colorStrength, thisManipulatorProperty.strength);
            thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyColorInRange, thisManipulatorProperty.onlyColorInRange);
        } else
        // Mesh target
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.MeshTarget) {
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTarget").FindPropertyRelative("gameObject"), new GUIContent(playgroundLanguage.meshTarget));
            GUILayout.BeginVertical(boxStyle);
            EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions);
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural"), new GUIContent(
                playgroundLanguage.meshVerticesUpdate,
                playgroundLanguage.meshVerticesUpdateDescription
                ));

            GUI.enabled = guiEnabled&&serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural").boolValue;
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTarget").FindPropertyRelative("updateNormals"), new GUIContent(
                playgroundLanguage.meshNormalsUpdate,
                playgroundLanguage.meshNormalsUpdateDescription
                ));
            GUI.enabled = guiEnabled;
            GUILayout.EndVertical();
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting));
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength);
            thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange);
            thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
        } else
        // Skinned mesh target
        if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.SkinnedMeshTarget) {
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("skinnedMeshTarget").FindPropertyRelative("gameObject"), new GUIContent(playgroundLanguage.skinnedMeshTarget));
            GUILayout.BeginVertical(boxStyle);
            EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions);
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural"), new GUIContent(
                playgroundLanguage.meshVerticesUpdate,
                playgroundLanguage.meshVerticesUpdateDescription
                ));
            GUI.enabled = guiEnabled&&serializedManipulatorProperty.FindPropertyRelative("meshTargetIsProcedural").boolValue;
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("skinnedMeshTarget").FindPropertyRelative("updateNormals"), new GUIContent(
                playgroundLanguage.meshNormalsUpdate,
                playgroundLanguage.meshNormalsUpdateDescription
                ));
            GUI.enabled = guiEnabled;
            GUILayout.EndVertical();
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("targetSorting"), new GUIContent(playgroundLanguage.targetSorting));
            thisManipulatorProperty.strength = EditorGUILayout.FloatField(playgroundLanguage.targetStrength, thisManipulatorProperty.strength);
            thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle(playgroundLanguage.onlyPositionInRange, thisManipulatorProperty.onlyPositionInRange);
            thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider(playgroundLanguage.manipulatorZeroVelocityStrength, thisManipulatorProperty.zeroVelocityStrength, 0, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
        }

        EditorGUILayout.Separator();
        if (thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.None &&
            thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Attractor &&
            thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Gravitational &&
            thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Repellent &&
            thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Vortex &&
            thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Turbulence
        )
            thisManipulatorProperty.transition = (MANIPULATORPROPERTYTRANSITIONC)EditorGUILayout.EnumPopup(playgroundLanguage.transition, thisManipulatorProperty.transition);
    }
	// Use this for initialization
	void Start () {
		manipulator = PlaygroundC.GetManipulator (0, GetComponent<PlaygroundParticlesC>());
	}
	public static void RenderManipulatorSettings (ManipulatorObjectC thisManipulator, SerializedProperty serializedManipulator, bool isPlayground) {
		SerializedProperty serializedManipulatorAffects = serializedManipulator.FindPropertyRelative("affects");
		SerializedProperty serializedManipulatorSize;
		SerializedProperty serializedManipulatorStrength;
		
		thisManipulator.enabled = EditorGUILayout.ToggleLeft("Enabled", thisManipulator.enabled);
		GUI.enabled = thisManipulator.enabled;
		
		EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("transform"), new GUIContent("Transform"));
		if (thisManipulator.transform) {
			EditorGUI.indentLevel++;
			thisManipulator.transform.position = EditorGUILayout.Vector3Field("Position", thisManipulator.transform.position);
			thisManipulator.transform.rotation = Quaternion.Euler(EditorGUILayout.Vector3Field("Rotation", thisManipulator.transform.rotation.eulerAngles));
			thisManipulator.transform.localScale = EditorGUILayout.Vector3Field("Scale", thisManipulator.transform.localScale);
			EditorGUI.indentLevel--;
		}
		EditorGUILayout.Separator();
		EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("type"), new GUIContent("Type"));
		
		// Render properties
		if (thisManipulator.type==MANIPULATORTYPEC.Property)
			RenderManipulatorProperty(thisManipulator, thisManipulator.property, serializedManipulator.FindPropertyRelative("property"));
		if (thisManipulator.type==MANIPULATORTYPEC.Combined) {
			if (thisManipulator.properties.Count>0) {
				SerializedProperty serializedManipulatorProperties = serializedManipulator.FindPropertyRelative("properties");
				int prevPropertyCount = thisManipulator.properties.Count;
				for (int i = 0; i<thisManipulator.properties.Count; i++) {
					if (thisManipulator.properties.Count!=prevPropertyCount) return;
					EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
					EditorGUILayout.BeginHorizontal();
					GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
					thisManipulator.properties[i].unfolded = GUILayout.Toggle(thisManipulator.properties[i].unfolded, thisManipulator.properties[i].type.ToString(), EditorStyles.foldout);
					
					EditorGUILayout.Separator();
					GUI.enabled = (thisManipulator.enabled&&thisManipulator.properties.Count>1);
					if(GUILayout.Button("U", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
						serializedManipulatorProperties.MoveArrayElement(i, i==0?thisManipulator.properties.Count-1:i-1);
					}
					if(GUILayout.Button("D", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
						serializedManipulatorProperties.MoveArrayElement(i, i<thisManipulator.properties.Count-1?i+1:0);
					}
					GUI.enabled = thisManipulator.enabled;
					if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
						thisManipulator.properties.RemoveAt(i);
						return;
					}
					EditorGUILayout.EndHorizontal();
					
					if (thisManipulator.properties[i].unfolded)
						RenderManipulatorProperty(thisManipulator, thisManipulator.properties[i], serializedManipulatorProperties.GetArrayElementAtIndex(i));
					EditorGUILayout.EndVertical();
				}
			} else {
				EditorGUILayout.HelpBox("No properties created.", MessageType.Info);
			}
			if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
				thisManipulator.properties.Add(new ManipulatorPropertyC());
			}
		}
				
		EditorGUILayout.Separator();
		EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("shape"), new GUIContent("Shape"));
		
		if (thisManipulator.shape==MANIPULATORSHAPEC.Sphere) {
			serializedManipulatorSize = serializedManipulator.FindPropertyRelative("size");
			serializedManipulatorSize.floatValue = EditorGUILayout.Slider("Size", serializedManipulatorSize.floatValue, 0, playgroundScriptReference.maximumAllowedManipulatorSize);
		} else {
			EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("bounds"), new GUIContent("Bounds"));
		}
		
		EditorGUILayout.Separator();
		serializedManipulatorStrength = serializedManipulator.FindPropertyRelative("strength");
		serializedManipulatorStrength.floatValue = EditorGUILayout.Slider("Manipulator Strength", serializedManipulatorStrength.floatValue, 0, playgroundScriptReference.maximumAllowedManipulatorStrength);
		EditorGUILayout.Separator();
		
		thisManipulator.inverseBounds = EditorGUILayout.Toggle("Inverse Bounds", thisManipulator.inverseBounds);
		
		if (isPlayground) {
			EditorGUILayout.Separator();
			EditorGUILayout.PropertyField(serializedManipulatorAffects, new GUIContent("Affects"));
		}
		
	}
	void Start () {
		globalManipulator = PlaygroundC.GetManipulator(0);
	}
    public static void RenderManipulatorProperty(ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, SerializedProperty serializedManipulatorProperty)
    {
        if (thisManipulatorProperty == null)
        {
            thisManipulatorProperty = new ManipulatorPropertyC();
        }

        EditorGUILayout.Separator();

        thisManipulatorProperty.type = (MANIPULATORPROPERTYTYPEC)EditorGUILayout.EnumPopup("Property Type", thisManipulatorProperty.type);

        // Velocity
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Velocity || thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.AdditiveVelocity)
        {
            thisManipulatorProperty.velocity         = EditorGUILayout.Vector3Field("Particle Velocity", thisManipulatorProperty.velocity);
            thisManipulatorProperty.strength         = EditorGUILayout.FloatField("Velocity Strength", thisManipulatorProperty.strength);
            thisManipulatorProperty.useLocalRotation = EditorGUILayout.Toggle("Local Rotation", thisManipulatorProperty.useLocalRotation);
        }
        else
        // Color
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Color)
        {
            thisManipulatorProperty.color            = EditorGUILayout.ColorField("Particle Color", thisManipulatorProperty.color);
            thisManipulatorProperty.strength         = EditorGUILayout.FloatField("Color Strength", thisManipulatorProperty.strength);
            thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle("Only Color In Range", thisManipulatorProperty.onlyColorInRange);
            thisManipulatorProperty.keepColorAlphas  = EditorGUILayout.Toggle("Keep Color Alphas", thisManipulatorProperty.keepColorAlphas);
        }
        else
        // Size
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Size)
        {
            thisManipulatorProperty.size     = EditorGUILayout.FloatField("Particle Size", thisManipulatorProperty.size);
            thisManipulatorProperty.strength = EditorGUILayout.FloatField("Size Strength", thisManipulatorProperty.strength);
        }
        else
        // Target
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Target)
        {
            // Target List
            bool hasNull = false;
            EditorGUILayout.BeginVertical(boxStyle);
            targetsFoldout = GUILayout.Toggle(targetsFoldout, "Targets (" + thisManipulatorProperty.targets.Count + ")", EditorStyles.foldout);
            if (targetsFoldout)
            {
                if (thisManipulatorProperty.targets.Count > 0)
                {
                    for (int t = 0; t < thisManipulatorProperty.targets.Count; t++)
                    {
                        EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
                        EditorGUILayout.BeginHorizontal();

                        GUILayout.Label(t.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
                        thisManipulatorProperty.targets[t] = EditorGUILayout.ObjectField("", thisManipulatorProperty.targets[t], typeof(Transform), true) as Transform;
                        if (!thisManipulatorProperty.targets[t])
                        {
                            hasNull = true;
                        }

                        EditorGUILayout.Separator();
                        if (GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) }))
                        {
                            thisManipulatorProperty.targets.RemoveAt(t);
                        }

                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.EndVertical();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No targets created.", MessageType.Info);
                }

                if (hasNull)
                {
                    EditorGUILayout.HelpBox("All targets must be assigned.", MessageType.Warning);
                }

                if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50)))
                {
                    thisManipulatorProperty.targets.Add(thisManipulator.transform);
                }
                EditorGUILayout.Separator();
            }
            EditorGUILayout.EndVertical();

            thisManipulatorProperty.strength             = EditorGUILayout.FloatField("Target Strength", thisManipulatorProperty.strength);
            thisManipulatorProperty.onlyPositionInRange  = EditorGUILayout.Toggle("Only Position In Range", thisManipulatorProperty.onlyPositionInRange);
            thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider("Zero Velocity Strength", thisManipulatorProperty.zeroVelocityStrength, 0, playgroundScriptReference.maximumAllowedManipulatorZeroVelocity);
        }
        else
        // Death
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Death)
        {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField("Death Strength", thisManipulatorProperty.strength);
        }
        else
        // Attractor
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Attractor)
        {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField("Attractor Strength", thisManipulatorProperty.strength);
        }
        else
        // Gravitational
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Gravitational)
        {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField("Gravitational Strength", thisManipulatorProperty.strength);
        }
        else
        // Repellent
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Repellent)
        {
            thisManipulatorProperty.strength = EditorGUILayout.FloatField("Repellent Strength", thisManipulatorProperty.strength);
        }
        else
        // Lifetime Color
        if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.LifetimeColor)
        {
            EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("lifetimeColor"), new GUIContent("Lifetime Color"));
            thisManipulatorProperty.strength         = EditorGUILayout.FloatField("Color Strength", thisManipulatorProperty.strength);
            thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle("Only Color In Range", thisManipulatorProperty.onlyColorInRange);
        }

        EditorGUILayout.Separator();
        if (thisManipulatorProperty.type != MANIPULATORPROPERTYTYPEC.None &&
            thisManipulatorProperty.type != MANIPULATORPROPERTYTYPEC.Attractor &&
            thisManipulatorProperty.type != MANIPULATORPROPERTYTYPEC.Gravitational &&
            thisManipulatorProperty.type != MANIPULATORPROPERTYTYPEC.Repellent
            )
        {
            thisManipulatorProperty.transition = (MANIPULATORPROPERTYTRANSITIONC)EditorGUILayout.EnumPopup("Transition", thisManipulatorProperty.transition);
        }
    }
    public static void RenderManipulatorSettings(ManipulatorObjectC thisManipulator, SerializedProperty serializedManipulator, bool isPlayground)
    {
        SerializedProperty serializedManipulatorAffects = serializedManipulator.FindPropertyRelative("affects");
        SerializedProperty serializedManipulatorSize;
        SerializedProperty serializedManipulatorStrength;

        thisManipulator.enabled = EditorGUILayout.ToggleLeft("Enabled", thisManipulator.enabled);
        GUI.enabled             = thisManipulator.enabled;

        EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("transform"), new GUIContent("Transform"));
        if (thisManipulator.transform)
        {
            EditorGUI.indentLevel++;
            thisManipulator.transform.position   = EditorGUILayout.Vector3Field("Position", thisManipulator.transform.position);
            thisManipulator.transform.rotation   = Quaternion.Euler(EditorGUILayout.Vector3Field("Rotation", thisManipulator.transform.rotation.eulerAngles));
            thisManipulator.transform.localScale = EditorGUILayout.Vector3Field("Scale", thisManipulator.transform.localScale);
            EditorGUI.indentLevel--;
        }
        EditorGUILayout.Separator();
        EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("type"), new GUIContent("Type"));

        // Render properties
        if (thisManipulator.type == MANIPULATORTYPEC.Property)
        {
            RenderManipulatorProperty(thisManipulator, thisManipulator.property, serializedManipulator.FindPropertyRelative("property"));
        }
        if (thisManipulator.type == MANIPULATORTYPEC.Combined)
        {
            if (thisManipulator.properties.Count > 0)
            {
                SerializedProperty serializedManipulatorProperties = serializedManipulator.FindPropertyRelative("properties");
                int prevPropertyCount = thisManipulator.properties.Count;
                for (int i = 0; i < thisManipulator.properties.Count; i++)
                {
                    if (thisManipulator.properties.Count != prevPropertyCount)
                    {
                        return;
                    }
                    EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
                    thisManipulator.properties[i].unfolded = GUILayout.Toggle(thisManipulator.properties[i].unfolded, thisManipulator.properties[i].type.ToString(), EditorStyles.foldout);

                    EditorGUILayout.Separator();
                    GUI.enabled = (thisManipulator.enabled && thisManipulator.properties.Count > 1);
                    if (GUILayout.Button("U", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) }))
                    {
                        serializedManipulatorProperties.MoveArrayElement(i, i == 0?thisManipulator.properties.Count - 1:i - 1);
                    }
                    if (GUILayout.Button("D", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) }))
                    {
                        serializedManipulatorProperties.MoveArrayElement(i, i < thisManipulator.properties.Count - 1?i + 1:0);
                    }
                    GUI.enabled = thisManipulator.enabled;
                    if (GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) }))
                    {
                        thisManipulator.properties.RemoveAt(i);
                        return;
                    }
                    EditorGUILayout.EndHorizontal();

                    if (thisManipulator.properties[i].unfolded)
                    {
                        RenderManipulatorProperty(thisManipulator, thisManipulator.properties[i], serializedManipulatorProperties.GetArrayElementAtIndex(i));
                    }
                    EditorGUILayout.EndVertical();
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No properties created.", MessageType.Info);
            }
            if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50)))
            {
                thisManipulator.properties.Add(new ManipulatorPropertyC());
            }
        }

        EditorGUILayout.Separator();
        EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("shape"), new GUIContent("Shape"));

        if (thisManipulator.shape == MANIPULATORSHAPEC.Sphere)
        {
            serializedManipulatorSize            = serializedManipulator.FindPropertyRelative("size");
            serializedManipulatorSize.floatValue = EditorGUILayout.Slider("Size", serializedManipulatorSize.floatValue, 0, playgroundScriptReference.maximumAllowedManipulatorSize);
        }
        else
        {
            EditorGUILayout.PropertyField(serializedManipulator.FindPropertyRelative("bounds"), new GUIContent("Bounds"));
        }

        EditorGUILayout.Separator();
        serializedManipulatorStrength            = serializedManipulator.FindPropertyRelative("strength");
        serializedManipulatorStrength.floatValue = EditorGUILayout.Slider("Manipulator Strength", serializedManipulatorStrength.floatValue, 0, playgroundScriptReference.maximumAllowedManipulatorStrength);
        EditorGUILayout.Separator();

        thisManipulator.inverseBounds = EditorGUILayout.Toggle("Inverse Bounds", thisManipulator.inverseBounds);

        if (isPlayground)
        {
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(serializedManipulatorAffects, new GUIContent("Affects"));
        }
    }
    // Draws a Manipulator bounding box with handles in scene view
    public static void DrawManipulatorBox(ManipulatorObjectC manipulator)
    {
        Vector3 boxFrontTopLeft;
        Vector3 boxFrontTopRight;
        Vector3 boxFrontBottomLeft;
        Vector3 boxFrontBottomRight;
        Vector3 boxBackTopLeft;
        Vector3 boxBackTopRight;
        Vector3 boxBackBottomLeft;
        Vector3 boxBackBottomRight;
        Vector3 boxFrontDot;
        Vector3 boxLeftDot;
        Vector3 boxUpDot;

        // Always set positive values of bounds
        manipulator.bounds.extents = new Vector3(Mathf.Abs(manipulator.bounds.extents.x), Mathf.Abs(manipulator.bounds.extents.y), Mathf.Abs(manipulator.bounds.extents.z));

        // Set positions from bounds
        boxFrontTopLeft     = new Vector3(manipulator.bounds.center.x - manipulator.bounds.extents.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z - manipulator.bounds.extents.z);
        boxFrontTopRight    = new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z - manipulator.bounds.extents.z);
        boxFrontBottomLeft  = new Vector3(manipulator.bounds.center.x - manipulator.bounds.extents.x, manipulator.bounds.center.y - manipulator.bounds.extents.y, manipulator.bounds.center.z - manipulator.bounds.extents.z);
        boxFrontBottomRight = new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y - manipulator.bounds.extents.y, manipulator.bounds.center.z - manipulator.bounds.extents.z);
        boxBackTopLeft      = new Vector3(manipulator.bounds.center.x - manipulator.bounds.extents.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);
        boxBackTopRight     = new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);
        boxBackBottomLeft   = new Vector3(manipulator.bounds.center.x - manipulator.bounds.extents.x, manipulator.bounds.center.y - manipulator.bounds.extents.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);
        boxBackBottomRight  = new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y - manipulator.bounds.extents.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);

        boxFrontDot = new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y, manipulator.bounds.center.z);
        boxUpDot    = new Vector3(manipulator.bounds.center.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z);
        boxLeftDot  = new Vector3(manipulator.bounds.center.x, manipulator.bounds.center.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);

        // Apply transform positioning
        boxFrontTopLeft     = manipulator.transform.TransformPoint(boxFrontTopLeft);
        boxFrontTopRight    = manipulator.transform.TransformPoint(boxFrontTopRight);
        boxFrontBottomLeft  = manipulator.transform.TransformPoint(boxFrontBottomLeft);
        boxFrontBottomRight = manipulator.transform.TransformPoint(boxFrontBottomRight);
        boxBackTopLeft      = manipulator.transform.TransformPoint(boxBackTopLeft);
        boxBackTopRight     = manipulator.transform.TransformPoint(boxBackTopRight);
        boxBackBottomLeft   = manipulator.transform.TransformPoint(boxBackBottomLeft);
        boxBackBottomRight  = manipulator.transform.TransformPoint(boxBackBottomRight);

        boxFrontDot = manipulator.transform.TransformPoint(boxFrontDot);
        boxLeftDot  = manipulator.transform.TransformPoint(boxLeftDot);
        boxUpDot    = manipulator.transform.TransformPoint(boxUpDot);

        // Draw front lines
        Handles.DrawLine(boxFrontTopLeft, boxFrontTopRight);
        Handles.DrawLine(boxFrontTopRight, boxFrontBottomRight);
        Handles.DrawLine(boxFrontBottomLeft, boxFrontTopLeft);
        Handles.DrawLine(boxFrontBottomRight, boxFrontBottomLeft);

        // Draw back lines
        Handles.DrawLine(boxBackTopLeft, boxBackTopRight);
        Handles.DrawLine(boxBackTopRight, boxBackBottomRight);
        Handles.DrawLine(boxBackBottomLeft, boxBackTopLeft);
        Handles.DrawLine(boxBackBottomRight, boxBackBottomLeft);

        // Draw front to back lines
        Handles.DrawLine(boxFrontTopLeft, boxBackTopLeft);
        Handles.DrawLine(boxFrontTopRight, boxBackTopRight);
        Handles.DrawLine(boxFrontBottomLeft, boxBackBottomLeft);
        Handles.DrawLine(boxFrontBottomRight, boxBackBottomRight);

        // Draw extents handles
        boxFrontDot = Handles.Slider(boxFrontDot, manipulator.transform.right, HandleUtility.GetHandleSize(boxFrontDot) * .03f, Handles.DotCap, 0f);
        boxUpDot    = Handles.Slider(boxUpDot, manipulator.transform.up, HandleUtility.GetHandleSize(boxUpDot) * .03f, Handles.DotCap, 0f);
        boxLeftDot  = Handles.Slider(boxLeftDot, manipulator.transform.forward, HandleUtility.GetHandleSize(boxLeftDot) * .03f, Handles.DotCap, 0f);

        manipulator.bounds.extents = new Vector3(
            manipulator.transform.InverseTransformPoint(boxFrontDot).x - manipulator.bounds.center.x,
            manipulator.transform.InverseTransformPoint(boxUpDot).y - manipulator.bounds.center.y,
            manipulator.transform.InverseTransformPoint(boxLeftDot).z - manipulator.bounds.center.z
            );
    }
	// Create a new ManipulatorObject and attach to the Playground Manager
	public static ManipulatorObjectC NewManipulatorObject (MANIPULATORTYPEC type, LayerMask affects, Transform manipulatorTransform, float size, float strength, PlaygroundParticlesC playgroundParticles) {
		ManipulatorObjectC manipulatorObject = new ManipulatorObjectC();
		manipulatorObject.type = type;
		manipulatorObject.affects = affects;
		manipulatorObject.transform = manipulatorTransform;
		manipulatorObject.size = size;
		manipulatorObject.strength = strength;
		manipulatorObject.bounds = new Bounds(Vector3.zero, new Vector3(size, size, size));
		manipulatorObject.property = new ManipulatorPropertyC();

		// Add this to Playground Manager or the passed in playgroundParticles
		if (playgroundParticles==null)
			PlaygroundC.reference.manipulators.Add(manipulatorObject);
		else
			playgroundParticles.manipulators.Add(manipulatorObject);
		
		return manipulatorObject;
	}
	public static void RenderManipulatorProperty (ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, SerializedProperty serializedManipulatorProperty) {
		if (thisManipulatorProperty == null) thisManipulatorProperty = new ManipulatorPropertyC();
		
		EditorGUILayout.Separator();
		
		thisManipulatorProperty.type = (MANIPULATORPROPERTYTYPEC)EditorGUILayout.EnumPopup("Property Type", thisManipulatorProperty.type);
		
		// Velocity
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Velocity || thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.AdditiveVelocity) {
			thisManipulatorProperty.velocity = EditorGUILayout.Vector3Field("Particle Velocity", thisManipulatorProperty.velocity);
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Velocity Strength", thisManipulatorProperty.strength);
			thisManipulatorProperty.useLocalRotation = EditorGUILayout.Toggle("Local Rotation", thisManipulatorProperty.useLocalRotation);
		} else 
		// Color
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Color) {
			thisManipulatorProperty.color = EditorGUILayout.ColorField("Particle Color", thisManipulatorProperty.color);
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Color Strength", thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle("Only Color In Range", thisManipulatorProperty.onlyColorInRange);
			thisManipulatorProperty.keepColorAlphas = EditorGUILayout.Toggle("Keep Color Alphas", thisManipulatorProperty.keepColorAlphas);
		} else
		// Size
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Size) {
			thisManipulatorProperty.size = EditorGUILayout.FloatField("Particle Size", thisManipulatorProperty.size);
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Size Strength", thisManipulatorProperty.strength);
		} else
		// Target
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Target) {
			
			// Target List
			bool hasNull = false;
			EditorGUILayout.BeginVertical(boxStyle);
			targetsFoldout = GUILayout.Toggle(targetsFoldout, "Targets ("+thisManipulatorProperty.targets.Count+")", EditorStyles.foldout);
			if (targetsFoldout) {
				if (thisManipulatorProperty.targets.Count>0) {
					for (int t = 0; t<thisManipulatorProperty.targets.Count; t++) {
						EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
						EditorGUILayout.BeginHorizontal();
						
						GUILayout.Label(t.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
						thisManipulatorProperty.targets[t] = EditorGUILayout.ObjectField("", thisManipulatorProperty.targets[t], typeof(Transform), true) as Transform;
						if (!thisManipulatorProperty.targets[t]) hasNull = true;
							
						EditorGUILayout.Separator();
						if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							thisManipulatorProperty.targets.RemoveAt(t);
						}
						
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.EndVertical();
					}
				} else {
					EditorGUILayout.HelpBox("No targets created.", MessageType.Info);
				}
				
				if (hasNull)
					EditorGUILayout.HelpBox("All targets must be assigned.", MessageType.Warning);
				
				if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
					thisManipulatorProperty.targets.Add(thisManipulator.transform);
				}
				EditorGUILayout.Separator();
			}
			EditorGUILayout.EndVertical();
			
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Target Strength", thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyPositionInRange = EditorGUILayout.Toggle("Only Position In Range", thisManipulatorProperty.onlyPositionInRange);
			thisManipulatorProperty.zeroVelocityStrength = EditorGUILayout.Slider("Zero Velocity Strength", thisManipulatorProperty.zeroVelocityStrength, 0, playgroundScriptReference.maximumAllowedManipulatorZeroVelocity);
		} else
		// Death
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Death) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Death Strength", thisManipulatorProperty.strength);
		} else
		// Attractor
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Attractor) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Attractor Strength", thisManipulatorProperty.strength);
		} else
		// Gravitational
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Gravitational) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Gravitational Strength", thisManipulatorProperty.strength);
		} else
		// Repellent
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.Repellent) {
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Repellent Strength", thisManipulatorProperty.strength);
		} else 
		// Lifetime Color
		if (thisManipulatorProperty.type==MANIPULATORPROPERTYTYPEC.LifetimeColor) {
			EditorGUILayout.PropertyField(serializedManipulatorProperty.FindPropertyRelative("lifetimeColor"), new GUIContent("Lifetime Color"));
			thisManipulatorProperty.strength = EditorGUILayout.FloatField("Color Strength", thisManipulatorProperty.strength);
			thisManipulatorProperty.onlyColorInRange = EditorGUILayout.Toggle("Only Color In Range", thisManipulatorProperty.onlyColorInRange);
		}
		
		EditorGUILayout.Separator();
		if (thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.None &&
			thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Attractor &&
			thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Gravitational &&
			thisManipulatorProperty.type!=MANIPULATORPROPERTYTYPEC.Repellent
		)
			thisManipulatorProperty.transition = (MANIPULATORPROPERTYTRANSITIONC)EditorGUILayout.EnumPopup("Transition", thisManipulatorProperty.transition);
	}
	// Calculate the effect from manipulator properties
	public static void PropertyManipulator (PlaygroundParticlesC playgroundParticles, ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, ref int p, ref float t, ref Vector3 particlePosition, ref Vector3 manipulatorPosition, ref bool localSpace) {
		if (thisManipulator.Contains(particlePosition, manipulatorPosition)) {
			switch (thisManipulatorProperty.type) {
				
				// Velocity Property
			case MANIPULATORPROPERTYTYPEC.Velocity:
				if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None)
					playgroundParticles.playgroundCache.velocity[p] = thisManipulatorProperty.useLocalRotation?
						thisManipulator.transform.TransformPoint(thisManipulatorProperty.velocity)-manipulatorPosition
						:
						thisManipulatorProperty.velocity;
				else
					playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], thisManipulatorProperty.useLocalRotation?
						thisManipulator.transform.TransformPoint(thisManipulatorProperty.velocity)-manipulatorPosition
					:
						thisManipulatorProperty.velocity, t*thisManipulatorProperty.strength*thisManipulator.strength);
				break;
				
				// Additive Velocity Property
			case MANIPULATORPROPERTYTYPEC.AdditiveVelocity:
				if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None)
					playgroundParticles.playgroundCache.velocity[p] += thisManipulatorProperty.useLocalRotation?
						thisManipulator.transform.TransformPoint(thisManipulatorProperty.velocity*(t*thisManipulatorProperty.strength*thisManipulator.strength))-manipulatorPosition
						:
						thisManipulatorProperty.velocity*(t*thisManipulatorProperty.strength*thisManipulator.strength);
				else
					playgroundParticles.playgroundCache.velocity[p] += Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], thisManipulatorProperty.useLocalRotation? thisManipulator.transform.TransformPoint(thisManipulatorProperty.velocity)-manipulatorPosition : thisManipulatorProperty.velocity, t*thisManipulatorProperty.strength*thisManipulator.strength)*(t*thisManipulatorProperty.strength*thisManipulator.strength);
				break;
				
				// Color Property
			case MANIPULATORPROPERTYTYPEC.Color:
				Color staticColor;
				if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) {
					if (thisManipulatorProperty.keepColorAlphas) {
						staticColor = thisManipulatorProperty.color;
						staticColor.a = Mathf.Clamp(playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime).a, 0, staticColor.a);
						playgroundParticles.particleCache.particles[p].color = staticColor;
					} else playgroundParticles.particleCache.particles[p].color = thisManipulatorProperty.color;
				} else {
					if (thisManipulatorProperty.keepColorAlphas) {
						staticColor = thisManipulatorProperty.color;
						staticColor.a = Mathf.Clamp(playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime).a, 0, staticColor.a);
						playgroundParticles.particleCache.particles[p].color = Color.Lerp(playgroundParticles.particleCache.particles[p].color, staticColor, t*thisManipulatorProperty.strength*thisManipulator.strength);
					} else playgroundParticles.particleCache.particles[p].color = Color.Lerp(playgroundParticles.particleCache.particles[p].color, thisManipulatorProperty.color, t*thisManipulatorProperty.strength*thisManipulator.strength);
					playgroundParticles.playgroundCache.changedByPropertyColorLerp[p] = true;
				}
				
				// Only color in range of manipulator boundaries
				if (!thisManipulatorProperty.onlyColorInRange)
					playgroundParticles.playgroundCache.changedByPropertyColor[p] = true;

				// Keep alpha of original color
				if (thisManipulatorProperty.keepColorAlphas)
					playgroundParticles.playgroundCache.changedByPropertyColorKeepAlpha[p] = true;
				
				// Set color pairing key
				else if (playgroundParticles.playgroundCache.propertyColorId[p] != thisManipulator.transform.GetInstanceID()) {
					playgroundParticles.playgroundCache.propertyColorId[p] = thisManipulator.transform.GetInstanceID();
				}
				break;
				
				// Lifetime Color Property
			case MANIPULATORPROPERTYTYPEC.LifetimeColor:
				if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) {
					playgroundParticles.particleCache.particles[p].color = thisManipulatorProperty.lifetimeColor.Evaluate(playgroundParticles.lifetime>0?playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime:0);
				} else {
					playgroundParticles.particleCache.particles[p].color = Color.Lerp(playgroundParticles.particleCache.particles[p].color, thisManipulatorProperty.lifetimeColor.Evaluate(playgroundParticles.lifetime>0?playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime:0), t*thisManipulatorProperty.strength*thisManipulator.strength);
					playgroundParticles.playgroundCache.changedByPropertyColorLerp[p] = true;
				}
				
				// Only color in range of manipulator boundaries
				if (!thisManipulatorProperty.onlyColorInRange)
					playgroundParticles.playgroundCache.changedByPropertyColor[p] = true;
				
				// Set color pairing key
				else if (playgroundParticles.playgroundCache.propertyColorId[p] != thisManipulator.transform.GetInstanceID()) {
					playgroundParticles.playgroundCache.propertyColorId[p] = thisManipulator.transform.GetInstanceID();
				}
				break;
				
				// Size Property
			case MANIPULATORPROPERTYTYPEC.Size:
				if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None)
					playgroundParticles.particleCache.particles[p].size = thisManipulatorProperty.size;
				else if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Lerp)
					playgroundParticles.particleCache.particles[p].size = Mathf.Lerp(playgroundParticles.particleCache.particles[p].size, thisManipulatorProperty.size, t*thisManipulatorProperty.strength*thisManipulator.strength);
				else if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Linear)
					playgroundParticles.particleCache.particles[p].size = Mathf.MoveTowards(playgroundParticles.particleCache.particles[p].size, thisManipulatorProperty.size, t*thisManipulatorProperty.strength*thisManipulator.strength);
				playgroundParticles.playgroundCache.changedByPropertySize[p] = true;
				break;
				
				// Target Property
			case MANIPULATORPROPERTYTYPEC.Target:
				if (thisManipulatorProperty.targets.Count>0 && thisManipulatorProperty.targets[thisManipulatorProperty.targetPointer%thisManipulatorProperty.targets.Count]) {
					
					
					// Set target pointer
					if (playgroundParticles.playgroundCache.propertyId[p] != thisManipulator.transform.GetInstanceID()) {
						playgroundParticles.playgroundCache.propertyTarget[p] = thisManipulatorProperty.targetPointer;
						thisManipulatorProperty.targetPointer++; thisManipulatorProperty.targetPointer=thisManipulatorProperty.targetPointer%thisManipulatorProperty.targets.Count;
						playgroundParticles.playgroundCache.propertyId[p] = thisManipulator.transform.GetInstanceID();
					}
					
					// Teleport or lerp to position based on transition type
					if (playgroundParticles.playgroundCache.propertyId[p] == thisManipulator.transform.GetInstanceID() && thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count]) {
						if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None)
							playgroundParticles.particleCache.particles[p].position = localSpace? 
								playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position)
							: 
								thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position;
						else if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Lerp) {
							playgroundParticles.particleCache.particles[p].position = localSpace? 
								Vector3.Lerp(particlePosition, playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position), t*thisManipulatorProperty.strength*thisManipulator.strength)
							:
								Vector3.Lerp(particlePosition, thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position, t*thisManipulatorProperty.strength*thisManipulator.strength);
							if (thisManipulatorProperty.zeroVelocityStrength>0)
								playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], Vector3.zero, t*thisManipulatorProperty.zeroVelocityStrength);
						} else if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Linear) {
							playgroundParticles.particleCache.particles[p].position = localSpace?
								Vector3.MoveTowards(particlePosition, playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position), t*thisManipulatorProperty.strength*thisManipulator.strength)
							:
								Vector3.MoveTowards(particlePosition, thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position, t*thisManipulatorProperty.strength*thisManipulator.strength);
							if (thisManipulatorProperty.zeroVelocityStrength>0)
								playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], Vector3.zero, t*thisManipulatorProperty.zeroVelocityStrength);
						}
						
						// This particle was changed by a target property
						playgroundParticles.playgroundCache.changedByPropertyTarget[p] = true;
					}
				}
				break;
				
				// Death Property
			case MANIPULATORPROPERTYTYPEC.Death:
				if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None)
					playgroundParticles.playgroundCache.life[p] = playgroundParticles.lifetime;
				else
					playgroundParticles.playgroundCache.birth[p] -= t*thisManipulatorProperty.strength*thisManipulator.strength;
				
				// This particle was changed by a death property
				playgroundParticles.playgroundCache.changedByPropertyDeath[p] = true;
				break;
				
				
				// Attractors
			case MANIPULATORPROPERTYTYPEC.Attractor:
				if (!playgroundParticles.onlySourcePositioning) {
					float attractorDistance = Vector3.Distance(manipulatorPosition, particlePosition);
					playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (manipulatorPosition-particlePosition)*((thisManipulatorProperty.strength*thisManipulator.strength)/attractorDistance), t*((thisManipulatorProperty.strength*thisManipulator.strength)/attractorDistance));
				}
				break;
				
				// Attractors Gravitational
			case MANIPULATORPROPERTYTYPEC.Gravitational:
				if (!playgroundParticles.onlySourcePositioning) {
					playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (manipulatorPosition-particlePosition)*(thisManipulatorProperty.strength*thisManipulator.strength)/Vector3.Distance(manipulatorPosition, particlePosition), t);
				}
			break;
				
				// Repellents 
			case MANIPULATORPROPERTYTYPEC.Repellent:
				if (!playgroundParticles.onlySourcePositioning) {
					float repellentsDistance = Vector3.Distance(manipulatorPosition, particlePosition);
					playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (particlePosition-manipulatorPosition)*((thisManipulatorProperty.strength*thisManipulator.strength)/repellentsDistance), t*((thisManipulatorProperty.strength*thisManipulator.strength)/repellentsDistance));
				}
			break;
			}
			
			playgroundParticles.playgroundCache.changedByProperty[p] = true;
			
		} else {
			
			// Handle colors outside of property manipulator range
			if (playgroundParticles.playgroundCache.propertyColorId[p] == thisManipulator.transform.GetInstanceID() && (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Color || thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.LifetimeColor)) {

				// Lerp back color with previous set key
				if (playgroundParticles.playgroundCache.changedByPropertyColorLerp[p] && thisManipulatorProperty.transition != MANIPULATORPROPERTYTRANSITIONC.None && thisManipulatorProperty.onlyColorInRange)
					playgroundParticles.particleCache.particles[p].color = Color.Lerp(playgroundParticles.particleCache.particles[p].color, playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime), t*thisManipulatorProperty.strength*thisManipulator.strength);
			}

			// Target positioning outside of range
			if (thisManipulatorProperty.type == MANIPULATORPROPERTYTYPEC.Target && thisManipulatorProperty.transition != MANIPULATORPROPERTYTRANSITIONC.None) {
				if (thisManipulatorProperty.targets.Count>0 && thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count]!=null) {
					if (playgroundParticles.playgroundCache.changedByPropertyTarget[p] && !thisManipulatorProperty.onlyPositionInRange && thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count] && playgroundParticles.playgroundCache.propertyId[p] == thisManipulator.transform.GetInstanceID()) {
						if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.Lerp)
							playgroundParticles.particleCache.particles[p].position = localSpace?
								Vector3.Lerp(particlePosition, playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position), t*thisManipulatorProperty.strength*thisManipulator.strength)
								:	
								Vector3.Lerp(particlePosition, thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position, t*thisManipulatorProperty.strength*thisManipulator.strength);
						else
							playgroundParticles.particleCache.particles[p].position = localSpace?
								Vector3.MoveTowards(particlePosition, playgroundParticles.particleSystemTransform.InverseTransformPoint(thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position), t*thisManipulatorProperty.strength*thisManipulator.strength)
								:
								Vector3.MoveTowards(particlePosition, thisManipulatorProperty.targets[playgroundParticles.playgroundCache.propertyTarget[p]%thisManipulatorProperty.targets.Count].position, t*thisManipulatorProperty.strength*thisManipulator.strength);
						
						if (thisManipulatorProperty.zeroVelocityStrength>0)
							playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], Vector3.zero, t*thisManipulatorProperty.zeroVelocityStrength);
					}
				}
			}
		}
	}
Exemplo n.º 43
0
	public static void RenderManipulatorInScene (ManipulatorObjectC thisManipulator, Color manipulatorColor) {
		// Draw Manipulators in Scene View
		if (thisManipulator.transform.available && thisManipulator.transform.transform!=null) {
			Handles.color = new Color(manipulatorColor.r,manipulatorColor.g,manipulatorColor.b,Mathf.Clamp(Mathf.Abs(thisManipulator.strength),.25f,1f));
			Handles.color = thisManipulator.enabled? Handles.color : new Color(manipulatorColor.r,manipulatorColor.g,manipulatorColor.b,.2f);
			
			// Position
			if (Tools.current==Tool.Move)
				thisManipulator.transform.transform.position = Handles.PositionHandle(thisManipulator.transform.transform.position, Tools.pivotRotation==PivotRotation.Global? Quaternion.identity : thisManipulator.transform.transform.rotation);
			// Rotation
			else if (Tools.current==Tool.Rotate)
				thisManipulator.transform.transform.rotation = Handles.RotationHandle(thisManipulator.transform.transform.rotation, thisManipulator.transform.transform.position);
			// Scale
			else if (Tools.current==Tool.Scale)
				thisManipulator.transform.transform.localScale = Handles.ScaleHandle(thisManipulator.transform.transform.localScale, thisManipulator.transform.transform.position, thisManipulator.transform.transform.rotation, HandleUtility.GetHandleSize(thisManipulator.transform.transform.position));
			
			// Sphere Size
			if (thisManipulator.shape==MANIPULATORSHAPEC.Sphere) {
				thisManipulator.size = Handles.RadiusHandle (Quaternion.identity, thisManipulator.transform.position, thisManipulator.size);
				if (thisManipulator.enabled && GUIUtility.hotControl>0)
					Handles.Label(thisManipulator.transform.transform.position+new Vector3(thisManipulator.size+1f,1f,0f), playgroundLanguage.size+" "+thisManipulator.size.ToString("f2"));
				
				// Box Bounds
			} else {
				DrawManipulatorBox(thisManipulator);
			}
			
			// Strength
			manipulatorHandlePosition = thisManipulator.transform.transform.position+new Vector3(0f,thisManipulator.strength,0f);
			
			// Event particles
			if (thisManipulator.trackParticles) {
				
				Handles.Label(thisManipulator.transform.transform.position+new Vector3(0f,-(thisManipulator.size+1f),0f), thisManipulator.particles.Count+" "+playgroundLanguage.particles);
				
			}
			
			Handles.DrawLine(thisManipulator.transform.transform.position, manipulatorHandlePosition);
			thisManipulator.strength = Handles.ScaleValueHandle(thisManipulator.strength, manipulatorHandlePosition, Quaternion.identity, HandleUtility.GetHandleSize(manipulatorHandlePosition), Handles.SphereCap, 1);      
			if (thisManipulator.enabled && GUIUtility.hotControl>0)
				Handles.Label(manipulatorHandlePosition+new Vector3(1f,1f,0f), playgroundLanguage.strength+" "+thisManipulator.strength.ToString("f2"));
			
			Handles.color = new Color(.4f,.6f,1f,.025f);
			Handles.DrawSolidDisc(thisManipulator.transform.transform.position, Camera.current.transform.forward, thisManipulator.strength);
			Handles.color = new Color(.4f,.6f,1f,.5f);
			Handles.DrawSolidDisc(thisManipulator.transform.transform.position, Camera.current.transform.forward, HandleUtility.GetHandleSize(thisManipulator.transform.transform.position)*.05f);
		}
		
	}
	// Calculate the effect from a manipulator
	public static void CalculateManipulator (PlaygroundParticlesC playgroundParticles, ManipulatorObjectC thisManipulator, ref int p, ref float t, Vector3 particlePosition, Vector3 manipulatorPosition, ref bool localSpace) {
		if (thisManipulator.enabled && thisManipulator.transform!=null && thisManipulator.strength!=0 && (thisManipulator.affects.value & 1<<playgroundParticles.particleSystemGameObject.layer)!=0) {
			float manipulatorDistance;
			if (!playgroundParticles.onlySourcePositioning) {
				// Attractors
				if (thisManipulator.type==MANIPULATORTYPEC.Attractor) {
					manipulatorDistance = Vector3.Distance(manipulatorPosition, particlePosition);
					if (thisManipulator.Contains(particlePosition, manipulatorPosition)) {
						playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (manipulatorPosition-particlePosition)*(thisManipulator.strength/manipulatorDistance), t*(thisManipulator.strength/manipulatorDistance));
					}
				} else
					
					// Attractors Gravitational
				if (thisManipulator.type==MANIPULATORTYPEC.AttractorGravitational) {
					manipulatorDistance = Vector3.Distance(manipulatorPosition, particlePosition);
					if (thisManipulator.Contains(particlePosition, manipulatorPosition)) {
						playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (manipulatorPosition-particlePosition)*thisManipulator.strength/manipulatorDistance, t);
					}
				} else
					
					// Repellents 
				if (thisManipulator.type==MANIPULATORTYPEC.Repellent) {
					manipulatorDistance = Vector3.Distance(manipulatorPosition, particlePosition);
					if (thisManipulator.Contains(particlePosition, manipulatorPosition)) {
						playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], (particlePosition-manipulatorPosition)*(thisManipulator.strength/manipulatorDistance), t*(thisManipulator.strength/manipulatorDistance));
					}
				}
			}
			
			// Properties
			if (thisManipulator.type==MANIPULATORTYPEC.Property) {
				PropertyManipulator(playgroundParticles, thisManipulator, thisManipulator.property, ref p, ref t, ref particlePosition, ref manipulatorPosition, ref localSpace);
			}
			
			// Combined
			if (thisManipulator.type==MANIPULATORTYPEC.Combined) {
				for (int i = 0; i<thisManipulator.properties.Count; i++)
					PropertyManipulator(playgroundParticles, thisManipulator, thisManipulator.properties[i], ref p, ref t, ref particlePosition, ref manipulatorPosition, ref localSpace);
			}
		}
	}
Exemplo n.º 45
0
	// Draws a Manipulator bounding box with handles in scene view
	public static void DrawManipulatorBox (ManipulatorObjectC manipulator) {
		Vector3 boxFrontTopLeft;
		Vector3 boxFrontTopRight;
		Vector3 boxFrontBottomLeft;
		Vector3 boxFrontBottomRight;
		Vector3 boxBackTopLeft;
		Vector3 boxBackTopRight;
		Vector3 boxBackBottomLeft;
		Vector3 boxBackBottomRight;
		Vector3 boxFrontDot;
		Vector3 boxLeftDot;
		Vector3 boxUpDot;
		
		// Always set positive values of bounds
		manipulator.bounds.extents = new Vector3(Mathf.Abs(manipulator.bounds.extents.x), Mathf.Abs(manipulator.bounds.extents.y), Mathf.Abs(manipulator.bounds.extents.z));
		
		// Set positions from bounds
		boxFrontTopLeft 		= new Vector3(manipulator.bounds.center.x - manipulator.bounds.extents.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z - manipulator.bounds.extents.z);
		boxFrontTopRight 		= new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z - manipulator.bounds.extents.z);
		boxFrontBottomLeft 		= new Vector3(manipulator.bounds.center.x - manipulator.bounds.extents.x, manipulator.bounds.center.y - manipulator.bounds.extents.y, manipulator.bounds.center.z - manipulator.bounds.extents.z);
		boxFrontBottomRight 	= new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y - manipulator.bounds.extents.y, manipulator.bounds.center.z - manipulator.bounds.extents.z);
		boxBackTopLeft 			= new Vector3(manipulator.bounds.center.x - manipulator.bounds.extents.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);
		boxBackTopRight 		= new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);
		boxBackBottomLeft 		= new Vector3(manipulator.bounds.center.x - manipulator.bounds.extents.x, manipulator.bounds.center.y - manipulator.bounds.extents.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);
		boxBackBottomRight 		= new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y - manipulator.bounds.extents.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);
		
		boxFrontDot				= new Vector3(manipulator.bounds.center.x + manipulator.bounds.extents.x, manipulator.bounds.center.y, manipulator.bounds.center.z);
		boxUpDot				= new Vector3(manipulator.bounds.center.x, manipulator.bounds.center.y + manipulator.bounds.extents.y, manipulator.bounds.center.z);
		boxLeftDot				= new Vector3(manipulator.bounds.center.x, manipulator.bounds.center.y, manipulator.bounds.center.z + manipulator.bounds.extents.z);
		
		// Apply transform positioning
		boxFrontTopLeft			= manipulator.transform.transform.TransformPoint(boxFrontTopLeft);
		boxFrontTopRight		= manipulator.transform.transform.TransformPoint(boxFrontTopRight);
		boxFrontBottomLeft		= manipulator.transform.transform.TransformPoint(boxFrontBottomLeft);
		boxFrontBottomRight		= manipulator.transform.transform.TransformPoint(boxFrontBottomRight);
		boxBackTopLeft			= manipulator.transform.transform.TransformPoint(boxBackTopLeft);
		boxBackTopRight			= manipulator.transform.transform.TransformPoint(boxBackTopRight);
		boxBackBottomLeft		= manipulator.transform.transform.TransformPoint(boxBackBottomLeft);
		boxBackBottomRight		= manipulator.transform.transform.TransformPoint(boxBackBottomRight);
		
		boxFrontDot				= manipulator.transform.transform.TransformPoint(boxFrontDot);
		boxLeftDot				= manipulator.transform.transform.TransformPoint(boxLeftDot);
		boxUpDot				= manipulator.transform.transform.TransformPoint(boxUpDot);
		
		// Draw front lines
		Handles.DrawLine(boxFrontTopLeft, boxFrontTopRight);
		Handles.DrawLine(boxFrontTopRight, boxFrontBottomRight);
		Handles.DrawLine(boxFrontBottomLeft, boxFrontTopLeft);
		Handles.DrawLine(boxFrontBottomRight, boxFrontBottomLeft);
		
		// Draw back lines
		Handles.DrawLine(boxBackTopLeft, boxBackTopRight);
		Handles.DrawLine(boxBackTopRight, boxBackBottomRight);
		Handles.DrawLine(boxBackBottomLeft, boxBackTopLeft);
		Handles.DrawLine(boxBackBottomRight, boxBackBottomLeft);
		
		// Draw front to back lines
		Handles.DrawLine(boxFrontTopLeft, boxBackTopLeft);
		Handles.DrawLine(boxFrontTopRight, boxBackTopRight);
		Handles.DrawLine(boxFrontBottomLeft, boxBackBottomLeft);
		Handles.DrawLine(boxFrontBottomRight, boxBackBottomRight);
		
		// Draw extents handles
		boxFrontDot = Handles.Slider(boxFrontDot, manipulator.transform.right, HandleUtility.GetHandleSize(boxFrontDot)*.03f, Handles.DotCap, 0f);
		boxUpDot = Handles.Slider(boxUpDot, manipulator.transform.up, HandleUtility.GetHandleSize(boxUpDot)*.03f, Handles.DotCap, 0f);
		boxLeftDot = Handles.Slider(boxLeftDot, manipulator.transform.forward, HandleUtility.GetHandleSize(boxLeftDot)*.03f, Handles.DotCap, 0f);
		
		manipulator.bounds.extents = new Vector3(
			manipulator.transform.transform.InverseTransformPoint(boxFrontDot).x-manipulator.bounds.center.x,
			manipulator.transform.transform.InverseTransformPoint(boxUpDot).y-manipulator.bounds.center.y,
			manipulator.transform.transform.InverseTransformPoint(boxLeftDot).z-manipulator.bounds.center.z
			);	
	}
	// Return a copy of this ManipulatorObjectC
	public ManipulatorObjectC Clone () {
		ManipulatorObjectC manipulatorObject = new ManipulatorObjectC();
		manipulatorObject.type = this.type;
		manipulatorObject.property = this.property.Clone();
		manipulatorObject.affects = this.affects;
		manipulatorObject.transform = this.transform;
		manipulatorObject.size = this.size;
		manipulatorObject.shape = this.shape;
		manipulatorObject.bounds = this.bounds;
		manipulatorObject.strength = this.strength;
		manipulatorObject.enabled = this.enabled;
		manipulatorObject.inverseBounds = this.inverseBounds;
		manipulatorObject.properties = new List<ManipulatorPropertyC>();
		for (int i = 0; i<properties.Count; i++)
			manipulatorObject.properties.Add(properties[i].Clone());
		return manipulatorObject;
	}
Exemplo n.º 47
0
 void Start()
 {
     globalManipulator = PlaygroundC.GetManipulator(0);
 }