예제 #1
0
        /// <summary>
        /// Updates a PlaygroundParticlesC object (called each calculation step from PlaygroundC).
        /// </summary>
        public bool UpdateSystem()
        {
            if (isYieldRefreshing || isLoading || playgroundCache==null || thisInstance==null || !particleSystemGameObject.activeInHierarchy || !particleSystemGameObject.activeSelf || !enabled || isSettingLifetime || isSettingParticleCount || isPrewarming) return false;

            // Emission halt for disabling called from calculation thread
            if (queueEmissionHalt && !IsAlive() && !loop) {
                if (disableOnDoneRoutine==ONDONE.Inactivate)
                    particleSystemGameObject.SetActive(false);
                else if (Application.isPlaying) {
                    DestroyImmediate(particleSystemGameObject);
                    return false;
                }
            }

            // Source
            if (source!=prevSource) {
                prevSource=source;
                return false;
            }

            // Particle count
            if (particleCount!=previousParticleCount) {
                SetParticleCount(thisInstance, particleCount);
                isDoneThread = true;
                if (particleCount>0)
                    StartCoroutine(Boot());
                return false;
            }

            // Particle emission
            if (emit!=previousEmission) {
                Emit(emit);
                return false;
            }

            // Particle loop enabled again
            if (loop!=previousLoop) {
                if (emit && loop)
                    Emit(true);
                previousLoop = loop;
                return false;
            }

            // Particle size
            if (sizeMin!=previousSizeMin || sizeMax!=previousSizeMax)
                SetSizeRandom(thisInstance, sizeMin, sizeMax);

            // Particle rotation
            if (initialRotationMin!=previousInitialRotationMin || initialRotationMax!=previousInitialRotationMax)
                SetInitialRotationRandom(thisInstance, initialRotationMin, initialRotationMax);
            if (rotationSpeedMin!=previousRotationSpeedMin || rotationSpeedMax!=previousRotationSpeedMax)
                SetRotationRandom(thisInstance, rotationSpeedMin, rotationSpeedMax);

            // Particle velocity
            if (applyInitialVelocity) {
                if (initialVelocityMin!=previousVelocityMin || initialVelocityMax!=previousVelocityMax || initialVelocityMethod!=previousVelocityMethod || playgroundCache.initialVelocity==null || playgroundCache.initialVelocity.Length!=particleCount) {
                    SetVelocityRandom(thisInstance, initialVelocityMin, initialVelocityMax);
                    return false;
                }
            }

            // Particle local velocity
            if (applyInitialLocalVelocity) {
                if (initialLocalVelocityMin!=previousLocalVelocityMin || initialLocalVelocityMax!=previousLocalVelocityMax || initialLocalVelocityMethod!=previousLocalVelocityMethod || playgroundCache.initialLocalVelocity==null || playgroundCache.initialLocalVelocity.Length!=particleCount) {
                    SetLocalVelocityRandom(thisInstance, initialLocalVelocityMin, initialLocalVelocityMax);
                    return false;
                }
            }

            // Particle life
            if (previousLifetime!=lifetime ||
                lifetimeValueMethod==VALUEMETHOD.Constant && previousLifetimeValueMethod!=lifetimeValueMethod) {
                Start();
                return false;
            }

            // Lifetime sorting
            if (previousNearestNeighborOriginMethod!=nearestNeighborOriginMethod ||
                (sorting==SORTINGC.NearestNeighbor||sorting==SORTINGC.NearestNeighborReversed)&&
                (nearestNeighborOriginMethod==NEARESTNEIGHBORORIGINMETHOD.SourcePoint && previousNearestNeighborOrigin!=nearestNeighborOrigin ||
                nearestNeighborOriginMethod==NEARESTNEIGHBORORIGINMETHOD.Vector3 && previousNearestNeighborOriginVector3!=nearestNeighborOriginVector3 ||
                nearestNeighborOriginMethod==NEARESTNEIGHBORORIGINMETHOD.Transform && previousNearestNeighborOriginTransform!=nearestNeighborOriginTransform) ||
                previousSorting!=sorting || previousLifetimeEmission!=lifetimeEmission) {
                Start();
                return false;
            }

            // Particle total lifetime
            if (lifetimeValueMethod==VALUEMETHOD.RandomBetweenTwoValues) {
                if (previousLifetimeMin!=lifetimeMin ||
                    previousLifetime!=lifetime ||
                    previousLifetimeValueMethod!=lifetimeValueMethod) {
                    SetLifetimeSubtraction(thisInstance);
                    previousLifetimeMin=lifetimeMin;
                }
            }

            // Particle emission rate
            if (previousEmissionRate!=emissionRate && source!=SOURCEC.Script) {
                SetEmissionRate(thisInstance);
            }

            // Particle state change
            if (source==SOURCEC.State && activeState!=previousActiveState) {
                if (states[activeState].positionLength>particleCount)
                    SetParticleCount(thisInstance, states[activeState].positionLength);
                previousActiveState = activeState;
            }

            // All good!
            return true;
        }
예제 #2
0
        void OnEnable()
        {
            if (isSnapshot || isLoading) return;
            thisInstance = this;
            thisLayer = particleSystemGameObject.layer;
            initialized = false;
            isYieldRefreshing = false;
            isSettingParticleCount = false;
            isSettingLifetime = false;
            hasActiveParticles = true;
            threadHadNoActiveParticles = false;
            isDoneThread = true;
            calculate = true;

            lastTimeUpdated = PlaygroundC.globalTime;
            localTime = lastTimeUpdated;
            emissionStopped = 0;
            queueEmissionHalt = false;

            // Set new randoms
            RefreshSystemRandom();

            // Set 0 size to avoid one-frame flash
            shurikenParticleSystem.startSize = 0f;

            if (shurikenParticleSystem.isPaused || shurikenParticleSystem.isStopped)
                shurikenParticleSystem.Play();

            // Set initial values
            previousLifetimeValueMethod = lifetimeValueMethod;
            previousLifetime = lifetime;
            previousLifetimeMin = lifetimeMin;
            previousEmission = emit;
            previousLoop = loop;
            previousNearestNeighborOrigin = nearestNeighborOrigin;
            previousNearestNeighborOriginMethod = nearestNeighborOriginMethod;
            previousNearestNeighborOriginVector3 = nearestNeighborOriginVector3;
            previousNearestNeighborOriginTransform = nearestNeighborOriginTransform;
            previousSorting = sorting;
            previousParticleCount = particleCount;
            previousLifetimeEmission = lifetimeEmission;
            prevSource = source;
            loopExceeded = false;
            loopExceededOnParticle = -1;

            stRot = Quaternion.identity;
            stDir = new Vector3();

            // Initiate all arrays by setting particle count
            if (particleCache==null) {
                SetParticleCount(thisInstance, particleCount);
            } else {

                // Clean up particle positions
                SetInitialTargetPosition(thisInstance, PlaygroundC.initialTargetPosition, true);

                // Refresh
                StartCoroutine(YieldedRefresh());
            }
        }
예제 #3
0
 /// <summary>
 /// Emits a single particle with specified lifetime. This will set particle position, velocity and color from previously called emission (as set in the Source tab).
 /// </summary>
 /// <param name="giveLifetime">Lifetime.</param>
 public int Emit(float giveLifetime)
 {
     source = SOURCEC.Script;
     int returnIndex = scriptedEmissionIndex;
     scriptedLifetime = giveLifetime;
     EmitProcedure(scriptedEmissionPosition, scriptedEmissionVelocity, scriptedEmissionColor);
     scriptedLifetime = 0;
     return returnIndex;
 }
예제 #4
0
 /// <summary>
 /// Emits a single particle with specified position, velocity, lifetime and color.
 /// </summary>
 /// <param name="givePosition">Position.</param>
 /// <param name="giveVelocity">Velocity.</param>
 /// <param name="giveLifetime">Lifetime.</param>
 /// <param name="giveColor">Color.</param>
 public int Emit(Vector3 givePosition, Vector3 giveVelocity, float giveLifetime, Color32 giveColor)
 {
     source = SOURCEC.Script;
     int returnIndex = scriptedEmissionIndex;
     scriptedLifetime = giveLifetime;
     EmitProcedure(givePosition, giveVelocity, giveColor);
     scriptedLifetime = 0;
     return returnIndex;
 }
예제 #5
0
 /// <summary>
 /// Emits number of particles set by quantity. All other values will be set from the previous scripted emission call (or as set in Inspector).
 /// </summary>
 /// <param name="quantity">Quantity.</param>
 public void Emit(int quantity)
 {
     source = SOURCEC.Script;
     for (int i = 0; i<quantity; i++)
         EmitProcedure(
             scriptedEmissionPosition,
             scriptedEmissionVelocity,
             scriptedEmissionColor
         );
 }
예제 #6
0
 /// <summary>
 /// Emits number of particles set by quantity, minimum - maximum random position and velocity.
 /// </summary>
 /// <param name="quantity">Quantity.</param>
 /// <param name="randomPositionMin">Random position minimum.</param>
 /// <param name="randomPositionMax">Random position max.</param>
 /// <param name="randomVelocityMin">Random velocity minimum.</param>
 /// <param name="randomVelocityMax">Random velocity max.</param>
 /// <param name="giveColor">Color.</param>
 public void Emit(int quantity, Vector3 randomPositionMin, Vector3 randomPositionMax, Vector3 randomVelocityMin, Vector3 randomVelocityMax, Color32 giveColor)
 {
     source = SOURCEC.Script;
     for (int i = 0; i<quantity; i++)
         EmitProcedure(
             RandomRange(internalRandom01, randomPositionMin, randomPositionMax),
             applyInitialVelocityShape?
                 Vector3.Scale (RandomRange(internalRandom01, randomVelocityMin, randomVelocityMax), initialVelocityShape.Evaluate((i*1f)/(quantity*1f), initialVelocityShapeScale))
             :
                 RandomRange(internalRandom01, randomVelocityMin, randomVelocityMax),
             giveColor
         );
 }
예제 #7
0
 /// <summary>
 /// Emits a single particle at position with previously set scripted emission velocity and color.
 /// </summary>
 /// <param name="givePosition">Position.</param>
 public int Emit(Vector3 givePosition)
 {
     source = SOURCEC.Script;
     int returnIndex = scriptedEmissionIndex;
     EmitProcedure(givePosition, scriptedEmissionVelocity, scriptedEmissionColor);
     //particleSystemGameObject.SetActive(true);
     return returnIndex;
 }
예제 #8
0
 /// <summary>
 /// Emits a single particle at position with velocity and color (Source Mode SOURCEC.Script will be automatically set).
 /// </summary>
 /// <param name="givePosition">Position.</param>
 /// <param name="giveVelocity">Velocity.</param>
 /// <param name="giveColor">Color.</param>
 public int Emit(Vector3 givePosition, Vector3 giveVelocity, Color32 giveColor)
 {
     source = SOURCEC.Script;
     int returnIndex = scriptedEmissionIndex;
     EmitProcedure(givePosition, giveVelocity, giveColor);
     return returnIndex;
 }
	public override void OnInspectorGUI () {
		if (boxStyle==null)
			boxStyle = GUI.skin.FindStyle("box");
		
		if (Selection.activeTransform==null) {
			EditorGUILayout.LabelField("Please edit this from Hierarchy only.");
			return;
		}
		
		if (Event.current.type == EventType.ValidateCommand &&
			Event.current.commandName == "UndoRedoPerformed") {			
				PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.particleCount);
				LifetimeSorting();
		}
		
		playgroundParticles.Update();
		
		EditorGUILayout.Separator();
		
		GUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Particle Playground "+PlaygroundC.version+PlaygroundC.specialVersion, EditorStyles.largeLabel, GUILayout.Height(20));
		
		EditorGUILayout.Separator();
		
		if(GUILayout.Button("Playground Wizard", EditorStyles.toolbarButton)) {
			PlaygroundParticleWindowC.ShowWindow();
		}
		if(GUILayout.Button("Create Preset", EditorStyles.toolbarButton)){
			PlaygroundCreatePresetWindowC.ShowWindow();
		}
		GUILayout.EndHorizontal();
		
		EditorGUILayout.Separator();

		if (playgroundParticlesScriptReference.particleSystemTransform.localScale.x != 1f ||
		    playgroundParticlesScriptReference.particleSystemTransform.localScale.y != 1f ||
		    playgroundParticlesScriptReference.particleSystemTransform.localScale.z != 1f) {
			EditorGUILayout.BeginVertical (boxStyle);
			EditorGUILayout.HelpBox("A local scale of anything else than Vector3 (1,1,1) may result in Shuriken component not rendering.", MessageType.Warning);
			if (GUILayout.Button ("Fix", EditorStyles.toolbarButton, GUILayout.Width (40)))
				playgroundParticlesScriptReference.particleSystemTransform.localScale = new Vector3(1f,1f,1f);
			EditorGUILayout.EndVertical ();
		}
		// Particles
		EditorGUILayout.BeginVertical(boxStyle);
		if (playgroundParticlesScriptReference.eventControlledBy.Count>0)
			particlesFoldout = GUILayout.Toggle(particlesFoldout, "Playground Particles (Event Controlled)", EditorStyles.foldout);
		else if (playgroundParticlesScriptReference.isSnapshot)
			particlesFoldout = GUILayout.Toggle(particlesFoldout, "Playground Particles (Snapshot)", EditorStyles.foldout);
		else
			particlesFoldout = GUILayout.Toggle(particlesFoldout, "Playground Particles", EditorStyles.foldout);
		if (particlesFoldout) {
			
			EditorGUILayout.BeginVertical(boxStyle);
			
			// Source Settings
			if (GUILayout.Button("Source ("+playgroundParticlesScriptReference.source.ToString()+")", EditorStyles.toolbarDropDown)) sourceFoldout=!sourceFoldout;
			if (sourceFoldout) {
				
				EditorGUILayout.Separator();
				
				if (previousSource!=playgroundParticlesScriptReference.source) {
					LifetimeSorting();
				}
				EditorGUILayout.PropertyField(source, new GUIContent(
					"Source", 
					"Source is the target method for the particles in this Particle Playground System.\n\nState: Target position and color in a stored state\n\nTransform: Target transforms live in the scene\n\nWorldObject: Target each vertex in a mesh live in the scene\n\nSkinnedWorldObject: Target each vertex in a skinned mesh live in the scene\n\nScript: Behaviour controlled by custom scripts\n\nPaint: Target painted positions and colors made with a brush\n\nProjection: Target projected positions and colors made with a texture")
				);
				
				EditorGUILayout.Separator();
				
				// Source is State
				if (source.intValue == 0) {
					RenderStateSettings();
					
				// Source is Projection
				} else if (source.intValue == 6) {
					RenderProjectionSettings();
				
				// Source is Transforms
				} else if (source.intValue == 1) {
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Transform");
					sourceTransform.objectReferenceValue = EditorGUILayout.ObjectField(sourceTransform.objectReferenceValue, typeof(Transform), true);
					GUILayout.EndHorizontal();
					
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Points:");
					EditorGUILayout.SelectableLabel(sourceTransform.objectReferenceValue!=null?"1":"0", GUILayout.MaxWidth(80));
					EditorGUILayout.Separator();
					if(GUILayout.Button("Set Particle Count", EditorStyles.toolbarButton)){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, sourceTransform.objectReferenceValue!=null?1:0);
						playgroundParticlesScriptReference.Start();
					}
					GUI.enabled = (sourceTransform.objectReferenceValue!=null);
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
						particleCount.intValue = particleCount.intValue+1;
					GUI.enabled = true;
					GUILayout.EndHorizontal();
					
				// Source is World Object
				} else if (source.intValue == 2) {
					playgroundParticlesScriptReference.worldObject.gameObject = (GameObject)EditorGUILayout.ObjectField("World Object", playgroundParticlesScriptReference.worldObject.gameObject, typeof(GameObject), true);

					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Points:");
					EditorGUILayout.SelectableLabel((playgroundParticlesScriptReference.worldObject.vertexPositions!=null && playgroundParticlesScriptReference.worldObject.vertexPositions.Length>0)?playgroundParticlesScriptReference.worldObject.vertexPositions.Length.ToString():"No mesh", GUILayout.MaxWidth(80));
					
					EditorGUILayout.Separator();
					if(GUILayout.Button("Set Particle Count", EditorStyles.toolbarButton) && playgroundParticlesScriptReference.worldObject.vertexPositions!=null){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.worldObject.vertexPositions.Length);
						playgroundParticlesScriptReference.Start();
					}
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}) && playgroundParticlesScriptReference.worldObject.vertexPositions!=null)
						particleCount.intValue = particleCount.intValue+playgroundParticlesScriptReference.worldObject.vertexPositions.Length;
					GUILayout.EndHorizontal();

					GUILayout.BeginVertical(boxStyle);
					EditorGUILayout.LabelField("Procedural Options");
					EditorGUILayout.PropertyField(worldObjectUpdateVertices, new GUIContent(
						"Mesh Vertices Update",
						"Enable this if the World Object's mesh is procedural and changes vertices over time."
					));
					EditorGUILayout.PropertyField(worldObjectUpdateNormals, new GUIContent(
						"Mesh Normals Update",
						"Enable this if the World Object's mesh is procedural and changes normals over time."
					));
					GUILayout.EndVertical();
					
				// Source is Skinned World Object
				} else if (source.intValue == 3) {
					playgroundParticlesScriptReference.skinnedWorldObject.gameObject = (GameObject)EditorGUILayout.ObjectField("Skinned World Object", playgroundParticlesScriptReference.skinnedWorldObject.gameObject, typeof(GameObject), true);
					
					if (playgroundParticlesScriptReference.skinnedWorldObject.mesh) {
						int prevDownResolutionSkinned = playgroundParticlesScriptReference.skinnedWorldObject.downResolution;
						playgroundParticlesScriptReference.skinnedWorldObject.downResolution = EditorGUILayout.IntSlider("Source Down Resolution", playgroundParticlesScriptReference.skinnedWorldObject.downResolution, 1, Mathf.RoundToInt (playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/2));
						if (prevDownResolutionSkinned!=playgroundParticlesScriptReference.skinnedWorldObject.downResolution)
							LifetimeSorting();
					}

					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Points:");
					if (playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions!=null && playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length>0) {
						if (playgroundParticlesScriptReference.skinnedWorldObject.downResolution<=1)
							EditorGUILayout.SelectableLabel(playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length.ToString(), GUILayout.MaxWidth(80));
						else
							EditorGUILayout.SelectableLabel((playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.skinnedWorldObject.downResolution).ToString()+" ("+playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length.ToString()+")", GUILayout.MaxWidth(160));
					} else EditorGUILayout.SelectableLabel("No mesh");
					EditorGUILayout.Separator();
					if(GUILayout.Button("Set Particle Count", EditorStyles.toolbarButton) && playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions!=null){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.skinnedWorldObject.downResolution<=1?playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length:playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.skinnedWorldObject.downResolution);
						playgroundParticlesScriptReference.Start();
					}
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}) && playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions!=null)
						particleCount.intValue = particleCount.intValue+(playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.skinnedWorldObject.downResolution);
					GUILayout.EndHorizontal();

					GUILayout.BeginVertical(boxStyle);
					EditorGUILayout.LabelField("Procedural Options");
					EditorGUILayout.PropertyField(worldObjectUpdateVertices, new GUIContent(
						"Mesh Vertices Update",
						"Enable this if the Skinned World Object's mesh is procedural and changes vertices over time."
						));
					EditorGUILayout.PropertyField(worldObjectUpdateNormals, new GUIContent(
						"Mesh Normals Update",
						"Enable this if the Skinned World Object's mesh is procedural and changes normals over time."
						));
					GUILayout.EndVertical();
					
				// Source is Script
				} else if (source.intValue == 4) {

					// Controlled by events
					if (playgroundParticlesScriptReference.eventControlledBy.Count>0) {
						GUILayout.BeginVertical (boxStyle);
						int eventCount = 0;
						EditorGUILayout.HelpBox("This Particle Playground System is controlled by events from another particle system.", MessageType.Info);
						for (int i = 0; i<playgroundParticlesScriptReference.eventControlledBy.Count; i++) {
							eventCount = 0;
							for (int x = 0; x<playgroundParticlesScriptReference.eventControlledBy[i].events.Count; x++)
								if (playgroundParticlesScriptReference.eventControlledBy[i].events[x].target==playgroundParticlesScriptReference) eventCount++;
							GUILayout.BeginHorizontal (boxStyle);
							GUILayout.Label (i.ToString(), EditorStyles.miniLabel, new GUILayoutOption[]{GUILayout.Width(18)});
							if (GUILayout.Button (playgroundParticlesScriptReference.eventControlledBy[i].name+" ("+eventCount+")", EditorStyles.label)) 
								Selection.activeGameObject = playgroundParticlesScriptReference.eventControlledBy[i].particleSystemGameObject;
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								if (EditorUtility.DisplayDialog(
									"Remove events from "+playgroundParticlesScriptReference.eventControlledBy[i].name+"?",
									"All events connected to this particle system from "+playgroundParticlesScriptReference.eventControlledBy[i].name+" will be removed. Are you sure you want to remove them?", 
									"Yes", "No")) {
									for (int x = 0; x<playgroundParticlesScriptReference.eventControlledBy[i].events.Count; x++) {
										if (playgroundParticlesScriptReference.eventControlledBy[i].events[x].target == playgroundParticlesScriptReference) {
											playgroundParticlesScriptReference.eventControlledBy[i].events.RemoveAt(x);
											x--;
										}
									}
									playgroundParticlesScriptReference.eventControlledBy.RemoveAt (i);
								}
							}
							GUILayout.EndHorizontal ();
						}
						GUILayout.EndVertical ();
						GUI.enabled = false;
					} else EditorGUILayout.HelpBox("This Particle Playground System is controlled by script. You can only emit particles from script in this source mode using PlaygroundParticlesC.Emit(position, velocity, color) or let another particle system control it by events. Please see the manual for more details.", MessageType.Info);


					EditorGUILayout.Separator();
					
					EditorGUILayout.BeginVertical(boxStyle);
					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.scriptedEmissionIndex = EditorGUILayout.IntField("Emission Index", Mathf.Clamp(playgroundParticlesScriptReference.scriptedEmissionIndex, 0, playgroundParticlesScriptReference.particleCount-1));
					if(GUILayout.RepeatButton("Emit ()", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Height(16)})) {
						PlaygroundC.Emit(playgroundParticlesScriptReference);
					}
					EditorGUILayout.EndHorizontal();
					
					playgroundParticlesScriptReference.scriptedEmissionPosition = EditorGUILayout.Vector3Field("Position", playgroundParticlesScriptReference.scriptedEmissionPosition);
					playgroundParticlesScriptReference.scriptedEmissionVelocity = EditorGUILayout.Vector3Field("Velocity", playgroundParticlesScriptReference.scriptedEmissionVelocity);
					playgroundParticlesScriptReference.scriptedEmissionColor = EditorGUILayout.ColorField("Color", playgroundParticlesScriptReference.scriptedEmissionColor);

					EditorGUILayout.EndVertical();

					GUI.enabled = true;
					
				// Source is Paint
				} else if (source.intValue == 5) {
					
					if (playgroundParticlesScriptReference.paint==null) {
						PlaygroundC.PaintObject(playgroundParticlesScriptReference);
					}
					
					// Paint Mode
					EditorGUILayout.BeginVertical(boxStyle);
					EditorGUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Paint Mode");
					selectedPaintMode = GUILayout.Toolbar (selectedPaintMode, new string[]{"Dot","Brush","Eraser"}, EditorStyles.toolbarButton);
					EditorGUILayout.EndHorizontal();
					
					// Dot
					if (selectedPaintMode!=0) {
						EditorGUILayout.Separator();
					}
					
					// Brush
					if (selectedPaintMode==1) {
						EditorGUI.indentLevel++;
						EditorGUILayout.BeginVertical(boxStyle);
						brushPresetFoldout = GUILayout.Toggle(brushPresetFoldout, "Brush Presets", EditorStyles.foldout);
						EditorGUI.indentLevel--;
						if (brushPresetFoldout) {
							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.Separator();
							brushListStyle = GUILayout.Toolbar (brushListStyle, new string[]{"Icons","List"}, EditorStyles.toolbarButton, GUILayout.MaxWidth(120));
							EditorGUILayout.EndHorizontal();
							EditorGUILayout.Separator();
							int i;
							
							// Icons
							if (brushListStyle==0) {
								GUILayout.BeginHorizontal();
								for (i = 0; i<brushPresets.Length; i++) {
									EditorGUILayout.BeginVertical(new GUILayoutOption[]{GUILayout.Width(50), GUILayout.Height(62)});
									
									if (GUILayout.Button(brushPresets[i].texture, new GUILayoutOption[]{GUILayout.Width(32), GUILayout.Height(32)})){
										selectedBrushPreset = i;
										SetBrush(i);
									}
									if (brushNames.Length>0) {
										EditorGUILayout.LabelField(brushNames[i], EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[]{GUILayout.Width(50), GUILayout.Height(30)});
									}
									EditorGUILayout.EndVertical();
									if (i%(Screen.width/80)==0 && i>0) {
										EditorGUILayout.EndHorizontal();
										EditorGUILayout.BeginHorizontal();
									}
								}
								EditorGUILayout.EndHorizontal();
								
								
							// List
							} else {
								for (i = 0; i<brushPresets.Length; i++) {
									EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(22));
									EditorGUILayout.BeginHorizontal();
									if (GUILayout.Button(brushNames[i], EditorStyles.label)) {
										selectedBrushPreset = i;
										SetBrush(i);
									}
									EditorGUILayout.Separator();
									if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
										if (EditorUtility.DisplayDialog("Permanently delete this brush?", 
											"The brush "+brushNames[i]+" will be removed, are you sure?", 
											"Yes", 
											"No")) {
												AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(brushPrefabs[i] as UnityEngine.Object));
												LoadBrushes();
											}
									}
									EditorGUILayout.EndHorizontal();
									EditorGUILayout.EndVertical();
								}
							}
							
							// Create new brush
							if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
								PlaygroundCreateBrushWindowC.ShowWindow();
							}
						}
						
						EditorGUILayout.EndVertical();
						EditorGUILayout.Separator();
						
						GUILayout.BeginHorizontal();
						EditorGUILayout.PrefixLabel("Brush Shape");
						paintTexture = EditorGUILayout.ObjectField(paintTexture, typeof(Texture2D), false) as Texture2D;
						GUILayout.EndHorizontal();
						playgroundParticlesScriptReference.paint.brush.detail = (BRUSHDETAILC)EditorGUILayout.EnumPopup("Detail", playgroundParticlesScriptReference.paint.brush.detail);
						playgroundParticlesScriptReference.paint.brush.scale = EditorGUILayout.Slider("Brush Scale", playgroundParticlesScriptReference.paint.brush.scale, playgroundScriptReference.minimumAllowedBrushScale, playgroundScriptReference.maximumAllowedBrushScale);
						playgroundParticlesScriptReference.paint.brush.distance = EditorGUILayout.FloatField("Brush Distance", playgroundParticlesScriptReference.paint.brush.distance);
						
						if (paintTexture!=null && paintTexture!=playgroundParticlesScriptReference.paint.brush.texture) {
							playgroundParticlesScriptReference.paint.brush.SetTexture(paintTexture as Texture2D);
							selectedBrushPreset = -1;
						}
						
						useBrushColor = EditorGUILayout.Toggle("Use Brush Color", useBrushColor);
					}
					
					
					// Eraser
					if (selectedPaintMode==2) {
						eraserRadius = EditorGUILayout.Slider("Eraser Radius", eraserRadius, playgroundScriptReference.minimumEraserRadius, playgroundScriptReference.maximumEraserRadius);
					}
					
					EditorGUILayout.EndVertical();
					EditorGUILayout.Separator();
					
					if (selectedPaintMode==1 && useBrushColor) GUI.enabled = false;
					paintColor = EditorGUILayout.ColorField("Color", paintColor);
					GUI.enabled = true;
					if (showNoAlphaWarning && !useBrushColor) {
						EditorGUILayout.HelpBox("You have no alpha in the color. No particle positions will be painted.", MessageType.Warning);
					}
					showNoAlphaWarning = (paintColor.a == 0);

					EditorGUILayout.PropertyField(paintCollisionType, new GUIContent("Paint Collision Type"));
					if (paintCollisionType.enumValueIndex==1) {
						GUILayout.BeginHorizontal();
						GUILayout.Space (16);
						GUILayout.Label("Depth");
						EditorGUILayout.Separator();
						float minDepth = playgroundParticlesScriptReference.paint.minDepth;
						float maxDepth = playgroundParticlesScriptReference.paint.maxDepth;
						EditorGUILayout.MinMaxSlider(ref minDepth, ref maxDepth, -playgroundScriptReference.maximumAllowedDepth, playgroundScriptReference.maximumAllowedDepth, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
						playgroundParticlesScriptReference.paint.minDepth = minDepth;
						playgroundParticlesScriptReference.paint.maxDepth = maxDepth;
						playgroundParticlesScriptReference.paint.minDepth = EditorGUILayout.FloatField(playgroundParticlesScriptReference.paint.minDepth, GUILayout.Width(50));
						playgroundParticlesScriptReference.paint.maxDepth = EditorGUILayout.FloatField(playgroundParticlesScriptReference.paint.maxDepth, GUILayout.Width(50));
						GUILayout.EndHorizontal();
					}
					EditorGUILayout.PropertyField(paintLayerMask, new GUIContent("Paint Mask"));
					playgroundParticlesScriptReference.paint.spacing = EditorGUILayout.Slider("Paint Spacing", playgroundParticlesScriptReference.paint.spacing, .0f, playgroundScriptReference.maximumAllowedPaintSpacing);
					PlaygroundC.reference.paintMaxPositions = EditorGUILayout.IntSlider("Max Paint Positions", PlaygroundC.reference.paintMaxPositions, 0, playgroundScriptReference.maximumAllowedPaintPositions);
					playgroundParticlesScriptReference.paint.exceedMaxStopsPaint = EditorGUILayout.Toggle("Exceed Max Stops Paint", playgroundParticlesScriptReference.paint.exceedMaxStopsPaint);
					if (playgroundParticlesScriptReference.paint.exceedMaxStopsPaint && playgroundParticlesScriptReference.paint.positionLength>=PlaygroundC.reference.paintMaxPositions) {
						EditorGUILayout.HelpBox("You have exceeded max positions. No new paint positions are possible when Exceed Max Stops Paint is enabled.", MessageType.Warning);
					}
					
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Paint:");
					ProgressBar((playgroundParticlesScriptReference.paint.positionLength*1f)/PlaygroundC.reference.paintMaxPositions, playgroundParticlesScriptReference.paint.positionLength+"/"+PlaygroundC.reference.paintMaxPositions, Mathf.FloorToInt(Screen.width/2.2f)-65);
					EditorGUILayout.Separator();
					if(GUILayout.Button("Set Particle Count", EditorStyles.toolbarButton)){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.paint.positionLength);
						playgroundParticlesScriptReference.Start();
					}
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
						particleCount.intValue = particleCount.intValue+playgroundParticlesScriptReference.paint.positionLength;
					GUILayout.EndHorizontal();
					
					EditorGUILayout.Separator();
					
					GUILayout.BeginHorizontal();
					GUI.enabled = !(selectedPaintMode==1 && paintTexture==null);
					if (GUILayout.Button((inPaintMode?"Stop":"Start")+" Paint ", EditorStyles.toolbarButton, GUILayout.Width(80))){
						StartStopPaint();
					}
					
					GUI.enabled = (playgroundParticlesScriptReference.paint.positionLength>0);
					if(GUILayout.Button("Clear", EditorStyles.toolbarButton, GUILayout.Width(50))){
						ClearPaint();
					}
					GUI.enabled = true;
					GUILayout.EndHorizontal();
					EditorGUILayout.Separator();
					
					if (playgroundParticlesScriptReference.paint.positionLength-1>playgroundParticlesScriptReference.particleCount)
						EditorGUILayout.HelpBox("You have more paint positions than particles. Increase Particle Count to see all painted positions.", MessageType.Warning);
					
					if (GUI.changed) {
						SetBrushStyle();
					}
					
				}
				EditorGUILayout.Separator();
				
			}
			
			// Particle Settings
			if (GUILayout.Button("Particle Settings ("+playgroundParticlesScriptReference.particleCount+")", EditorStyles.toolbarDropDown)) particleSettingsFoldout=!particleSettingsFoldout;
			if (particleSettingsFoldout) {
				
				EditorGUILayout.Separator();
				
				if (source.intValue==4)
					EditorGUILayout.HelpBox("Some features are inactivated as this Particle Playground System is running in script mode.", MessageType.Info);
				
				GUILayout.BeginHorizontal();
				particleCount.intValue = EditorGUILayout.IntSlider("Particle Count", particleCount.intValue, 0, playgroundScriptReference.maximumAllowedParticles);
				if(GUILayout.Button("x2", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
					particleCount.intValue *= 2;
				GUILayout.EndHorizontal();
				
				GUI.enabled=(source.intValue!=4);
				emissionRate.floatValue = EditorGUILayout.Slider("Emisson Rate", emissionRate.floatValue, 0, 1f);
				GUI.enabled=(source.intValue!=4);
				EditorGUILayout.Separator();

				EditorGUILayout.PropertyField(overflowMode, new GUIContent(
					"Overflow Mode", 
					"The method to align the Overflow Offset by.")
				);
				overflowOffset.vector3Value = EditorGUILayout.Vector3Field("Overflow Offset", overflowOffset.vector3Value);

				EditorGUILayout.Separator();
				GUI.enabled=true;
				
				// Source Scattering
				GUI.enabled=(source.intValue!=4);
				bool prevScatterEnabled = playgroundParticlesScriptReference.applySourceScatter;
				Vector3 prevScatterMin = playgroundParticlesScriptReference.sourceScatterMin;
				Vector3 prevScatterMax = playgroundParticlesScriptReference.sourceScatterMax;
				playgroundParticlesScriptReference.applySourceScatter = EditorGUILayout.ToggleLeft("Source Scatter", playgroundParticlesScriptReference.applySourceScatter);
				GUI.enabled = (source.intValue!=4 && playgroundParticlesScriptReference.applySourceScatter);
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("X", GUILayout.Width(50));
					EditorGUILayout.Separator();
					float sourceScatterMinX = playgroundParticlesScriptReference.sourceScatterMin.x;
					float sourceScatterMaxX = playgroundParticlesScriptReference.sourceScatterMax.x;
					EditorGUILayout.MinMaxSlider(ref sourceScatterMinX, ref sourceScatterMaxX, -playgroundScriptReference.maximumAllowedSourceScatter, playgroundScriptReference.maximumAllowedSourceScatter, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.sourceScatterMin.x = sourceScatterMinX;
					playgroundParticlesScriptReference.sourceScatterMax.x = sourceScatterMaxX;
					playgroundParticlesScriptReference.sourceScatterMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.sourceScatterMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Y
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Y");
					EditorGUILayout.Separator();
					float sourceScatterMinY = playgroundParticlesScriptReference.sourceScatterMin.y;
					float sourceScatterMaxY = playgroundParticlesScriptReference.sourceScatterMax.y;
					EditorGUILayout.MinMaxSlider(ref sourceScatterMinY, ref sourceScatterMaxY, -playgroundScriptReference.maximumAllowedSourceScatter, playgroundScriptReference.maximumAllowedSourceScatter, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.sourceScatterMin.y = sourceScatterMinY;
					playgroundParticlesScriptReference.sourceScatterMax.y = sourceScatterMaxY;
					playgroundParticlesScriptReference.sourceScatterMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.y, GUILayout.Width(50));
					playgroundParticlesScriptReference.sourceScatterMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.y, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Z
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Z");
					EditorGUILayout.Separator();
					float sourceScatterMinZ = playgroundParticlesScriptReference.sourceScatterMin.z;
					float sourceScatterMaxZ = playgroundParticlesScriptReference.sourceScatterMax.z;
					EditorGUILayout.MinMaxSlider(ref sourceScatterMinZ, ref sourceScatterMaxZ, -playgroundScriptReference.maximumAllowedSourceScatter, playgroundScriptReference.maximumAllowedSourceScatter, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.sourceScatterMin.z = sourceScatterMinZ;
					playgroundParticlesScriptReference.sourceScatterMax.z = sourceScatterMaxZ;
					playgroundParticlesScriptReference.sourceScatterMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.z, GUILayout.Width(50));
					playgroundParticlesScriptReference.sourceScatterMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.z, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					

				GUI.enabled = true;
				
				if (prevScatterEnabled!=playgroundParticlesScriptReference.applySourceScatter || prevScatterMin!=playgroundParticlesScriptReference.sourceScatterMin || prevScatterMax!=playgroundParticlesScriptReference.sourceScatterMax) {
					LifetimeSorting();
					playgroundParticlesScriptReference.RefreshScatter();
				}
				
				EditorGUILayout.Separator();
				
				// Emission
				bool prevEmit = playgroundParticlesScriptReference.emit;
				bool prevLoop = playgroundParticlesScriptReference.loop;
				playgroundParticlesScriptReference.emit = EditorGUILayout.Toggle("Emit Particles", playgroundParticlesScriptReference.emit);
				playgroundParticlesScriptReference.loop = EditorGUILayout.Toggle("Loop", playgroundParticlesScriptReference.loop);
				if (prevEmit!=playgroundParticlesScriptReference.emit || prevLoop!=playgroundParticlesScriptReference.loop&&playgroundParticlesScriptReference.loop) {
					playgroundParticlesScriptReference.simulationStarted = PlaygroundC.globalTime;
					playgroundParticlesScriptReference.loopExceeded = false;
					playgroundParticlesScriptReference.loopExceededOnParticle = -1;
					playgroundParticlesScriptReference.particleSystemGameObject.SetActive(true);
				}
				GUI.enabled = !loop.boolValue;
				disableOnDone.boolValue = EditorGUILayout.Toggle("Disable On Done", disableOnDone.boolValue);
				GUI.enabled = true;
				//calculate.boolValue = EditorGUILayout.Toggle("Calculate Particles", calculate.boolValue);
				
				EditorGUILayout.Separator();
				
				GUILayout.BeginHorizontal();
				GUILayout.Label("Size");
				EditorGUILayout.Separator();
				float sizeMin = playgroundParticlesScriptReference.sizeMin;
				float sizeMax = playgroundParticlesScriptReference.sizeMax;
				EditorGUILayout.MinMaxSlider(ref sizeMin, ref sizeMax, 0, playgroundScriptReference.maximumAllowedSize, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.sizeMin = sizeMin;
				playgroundParticlesScriptReference.sizeMax = sizeMax;
				playgroundParticlesScriptReference.sizeMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sizeMin, GUILayout.Width(50));
				playgroundParticlesScriptReference.sizeMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sizeMax, GUILayout.Width(50));
				GUILayout.EndHorizontal();

				playgroundParticlesScriptReference.scale = EditorGUILayout.Slider("Scale", playgroundParticlesScriptReference.scale, 0, playgroundScriptReference.maximumAllowedScale);
				EditorGUILayout.BeginHorizontal();
				playgroundParticlesScriptReference.applyLifetimeSize = EditorGUILayout.ToggleLeft ("Lifetime Size", playgroundParticlesScriptReference.applyLifetimeSize, GUILayout.Width (120));
				GUILayout.FlexibleSpace();
				GUI.enabled = playgroundParticlesScriptReference.applyLifetimeSize;
				lifetimeSize.animationCurveValue = EditorGUILayout.CurveField(lifetimeSize.animationCurveValue);
				GUI.enabled = true;
				EditorGUILayout.EndHorizontal();

				EditorGUILayout.Separator();
				
				GUILayout.BeginHorizontal();
				GUILayout.Label("Inital Rotation");
				EditorGUILayout.Separator();
				float initialRotationMin = playgroundParticlesScriptReference.initialRotationMin;
				float initialRotationMax = playgroundParticlesScriptReference.initialRotationMax;
				EditorGUILayout.MinMaxSlider(ref initialRotationMin, ref initialRotationMax, -playgroundScriptReference.maximumAllowedRotation, playgroundScriptReference.maximumAllowedRotation, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.initialRotationMin = initialRotationMin;
				playgroundParticlesScriptReference.initialRotationMax = initialRotationMax;
				playgroundParticlesScriptReference.initialRotationMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialRotationMin, GUILayout.Width(50));
				playgroundParticlesScriptReference.initialRotationMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialRotationMax, GUILayout.Width(50));
				GUILayout.EndHorizontal();
				
				GUI.enabled = !playgroundParticlesScriptReference.rotateTowardsDirection;
				GUILayout.BeginHorizontal();
				GUILayout.Label("Rotation");
				EditorGUILayout.Separator();
				float rotationSpeedMin = playgroundParticlesScriptReference.rotationSpeedMin;
				float rotationSpeedMax = playgroundParticlesScriptReference.rotationSpeedMax;
				EditorGUILayout.MinMaxSlider(ref rotationSpeedMin, ref rotationSpeedMax, -playgroundScriptReference.maximumAllowedRotation, playgroundScriptReference.maximumAllowedRotation, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.rotationSpeedMin = rotationSpeedMin;
				playgroundParticlesScriptReference.rotationSpeedMax = rotationSpeedMax;
				playgroundParticlesScriptReference.rotationSpeedMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.rotationSpeedMin, GUILayout.Width(50));
				playgroundParticlesScriptReference.rotationSpeedMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.rotationSpeedMax, GUILayout.Width(50));

				GUILayout.EndHorizontal();
				
				GUI.enabled = true;
				
				playgroundParticlesScriptReference.rotateTowardsDirection = EditorGUILayout.Toggle("Rotate Towards Direction", playgroundParticlesScriptReference.rotateTowardsDirection);
				GUI.enabled = playgroundParticlesScriptReference.rotateTowardsDirection;
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.rotationNormal = EditorGUILayout.Vector3Field("Rotation Normal", playgroundParticlesScriptReference.rotationNormal);
					playgroundParticlesScriptReference.rotationNormal.x = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.x, -1, 1);
					playgroundParticlesScriptReference.rotationNormal.y = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.y, -1, 1);
					playgroundParticlesScriptReference.rotationNormal.z = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.z, -1, 1);
					EditorGUI.indentLevel--;
				
				GUI.enabled = true;
				
				EditorGUILayout.Separator();
				
				lifetime.floatValue = EditorGUILayout.Slider("Lifetime", lifetime.floatValue, 0, playgroundScriptReference.maximumAllowedLifetime);

				// Sorting
				GUI.enabled=(source.intValue!=4);
				if (selectedSort!=sorting.intValue || selectedOrigin!=nearestNeighborOrigin.intValue) {
					LifetimeSorting();
					playgroundParticles.ApplyModifiedProperties();
				}
				selectedSort = sorting.intValue;
				selectedOrigin = nearestNeighborOrigin.intValue;
				EditorGUILayout.PropertyField(sorting, new GUIContent(
					"Lifetime Sorting", 
					"Determines how the particles are ordered on rebirth.\nScrambled: Randomly placed.\nScrambled Linear: Randomly placed but never at the same time.\nBurst: Alfa and Omega.\nLinear: Alfa to Omega.\nReversed: Omega to Alfa.")
				);
				
				if (sorting.intValue==5||sorting.intValue==6) {
					EditorGUI.indentLevel++;
					nearestNeighborOrigin.intValue = EditorGUILayout.IntSlider("Sort Origin", nearestNeighborOrigin.intValue, 0, playgroundParticlesScriptReference.particleCount>0?playgroundParticlesScriptReference.particleCount-1:0);
					EditorGUI.indentLevel--;
				}
				
				// Custom lifetime sorting
				if (sorting.intValue==7) {
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.lifetimeSorting = EditorGUILayout.CurveField("Custom Sorting", playgroundParticlesScriptReference.lifetimeSorting);
					EditorGUI.indentLevel--;
					bool changed = prevLifetimeSortingKeys.Length!=playgroundParticlesScriptReference.lifetimeSorting.keys.Length;
					if (!changed)
						for (int k = 0; k<prevLifetimeSortingKeys.Length; k++) {
							if (playgroundParticlesScriptReference.lifetimeSorting.keys[k].value != prevLifetimeSortingKeys[k].value || playgroundParticlesScriptReference.lifetimeSorting.keys[k].time != prevLifetimeSortingKeys[k].time) {
								changed = true;
							}
						}
					if (changed) {
						LifetimeSorting();
						prevLifetimeSortingKeys = playgroundParticlesScriptReference.lifetimeSorting.keys;
					}
				}
				
				float prevLifetimeOffset = playgroundParticlesScriptReference.lifetimeOffset;
				playgroundParticlesScriptReference.lifetimeOffset = EditorGUILayout.Slider("Lifetime Offset", playgroundParticlesScriptReference.lifetimeOffset, -playgroundParticlesScriptReference.lifetime, playgroundParticlesScriptReference.lifetime);
				if (prevLifetimeOffset!=playgroundParticlesScriptReference.lifetimeOffset) {
					LifetimeSortingAll();
				}
				GUI.enabled = true;
				
				EditorGUILayout.Separator();

				playgroundParticlesScriptReference.particleMask = EditorGUILayout.IntSlider("Particle Mask", playgroundParticlesScriptReference.particleMask, 0, particleCount.intValue);
				playgroundParticlesScriptReference.particleMaskTime = EditorGUILayout.Slider("Mask Time", playgroundParticlesScriptReference.particleMaskTime, 0, PlaygroundC.reference.maximumAllowedTransitionTime);

				EditorGUILayout.Separator();
			}
						
			// Force Settings
			if (GUILayout.Button(onlySourcePositioning.boolValue||(playgroundParticlesScriptReference.axisConstraints.x&&playgroundParticlesScriptReference.axisConstraints.y&&playgroundParticlesScriptReference.axisConstraints.z)?"Forces (Off)":playgroundParticlesScriptReference.turbulenceType==TURBULENCETYPE.None?"Forces":"Forces (Turbulence)", EditorStyles.toolbarDropDown)) forcesFoldout=!forcesFoldout;
			if (forcesFoldout) {
				
				EditorGUILayout.Separator();
				
				onlySourcePositioning.boolValue = EditorGUILayout.Toggle("Only Source Positions", onlySourcePositioning.boolValue);
				if (onlySourcePositioning.boolValue)
					EditorGUILayout.HelpBox("Particles are bound to their source position during their lifetime.", MessageType.Info);
				
				EditorGUILayout.Separator();
				
				GUI.enabled = !onlySourcePositioning.boolValue;
				
				// Delta Movement
				if (playgroundParticlesScriptReference.source==SOURCEC.State && playgroundParticlesScriptReference.states!=null && playgroundParticlesScriptReference.states.Count>0 && playgroundParticlesScriptReference.states[playgroundParticlesScriptReference.activeState].stateTransform==null) {
					EditorGUILayout.HelpBox("Assign a transform to the active state to enable Delta Movement.", MessageType.Info);
					GUI.enabled = false;
				} else GUI.enabled = (source.intValue!=4 && !onlySourcePositioning.boolValue);
					playgroundParticlesScriptReference.calculateDeltaMovement = EditorGUILayout.ToggleLeft("Delta Movement", playgroundParticlesScriptReference.calculateDeltaMovement);
				GUI.enabled = (GUI.enabled && playgroundParticlesScriptReference.calculateDeltaMovement && !onlySourcePositioning.boolValue);
					EditorGUI.indentLevel++;
					deltaMovementStrength.floatValue = EditorGUILayout.Slider("Delta Movement Strength", deltaMovementStrength.floatValue, 0, playgroundScriptReference.maximumAllowedDeltaMovementStrength);
					EditorGUI.indentLevel--;
				GUI.enabled = !onlySourcePositioning.boolValue;
				EditorGUILayout.Separator();
				
				// Lifetime velocity
				applyLifetimeVelocity.boolValue = EditorGUILayout.ToggleLeft("Lifetime Velocity", applyLifetimeVelocity.boolValue);
				GUI.enabled = (applyLifetimeVelocity.boolValue&&!onlySourcePositioning.boolValue);
				EditorGUI.indentLevel++;
				lifeTimeVelocityX.animationCurveValue = EditorGUILayout.CurveField("X", lifeTimeVelocityX.animationCurveValue);
				lifeTimeVelocityY.animationCurveValue = EditorGUILayout.CurveField("Y", lifeTimeVelocityY.animationCurveValue);
				lifeTimeVelocityZ.animationCurveValue = EditorGUILayout.CurveField("Z", lifeTimeVelocityZ.animationCurveValue);
				EditorGUI.indentLevel--;
				GUI.enabled = !onlySourcePositioning.boolValue;
				EditorGUILayout.Separator();
				
				// Initial Velocity
				EditorGUILayout.Separator();
				applyInitialVelocity.boolValue = EditorGUILayout.ToggleLeft("Initial Velocity", applyInitialVelocity.boolValue);
				GUI.enabled = (applyInitialVelocity.boolValue&&!onlySourcePositioning.boolValue);
					
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("X", GUILayout.Width(50));
					EditorGUILayout.Separator();
					float initialVelocityMinX = playgroundParticlesScriptReference.initialVelocityMin.x;
					float initialVelocityMaxX = playgroundParticlesScriptReference.initialVelocityMax.x;
					EditorGUILayout.MinMaxSlider(ref initialVelocityMinX, ref initialVelocityMaxX, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialVelocityMin.x = initialVelocityMinX;
					playgroundParticlesScriptReference.initialVelocityMax.x = initialVelocityMaxX;
					playgroundParticlesScriptReference.initialVelocityMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialVelocityMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Y
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Y");
					EditorGUILayout.Separator();
					float initialVelocityMinY = playgroundParticlesScriptReference.initialVelocityMin.y;
					float initialVelocityMaxY = playgroundParticlesScriptReference.initialVelocityMax.y;
					EditorGUILayout.MinMaxSlider(ref initialVelocityMinY, ref initialVelocityMaxY, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialVelocityMin.y = initialVelocityMinY;
					playgroundParticlesScriptReference.initialVelocityMax.y = initialVelocityMaxY;
					playgroundParticlesScriptReference.initialVelocityMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.y, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialVelocityMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.y, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Z
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Z");
					EditorGUILayout.Separator();
					float initialVelocityMinZ = playgroundParticlesScriptReference.initialVelocityMin.z;
					float initialVelocityMaxZ = playgroundParticlesScriptReference.initialVelocityMax.z;
					EditorGUILayout.MinMaxSlider(ref initialVelocityMinZ, ref initialVelocityMaxZ, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialVelocityMin.z = initialVelocityMinZ;
					playgroundParticlesScriptReference.initialVelocityMax.z = initialVelocityMaxZ;
					playgroundParticlesScriptReference.initialVelocityMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.z, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialVelocityMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.z, GUILayout.Width(50));
					GUILayout.EndHorizontal();

				GUI.enabled = !onlySourcePositioning.boolValue;
				
				// Initial Local Velocity
				EditorGUILayout.Separator();
				GUI.enabled=(source.intValue!=4 && !onlySourcePositioning.boolValue);
				
				if (source.intValue==4) {
					GUI.enabled = true;
					EditorGUILayout.HelpBox("Initial Local Velocity is controlled by passed in velocity to Emit() in script mode.", MessageType.Info);
					GUI.enabled = false;
				}
				applyInitialLocalVelocity.boolValue = EditorGUILayout.ToggleLeft("Initial Local Velocity", applyInitialLocalVelocity.boolValue);
				if (playgroundParticlesScriptReference.source==SOURCEC.State && playgroundParticlesScriptReference.states!=null && playgroundParticlesScriptReference.states.Count>0 && playgroundParticlesScriptReference.states[playgroundParticlesScriptReference.activeState].stateTransform==null) {
					EditorGUILayout.HelpBox("Assign a transform to the active state to enable Initial Local Velocity.", MessageType.Info);
					GUI.enabled = false;
				} else GUI.enabled = (applyInitialLocalVelocity.boolValue&&!onlySourcePositioning.boolValue&&source.intValue!=4);
					
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("X", GUILayout.Width(50));
					EditorGUILayout.Separator();
					float initialLocalVelocityMinX = playgroundParticlesScriptReference.initialLocalVelocityMin.x;
					float initialLocalVelocityMaxX = playgroundParticlesScriptReference.initialLocalVelocityMax.x;
					EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinX, ref initialLocalVelocityMaxX, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialLocalVelocityMin.x = initialLocalVelocityMinX;
					playgroundParticlesScriptReference.initialLocalVelocityMax.x = initialLocalVelocityMaxX;
					playgroundParticlesScriptReference.initialLocalVelocityMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialLocalVelocityMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Y
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Y");
					EditorGUILayout.Separator();
					float initialLocalVelocityMinY = playgroundParticlesScriptReference.initialLocalVelocityMin.y;
					float initialLocalVelocityMaxY = playgroundParticlesScriptReference.initialLocalVelocityMax.y;
					EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinY, ref initialLocalVelocityMaxY, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialLocalVelocityMin.y = initialLocalVelocityMinY;
					playgroundParticlesScriptReference.initialLocalVelocityMax.y = initialLocalVelocityMaxY;
					playgroundParticlesScriptReference.initialLocalVelocityMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.y, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialLocalVelocityMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.y, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Z
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Z");
					EditorGUILayout.Separator();
					float initialLocalVelocityMinZ = playgroundParticlesScriptReference.initialLocalVelocityMin.z;
					float initialLocalVelocityMaxZ = playgroundParticlesScriptReference.initialLocalVelocityMax.z;
					EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinZ, ref initialLocalVelocityMaxZ, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialLocalVelocityMin.z = initialLocalVelocityMinZ;
					playgroundParticlesScriptReference.initialLocalVelocityMax.z = initialLocalVelocityMaxZ;
					playgroundParticlesScriptReference.initialLocalVelocityMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.z, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialLocalVelocityMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.z, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					
				EditorGUILayout.Separator();
				GUI.enabled = !onlySourcePositioning.boolValue;
				
				// Initial velocity shape
				playgroundParticlesScriptReference.applyInitialVelocityShape = EditorGUILayout.ToggleLeft("Initial Velocity Shape", playgroundParticlesScriptReference.applyInitialVelocityShape);
				GUI.enabled = (playgroundParticlesScriptReference.applyInitialVelocityShape&&!onlySourcePositioning.boolValue);
				EditorGUI.indentLevel++;
				initialVelocityShapeX.animationCurveValue = EditorGUILayout.CurveField("X", initialVelocityShapeX.animationCurveValue);
				initialVelocityShapeY.animationCurveValue = EditorGUILayout.CurveField("Y", initialVelocityShapeY.animationCurveValue);
				initialVelocityShapeZ.animationCurveValue = EditorGUILayout.CurveField("Z", initialVelocityShapeZ.animationCurveValue);
				EditorGUI.indentLevel--;
				GUI.enabled = !onlySourcePositioning.boolValue;
				
				// Velocity Bending
				EditorGUILayout.Separator();
				applyVelocityBending.boolValue = EditorGUILayout.ToggleLeft("Velocity Bending", applyVelocityBending.boolValue);
				GUI.enabled = (applyVelocityBending.boolValue&&!onlySourcePositioning.boolValue);
					EditorGUI.indentLevel++;
					EditorGUILayout.PropertyField (velocityBendingType, new GUIContent("Type"));
					playgroundParticlesScriptReference.velocityBending = EditorGUILayout.Vector3Field("", playgroundParticlesScriptReference.velocityBending);
					EditorGUI.indentLevel--;
				EditorGUILayout.Separator();
				GUI.enabled = !onlySourcePositioning.boolValue;

				// Turbulence
				playgroundParticlesScriptReference.turbulenceType = (TURBULENCETYPE)EditorGUILayout.EnumPopup("Turbulence", playgroundParticlesScriptReference.turbulenceType);
				GUI.enabled = (playgroundParticlesScriptReference.turbulenceType!=TURBULENCETYPE.None && !onlySourcePositioning.boolValue);
				EditorGUI.indentLevel++;
				playgroundParticlesScriptReference.turbulenceStrength = EditorGUILayout.Slider("Strength", playgroundParticlesScriptReference.turbulenceStrength, 0f, playgroundScriptReference.maximumAllowedTurbulenceStrength);
				playgroundParticlesScriptReference.turbulenceScale = EditorGUILayout.Slider("Scale", playgroundParticlesScriptReference.turbulenceScale, 0f, playgroundScriptReference.maximumAllowedTurbulenceScale);
				playgroundParticlesScriptReference.turbulenceTimeScale = EditorGUILayout.Slider("Time Scale", playgroundParticlesScriptReference.turbulenceTimeScale, 0f, playgroundScriptReference.maximumAllowedTurbulenceTimeScale);
				EditorGUILayout.BeginHorizontal();
				playgroundParticlesScriptReference.turbulenceApplyLifetimeStrength = EditorGUILayout.ToggleLeft ("Lifetime Strength", playgroundParticlesScriptReference.turbulenceApplyLifetimeStrength, GUILayout.Width (140));
				GUILayout.FlexibleSpace();
				GUI.enabled = (playgroundParticlesScriptReference.turbulenceApplyLifetimeStrength && playgroundParticlesScriptReference.turbulenceType!=TURBULENCETYPE.None && !onlySourcePositioning.boolValue);
				turbulenceLifetimeStrength.animationCurveValue = EditorGUILayout.CurveField(turbulenceLifetimeStrength.animationCurveValue);
				EditorGUILayout.EndHorizontal();
				EditorGUI.indentLevel--;
				GUI.enabled = !onlySourcePositioning.boolValue;
				EditorGUILayout.Separator();

				playgroundParticlesScriptReference.gravity = EditorGUILayout.Vector3Field("Gravity", playgroundParticlesScriptReference.gravity);
				playgroundParticlesScriptReference.damping = EditorGUILayout.Slider("Damping", playgroundParticlesScriptReference.damping, 0f, playgroundScriptReference.maximumAllowedDamping);
				playgroundParticlesScriptReference.maxVelocity = EditorGUILayout.Slider("Max Velocity", playgroundParticlesScriptReference.maxVelocity, 0, playgroundScriptReference.maximumAllowedVelocity);
				
				// Axis constraints
				GUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("Axis Constraints", GUILayout.Width(Mathf.FloorToInt(Screen.width/2.2f)-46));
				
				GUILayout.Label("X", GUILayout.Width(10));
				playgroundParticlesScriptReference.axisConstraints.x = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.x, GUILayout.Width(16));
				GUILayout.Label("Y", GUILayout.Width(10));
				playgroundParticlesScriptReference.axisConstraints.y = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.y, GUILayout.Width(16));
				GUILayout.Label("Z", GUILayout.Width(10));
				playgroundParticlesScriptReference.axisConstraints.z = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.z, GUILayout.Width(16));
				GUILayout.EndHorizontal();
				GUI.enabled = true;
				
				EditorGUILayout.Separator();
		
			}

			// Collision Settings
			if (GUILayout.Button(collision.boolValue?collisionType.intValue==0?"Collision (3d)":"Collision (2d)":"Collision (Off)", EditorStyles.toolbarDropDown)) collisionFoldout=!collisionFoldout;
			if (collisionFoldout) {
				
				EditorGUILayout.Separator();
				
				collision.boolValue = EditorGUILayout.ToggleLeft("Collision", collision.boolValue);
				EditorGUI.indentLevel++;
				GUI.enabled = collision.boolValue;
				EditorGUILayout.PropertyField(collisionType, new GUIContent("Collision Type"));
				if (collisionType.enumValueIndex==1) {
					GUILayout.BeginHorizontal();
					GUILayout.Space (16);
					GUILayout.Label("Depth");
					EditorGUILayout.Separator();
					float minDepth = playgroundParticlesScriptReference.minCollisionDepth;
					float maxDepth = playgroundParticlesScriptReference.maxCollisionDepth;
					EditorGUILayout.MinMaxSlider(ref minDepth, ref maxDepth, -playgroundScriptReference.maximumAllowedDepth, playgroundScriptReference.maximumAllowedDepth, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.minCollisionDepth = minDepth;
					playgroundParticlesScriptReference.maxCollisionDepth = maxDepth;
					playgroundParticlesScriptReference.minCollisionDepth = EditorGUILayout.FloatField(playgroundParticlesScriptReference.minCollisionDepth, GUILayout.Width(50));
					playgroundParticlesScriptReference.maxCollisionDepth = EditorGUILayout.FloatField(playgroundParticlesScriptReference.maxCollisionDepth, GUILayout.Width(50));
					GUILayout.EndHorizontal();
				}
				EditorGUILayout.PropertyField(collisionMask, new GUIContent("Collision Mask"));
				affectRigidbodies.boolValue = EditorGUILayout.Toggle("Collide With Rigidbodies", affectRigidbodies.boolValue);
				mass.floatValue = EditorGUILayout.Slider("Mass", mass.floatValue, 0, playgroundScriptReference.maximumAllowedMass);
				collisionRadius.floatValue = EditorGUILayout.Slider("Collision Radius", collisionRadius.floatValue, 0, playgroundScriptReference.maximumAllowedCollisionRadius);
				playgroundParticlesScriptReference.lifetimeLoss = EditorGUILayout.Slider("Lifetime Loss", playgroundParticlesScriptReference.lifetimeLoss, 0f, 1f);
				
				EditorGUILayout.Separator();
				bounciness.floatValue = EditorGUILayout.Slider("Bounciness", bounciness.floatValue, 0, playgroundScriptReference.maximumAllowedBounciness);
				EditorGUILayout.PrefixLabel("Random Bounce");
				// X
				GUILayout.BeginHorizontal();
				GUILayout.Space(32);
				GUILayout.Label("X", GUILayout.Width(50));
				EditorGUILayout.Separator();
				float bounceRandomMinX = playgroundParticlesScriptReference.bounceRandomMin.x;
				float bounceRandomMaxX = playgroundParticlesScriptReference.bounceRandomMax.x;
				EditorGUILayout.MinMaxSlider(ref bounceRandomMinX, ref bounceRandomMaxX, -1f, 1f, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.bounceRandomMin.x = bounceRandomMinX;
				playgroundParticlesScriptReference.bounceRandomMax.x = bounceRandomMaxX;
				playgroundParticlesScriptReference.bounceRandomMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.x, GUILayout.Width(50));
				playgroundParticlesScriptReference.bounceRandomMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.x, GUILayout.Width(50));
				GUILayout.EndHorizontal();
				// Y
				GUILayout.BeginHorizontal();
				GUILayout.Space(32);
				GUILayout.Label("Y");
				EditorGUILayout.Separator();
				float bounceRandomMinY = playgroundParticlesScriptReference.bounceRandomMin.y;
				float bounceRandomMaxY = playgroundParticlesScriptReference.bounceRandomMax.y;
				EditorGUILayout.MinMaxSlider(ref bounceRandomMinY, ref bounceRandomMaxY, -1f, 1f, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.bounceRandomMin.y = bounceRandomMinY;
				playgroundParticlesScriptReference.bounceRandomMax.y = bounceRandomMaxY;
				playgroundParticlesScriptReference.bounceRandomMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.y, GUILayout.Width(50));
				playgroundParticlesScriptReference.bounceRandomMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.y, GUILayout.Width(50));
				GUILayout.EndHorizontal();
				// Z
				GUILayout.BeginHorizontal();
				GUILayout.Space(32);
				GUILayout.Label("Z");
				EditorGUILayout.Separator();
				float bounceRandomMinZ = playgroundParticlesScriptReference.bounceRandomMin.z;
				float bounceRandomMaxZ = playgroundParticlesScriptReference.bounceRandomMax.z;
				EditorGUILayout.MinMaxSlider(ref bounceRandomMinZ, ref bounceRandomMaxZ, -1f, 1f, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.bounceRandomMin.z = bounceRandomMinZ;
				playgroundParticlesScriptReference.bounceRandomMax.z = bounceRandomMaxZ;
				playgroundParticlesScriptReference.bounceRandomMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.z, GUILayout.Width(50));
				playgroundParticlesScriptReference.bounceRandomMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.z, GUILayout.Width(50));
				GUILayout.EndHorizontal();
				
				EditorGUI.indentLevel--;
				EditorGUILayout.Separator();
				
				// Collision planes List
				EditorGUILayout.BeginVertical(boxStyle);
				collisionPlanesFoldout = GUILayout.Toggle(collisionPlanesFoldout, "Collision Planes ("+playgroundParticlesScriptReference.colliders.Count+")", EditorStyles.foldout);
				if (collisionPlanesFoldout) {
					if (playgroundParticlesScriptReference.colliders.Count>0) {
						for (int c = 0; c<playgroundParticlesScriptReference.colliders.Count; c++) {
							EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
							EditorGUILayout.BeginHorizontal();
							
							playgroundParticlesScriptReference.colliders[c].enabled = EditorGUILayout.Toggle("", playgroundParticlesScriptReference.colliders[c].enabled, GUILayout.Width(16));
							GUI.enabled = (playgroundParticlesScriptReference.colliders[c].enabled&&collision.boolValue);
							playgroundParticlesScriptReference.colliders[c].transform = EditorGUILayout.ObjectField("", playgroundParticlesScriptReference.colliders[c].transform, typeof(Transform), true) as Transform;
							playgroundParticlesScriptReference.colliders[c].offset = EditorGUILayout.Vector3Field("", playgroundParticlesScriptReference.colliders[c].offset, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-142));
							GUI.enabled = collision.boolValue;
							
							EditorGUILayout.Separator();
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								playgroundParticlesScriptReference.colliders.RemoveAt(c);
							}
							
							EditorGUILayout.EndHorizontal();
							EditorGUILayout.EndVertical();
						}
					} else {
						EditorGUILayout.HelpBox("No collision planes created.", MessageType.Info);
					}
					
					if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
						playgroundParticlesScriptReference.colliders.Add(new PlaygroundColliderC());
					}
					
					EditorGUILayout.Separator();
					playgroundScriptReference.collisionPlaneScale = EditorGUILayout.Slider("Gizmo Scale", playgroundScriptReference.collisionPlaneScale, 0, 1);
					EditorGUILayout.Separator();
				}
				EditorGUILayout.EndVertical();
				
				GUI.enabled = true;
				
				EditorGUILayout.Separator();
			}
			
			// Render Settings
			if (GUILayout.Button("Rendering ("+playgroundParticlesScriptReference.colorSource+")", EditorStyles.toolbarDropDown)) renderingFoldout=!renderingFoldout;
			if (renderingFoldout) {
				
				EditorGUILayout.Separator();
				
				GUILayout.BeginHorizontal();
				EditorGUILayout.PrefixLabel("Material");
				Material currentMat = particleMaterial as Material;
				particleMaterial = EditorGUILayout.ObjectField(particleMaterial, typeof(Material), false);
				if (currentMat!=particleMaterial) 
					PlaygroundParticlesC.SetMaterial(playgroundParticlesScriptReference, particleMaterial as Material);
				GUILayout.EndHorizontal();
				
				GUILayout.BeginVertical (boxStyle);
				EditorGUILayout.PropertyField(colorSource, new GUIContent("Color Source"));
				switch (playgroundParticlesScriptReference.colorSource) {
				case COLORSOURCEC.Source: 
					EditorGUILayout.PropertyField(lifetimeColor, new GUIContent("Lifetime Color"));
					playgroundParticlesScriptReference.sourceUsesLifetimeAlpha = EditorGUILayout.Toggle("Source Uses Lifetime Alpha", playgroundParticlesScriptReference.sourceUsesLifetimeAlpha);
					break;
				case COLORSOURCEC.LifetimeColor: 
					EditorGUILayout.PropertyField(lifetimeColor, new GUIContent("Lifetime Color")); 
					break;
				case COLORSOURCEC.LifetimeColors:
					
					if (lifetimeColors.arraySize>0) {
						
						SerializedProperty thisLifetimeColor;
						for (int c = 0; c<lifetimeColors.arraySize; c++) {
							thisLifetimeColor = lifetimeColors.GetArrayElementAtIndex(c).FindPropertyRelative("gradient");
							GUILayout.BeginHorizontal(boxStyle);
							EditorGUILayout.PropertyField (thisLifetimeColor);
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})) {
								lifetimeColors.DeleteArrayElementAtIndex(c);
								playgroundParticles.ApplyModifiedProperties();
								
							}
							GUILayout.EndHorizontal();
						}
						
					} else {
						EditorGUILayout.HelpBox("No lifetime colors created.", MessageType.Info);
					}
					if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))) {
						playgroundParticlesScriptReference.lifetimeColors.Add (new PlaygroundGradientC());
						playgroundParticlesScriptReference.lifetimeColors[playgroundParticlesScriptReference.lifetimeColors.Count-1].gradient = new Gradient();
						playgroundParticles.ApplyModifiedProperties();
					}
					break;
				}
				
				GUILayout.EndVertical ();
				
				EditorGUILayout.Separator();
				
				GUILayout.BeginVertical(boxStyle);
				
				// Render mode
				shurikenRenderer.renderMode = (ParticleSystemRenderMode)EditorGUILayout.EnumPopup("Render Mode", shurikenRenderer.renderMode);
				switch (shurikenRenderer.renderMode) {
				case ParticleSystemRenderMode.Stretch:
					EditorGUI.indentLevel++;
					shurikenRenderer.cameraVelocityScale = EditorGUILayout.Slider("Camera Scale", shurikenRenderer.cameraVelocityScale, -playgroundScriptReference.maximumRenderSliders, playgroundScriptReference.maximumRenderSliders);
					shurikenRenderer.velocityScale = EditorGUILayout.Slider("Speed Scale", shurikenRenderer.velocityScale, -playgroundScriptReference.maximumRenderSliders, playgroundScriptReference.maximumRenderSliders);
					shurikenRenderer.lengthScale = EditorGUILayout.Slider("Length Scale", shurikenRenderer.lengthScale, -playgroundScriptReference.maximumRenderSliders, playgroundScriptReference.maximumRenderSliders);
					playgroundParticlesScriptReference.stretchSpeed = EditorGUILayout.Slider("Stretch Speed", playgroundParticlesScriptReference.stretchSpeed, .1f, playgroundScriptReference.maximumAllowedStretchSpeed);
					playgroundParticlesScriptReference.stretchStartDirection = EditorGUILayout.Vector3Field ("Start Stretch", playgroundParticlesScriptReference.stretchStartDirection);
					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.applyLifetimeStretching = EditorGUILayout.ToggleLeft ("Lifetime Stretch", playgroundParticlesScriptReference.applyLifetimeStretching, GUILayout.Width (140));
					GUILayout.FlexibleSpace();
					GUI.enabled = (playgroundParticlesScriptReference.applyLifetimeStretching);
					lifetimeStretching.animationCurveValue = EditorGUILayout.CurveField(lifetimeStretching.animationCurveValue);
					EditorGUILayout.EndHorizontal();
					EditorGUI.indentLevel--;
					break;
				case ParticleSystemRenderMode.Mesh:
					shurikenRenderer.mesh = EditorGUILayout.ObjectField(shurikenRenderer.mesh, typeof(Mesh), false) as Mesh;
					GUI.enabled = false;
					break;
				}
				GUI.enabled = true;
				shurikenRenderer.maxParticleSize = EditorGUILayout.Slider("Max Particle Size", shurikenRenderer.maxParticleSize, 0f, 1f);

				GUILayout.EndVertical();
				
				// Sort order/layer
				/*
				GUILayout.BeginVertical(boxStyle);
				playgroundParticlesScriptReference.particleSystemRenderer.sortingOrder = EditorGUILayout.IntField("Sorting Order", playgroundParticlesScriptReference.particleSystemRenderer.sortingOrder);
				playgroundParticlesScriptReference.particleSystemRenderer.sortingLayerName = EditorGUILayout.TextField("Sorting Layer Name", playgroundParticlesScriptReference.particleSystemRenderer.sortingLayerName);
				GUILayout.EndVertical();
				*/
				EditorGUILayout.Separator();
			}
			
			// Manipulators Settings
			if (GUILayout.Button("Manipulators ("+playgroundParticlesScriptReference.manipulators.Count+")", EditorStyles.toolbarDropDown)) manipulatorsFoldout=!manipulatorsFoldout;
			if (manipulatorsFoldout) {
				
				EditorGUILayout.Separator();
				
				if (playgroundParticlesScriptReference.manipulators.Count>0) {
					string mName;	
					for (int i = 0; i<playgroundParticlesScriptReference.manipulators.Count; i++) {
						if (!playgroundParticlesScriptReference.manipulators[i].enabled)
							GUI.contentColor = Color.gray;
						if (playgroundParticlesScriptReference.manipulators[i].transform.available) {
							mName = playgroundParticlesScriptReference.manipulators[i].transform.transform.name;
							if (mName.Length>24)
								mName = mName.Substring(0, 24)+"...";
						} else {
							GUI.color = Color.red;
							mName = "(Missing Transform!)";
						}
						EditorGUILayout.BeginVertical("box");
						
						EditorGUILayout.BeginHorizontal();
						
						GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
						manipulatorListFoldout[i] = GUILayout.Toggle(manipulatorListFoldout[i], PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type), EditorStyles.foldout, GUILayout.Width(Screen.width/4));
						if (playgroundParticlesScriptReference.manipulators[i].transform.available) {
							if (GUILayout.Button(" ("+mName+")", EditorStyles.label)) {
								Selection.activeGameObject = playgroundParticlesScriptReference.manipulators[i].transform.transform.gameObject;
							}
						} else {
							GUILayout.Button(PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type)+" (Missing Transform!)", EditorStyles.label);
						}
						GUI.contentColor = Color.white;
						EditorGUILayout.Separator();
						GUI.enabled = (playgroundParticlesScriptReference.manipulators.Count>1);
						if(GUILayout.Button("U", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							manipulators.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.manipulators.Count-1:i-1);
						}
						if(GUILayout.Button("D", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							manipulators.MoveArrayElement(i, i<playgroundParticlesScriptReference.manipulators.Count-1?i+1:0);
						}
						GUI.enabled = true;
						if(GUILayout.Button("+", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							playgroundParticlesScriptReference.manipulators.Add(playgroundParticlesScriptReference.manipulators[i].Clone());
							manipulatorListFoldout.Add(manipulatorListFoldout[i]);
						}
						if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							
							if (playgroundParticlesScriptReference.manipulators[i].transform.transform==null || EditorUtility.DisplayDialog(
								"Remove "+PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type)+" Manipulator "+i+"?",
								"Are you sure you want to remove the Manipulator assigned to "+mName+"? (GameObject in Scene will remain intact)", 
								"Yes", "No")) {
									manipulators.DeleteArrayElementAtIndex(i);
									manipulatorListFoldout.RemoveAt(i);
									playgroundParticles.ApplyModifiedProperties();
									return;
								}
						}

						GUI.color = Color.white;
						
						EditorGUILayout.EndHorizontal();
						
						if (manipulatorListFoldout[i] && i<manipulators.arraySize) {
							PlaygroundInspectorC.RenderManipulatorSettings(playgroundParticlesScriptReference.manipulators[i], manipulators.GetArrayElementAtIndex(i), false);
						}

						GUI.enabled = true;
						EditorGUILayout.Separator();
						EditorGUILayout.EndVertical();
					}
					
				} else {
					EditorGUILayout.HelpBox("No manipulators created.", MessageType.Info);
				}
				
				if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
					if (Selection.gameObjects.Length>0)
						PlaygroundC.ManipulatorObject(null, playgroundParticlesScriptReference);
					else
						manipulators.InsertArrayElementAtIndex(manipulators.arraySize);
					manipulatorListFoldout.Add(true);
					SceneView.RepaintAll();
				}
				
				EditorGUILayout.Separator();
			}

			// Event Settings
			if (GUILayout.Button("Events ("+playgroundParticlesScriptReference.events.Count+")", EditorStyles.toolbarDropDown)) eventsFoldout=!eventsFoldout;
			if (eventsFoldout) {
				
				EditorGUILayout.Separator();

				if (playgroundParticlesScriptReference.events.Count>0) {
					string eName;
					for (int i = 0; i<playgroundParticlesScriptReference.events.Count; i++) {
						if (playgroundParticlesScriptReference.events[i].broadcastType!=EVENTBROADCASTC.EventListeners) {
							if (playgroundParticlesScriptReference.events[i].target!=null) {
								eName = playgroundParticlesScriptReference.events[i].target.name;
								if (eName.Length>24)
									eName = eName.Substring(0, 24)+"...";
							} else eName = "(No target)";
						} else eName = "(Event Listeners)";

						EditorGUILayout.BeginVertical("box");
						
						EditorGUILayout.BeginHorizontal();
						
						GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
						eventListFoldout[i] = GUILayout.Toggle(eventListFoldout[i], playgroundParticlesScriptReference.events[i].eventType.ToString(), EditorStyles.foldout, GUILayout.Width(Screen.width/4));
						if (playgroundParticlesScriptReference.events[i].target!=null) {
							if (GUILayout.Button(" ("+eName+")", EditorStyles.label)) {
								Selection.activeGameObject = playgroundParticlesScriptReference.events[i].target.gameObject;
							}
						} else {
							GUILayout.Button(eName, EditorStyles.label);
						}

						EditorGUILayout.Separator();
						GUI.enabled = (playgroundParticlesScriptReference.events.Count>1);
						if(GUILayout.Button("U", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							events.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.events.Count-1:i-1);
						}
						if(GUILayout.Button("D", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							events.MoveArrayElement(i, i<playgroundParticlesScriptReference.events.Count-1?i+1:0);
						}
						GUI.enabled = true;
						if(GUILayout.Button("+", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							playgroundParticlesScriptReference.events.Add(playgroundParticlesScriptReference.events[i].Clone());
							eventListFoldout.Add(eventListFoldout[i]);
						}
						if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							
							if (playgroundParticlesScriptReference.events[i].target==null || EditorUtility.DisplayDialog(
								"Remove "+playgroundParticlesScriptReference.events[i].eventType.ToString()+" Event "+i+"?",
								"Are you sure you want to remove this event?", 
								"Yes", "No")) {
								PlaygroundC.RemoveEvent (i, playgroundParticlesScriptReference);
								eventListFoldout.RemoveAt(i);
								playgroundParticles.ApplyModifiedProperties();
								return;
							}
						}
						
						EditorGUILayout.EndHorizontal();
						
						if (eventListFoldout[i] && i<events.arraySize) {
							RenderEventSettings(playgroundParticlesScriptReference.events[i], events.GetArrayElementAtIndex(i));
						}
						GUI.enabled = true;
						EditorGUILayout.Separator();
						EditorGUILayout.EndVertical();
					}
				} else {
					EditorGUILayout.HelpBox("No events created.", MessageType.Info);
				}

				if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
					PlaygroundC.CreateEvent(playgroundParticlesScriptReference);
					eventListFoldout.Add(true);
				}
				
				EditorGUILayout.Separator();
			}

			// Snapshot Settings
			if (!playgroundParticlesScriptReference.isSnapshot) {
				if (GUILayout.Button("Snapshots ("+playgroundParticlesScriptReference.snapshots.Count+")", EditorStyles.toolbarDropDown)) saveLoadFoldout=!saveLoadFoldout;
				if (saveLoadFoldout) {

					EditorGUILayout.Separator();
					bool setThisLoadFrom = false;
					string loadModeButton = "";
					if (playgroundParticlesScriptReference.snapshots.Count>0) {
						GUILayout.BeginHorizontal();
						playgroundParticlesScriptReference.loadTransition = EditorGUILayout.ToggleLeft("Transition Time", playgroundParticlesScriptReference.loadTransition, GUILayout.Width (Mathf.CeilToInt((Screen.width-140)/2)));
						GUI.enabled = playgroundParticlesScriptReference.loadTransition;
						playgroundParticlesScriptReference.loadTransitionTime = EditorGUILayout.Slider(playgroundParticlesScriptReference.loadTransitionTime, 0, PlaygroundC.reference.maximumAllowedTransitionTime);
						GUILayout.EndHorizontal();
						EditorGUI.indentLevel++;
						playgroundParticlesScriptReference.loadTransitionType = (TRANSITIONTYPEC)EditorGUILayout.EnumPopup("Transition Type", playgroundParticlesScriptReference.loadTransitionType);
						EditorGUI.indentLevel--;
						GUI.enabled = true;
						EditorGUILayout.Separator();
						playgroundParticlesScriptReference.loadFromStart = EditorGUILayout.ToggleLeft("Load From Start", playgroundParticlesScriptReference.loadFromStart);

						for (int i = 0; i<playgroundParticlesScriptReference.snapshots.Count; i++) {
							setThisLoadFrom = false;
							GUILayout.BeginHorizontal(boxStyle);

							if (playgroundParticlesScriptReference.loadFrom == i) {
								EditorGUILayout.Toggle (true, EditorStyles.radioButton, GUILayout.Width(14));
							} else
								setThisLoadFrom = EditorGUILayout.Toggle (setThisLoadFrom, EditorStyles.radioButton, GUILayout.Width(14));
							if (setThisLoadFrom)
								playgroundParticlesScriptReference.loadFrom = i;
							GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
							if (PlaygroundC.reference.showSnapshotsInHierarchy) {
								PlaygroundParticlesC currentSnapshot = playgroundParticlesScriptReference.snapshots[i].settings;
								playgroundParticlesScriptReference.snapshots[i].settings = (PlaygroundParticlesC)EditorGUILayout.ObjectField(playgroundParticlesScriptReference.snapshots[i].settings, typeof(PlaygroundParticlesC), true, GUILayout.MaxWidth (220));
								if (playgroundParticlesScriptReference.snapshots[i].settings!=currentSnapshot) {
									if (!playgroundParticlesScriptReference.snapshots[i].settings.isSnapshot) {
										EditorUtility.DisplayDialog(
											playgroundParticlesScriptReference.snapshots[i].settings.name+" is not a snapshot.",
											"You can only add snapshots into this slot. First create a snapshot from the new particle system you wish to assign.",
											"Ok"
										);
										playgroundParticlesScriptReference.snapshots[i].settings = currentSnapshot;
										continue;
									}
								}
								playgroundParticlesScriptReference.snapshots[i].settings.name = EditorGUILayout.TextField(playgroundParticlesScriptReference.snapshots[i].settings.name, EditorStyles.toolbarTextField);
								playgroundParticlesScriptReference.snapshots[i].name = playgroundParticlesScriptReference.snapshots[i].settings.name;
								GUI.enabled = playgroundParticlesScriptReference.loadTransition;
								playgroundParticlesScriptReference.snapshots[i].transitionType = (INDIVIDUALTRANSITIONTYPEC)EditorGUILayout.EnumPopup(playgroundParticlesScriptReference.snapshots[i].transitionType, GUILayout.MaxWidth (100));
								playgroundParticlesScriptReference.snapshots[i].transitionMultiplier = EditorGUILayout.FloatField(playgroundParticlesScriptReference.snapshots[i].transitionMultiplier, GUILayout.MaxWidth (30));
								GUI.enabled = true;
							} else {
								if (GUILayout.Button(playgroundParticlesScriptReference.snapshots[i].settings.name, EditorStyles.label, GUILayout.MinWidth (100)))
									playgroundParticlesScriptReference.loadFrom = i;
							}

							playgroundParticlesScriptReference.snapshots[i].loadTransform = EditorGUILayout.ToggleLeft ("Transform", playgroundParticlesScriptReference.snapshots[i].loadTransform, EditorStyles.miniButton, GUILayout.Width(80));
							switch (playgroundParticlesScriptReference.snapshots[i].loadMode) {
							case 0: loadModeButton = "Settings & Particles"; break;
							case 1: loadModeButton = "Settings Only"; break;
							case 2: loadModeButton = "Particles Only"; break;
							default: loadModeButton = "Settings & Particles"; break;
							}
							if (GUILayout.Button(loadModeButton, EditorStyles.toolbarButton, GUILayout.Width(110))){
								playgroundParticlesScriptReference.snapshots[i].loadMode++;
								playgroundParticlesScriptReference.snapshots[i].loadMode = playgroundParticlesScriptReference.snapshots[i].loadMode%3;
							}
							GUI.enabled = (playgroundParticlesScriptReference.snapshots.Count>1);
							if(GUILayout.Button("U", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								snapshots.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.snapshots.Count-1:i-1);
							}
							if(GUILayout.Button("D", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								snapshots.MoveArrayElement(i, i<playgroundParticlesScriptReference.snapshots.Count-1?i+1:0);
							}
							GUI.enabled = true;
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								if (EditorUtility.DisplayDialog(
									"Remove "+playgroundParticlesScriptReference.snapshots[i].name+"?",
									"Are you sure you want to remove the snapshot "+playgroundParticlesScriptReference.snapshots[i].name+" at list position "+i.ToString()+"?", 
									"Yes", "No")) {
									DestroyImmediate (playgroundParticlesScriptReference.snapshots[i].settings.gameObject);
									playgroundParticlesScriptReference.snapshots.RemoveAt(i);
									if (playgroundParticlesScriptReference.loadFrom>=playgroundParticlesScriptReference.snapshots.Count)
										playgroundParticlesScriptReference.loadFrom = playgroundParticlesScriptReference.snapshots.Count-1;
									return;
								}
							}
							GUILayout.EndHorizontal();
						}
						EditorGUILayout.Separator();
					} else {
						EditorGUILayout.HelpBox("No snapshots created.", MessageType.Info);
					}

					GUILayout.BeginHorizontal();
					if(GUILayout.Button("Save", EditorStyles.toolbarButton, GUILayout.Width(50))){
						saveName = "New Snapshot "+(playgroundParticlesScriptReference.snapshots.Count+1).ToString();
						playgroundParticlesScriptReference.Save(saveName);
						if (playgroundParticlesScriptReference.loadFrom>=playgroundParticlesScriptReference.snapshots.Count && playgroundParticlesScriptReference.snapshots.Count>0)
							playgroundParticlesScriptReference.loadFrom = playgroundParticlesScriptReference.snapshots.Count-1;
					}
					GUI.enabled = (playgroundParticlesScriptReference.snapshots.Count>0);
					if(GUILayout.Button("Load", EditorStyles.toolbarButton, GUILayout.Width(50))){
						playgroundParticlesScriptReference.Load(playgroundParticlesScriptReference.loadFrom);
					}
					GUILayout.FlexibleSpace();
					if(GUILayout.Button(playgroundScriptReference.showSnapshotsInHierarchy?"Simple":"Advanced", EditorStyles.toolbarButton, GUILayout.Width(70))){
						playgroundScriptReference.showSnapshotsInHierarchy = !playgroundScriptReference.showSnapshotsInHierarchy;
						PlaygroundInspectorC.UpdateSnapshots();
					}
					if(GUILayout.Button("Remove All", EditorStyles.toolbarButton, GUILayout.Width(70))){
						if (EditorUtility.DisplayDialog(
							"Remove all snapshots?",
							"Are you sure you want to remove all snapshot?", 
							"Yes", "No")) {
							for (int s = 0; s<playgroundParticlesScriptReference.snapshots.Count; s++) {
								DestroyImmediate (playgroundParticlesScriptReference.snapshots[s].settings.gameObject);
							}
							playgroundParticlesScriptReference.snapshots.Clear ();
							return;
						}
					}
					GUI.enabled = true;
					GUILayout.EndHorizontal();

					EditorGUILayout.Separator();
				}
			}

			// Advanced Settings
			if (GUILayout.Button("Advanced ("+playgroundParticlesScriptReference.particleSystem.simulationSpace+" Space)", EditorStyles.toolbarDropDown)) advancedFoldout=!advancedFoldout;
			if (advancedFoldout) {
				
				EditorGUILayout.Separator();
				
				// Update rate
				updateRate.intValue = EditorGUILayout.IntSlider("Update Rate (Frames)", updateRate.intValue, playgroundScriptReference.minimumAllowedUpdateRate, 1);
				
				EditorGUILayout.Separator();
				GUILayout.BeginVertical(boxStyle);
				GUI.enabled = (playgroundParticlesScriptReference.source!=SOURCEC.Projection);
				playgroundParticlesScriptReference.particleSystem.simulationSpace = (ParticleSystemSimulationSpace)EditorGUILayout.EnumPopup("Simulation Space", playgroundParticlesScriptReference.particleSystem.simulationSpace);
				GUI.enabled = true;
				if (playgroundParticlesScriptReference.particleSystem.simulationSpace==ParticleSystemSimulationSpace.Local && playgroundParticlesScriptReference.source!=SOURCEC.Projection) {
					/*
					if (playgroundParticlesScriptReference.source!=SOURCEC.Transform || playgroundParticlesScriptReference.source==SOURCEC.Transform && playgroundParticlesScriptReference.sourceTransform!=playgroundParticlesScriptReference.particleSystemTransform)
						if ((playgroundParticlesScriptReference.particleSystemTransform.position!=Vector3.zero || playgroundParticlesScriptReference.particleSystemTransform.rotation.eulerAngles!=Vector3.zero))
							EditorGUILayout.HelpBox("Keep the particle system global transform position and rotation at Vector3.zero to not offset your particles from your source position.", MessageType.Warning);
					*/

					playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation = EditorGUILayout.ToggleLeft ("Movement Compensation", playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation);
					GUI.enabled = playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation;
					GUILayout.BeginHorizontal();
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.applyMovementCompensationLifetimeStrength = EditorGUILayout.ToggleLeft ("Compensation Lifetime Strength", playgroundParticlesScriptReference.applyMovementCompensationLifetimeStrength);
					GUI.enabled = playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation && playgroundParticlesScriptReference.applyMovementCompensationLifetimeStrength;
					movementCompensationLifetimeStrength.animationCurveValue = EditorGUILayout.CurveField(movementCompensationLifetimeStrength.animationCurveValue);
					GUILayout.EndHorizontal();
					GUI.enabled = true;
					EditorGUI.indentLevel--;

				} else if (playgroundParticlesScriptReference.source==SOURCEC.Projection) {
					EditorGUILayout.HelpBox("Projection can only run in world space.", MessageType.Info);
				}

				GUILayout.EndVertical();

				EditorGUILayout.Separator();
				GUILayout.BeginVertical(boxStyle);
				EditorGUILayout.LabelField("Rebirth Options");
				playgroundParticlesScriptReference.applyRandomSizeOnRebirth = EditorGUILayout.Toggle ("Random Size", playgroundParticlesScriptReference.applyRandomSizeOnRebirth);
				playgroundParticlesScriptReference.applyRandomRotationOnRebirth = EditorGUILayout.Toggle ("Random Rotation", playgroundParticlesScriptReference.applyRandomRotationOnRebirth);
				playgroundParticlesScriptReference.applyRandomScatterOnRebirth = EditorGUILayout.Toggle ("Random Scatter", playgroundParticlesScriptReference.applyRandomScatterOnRebirth);
				playgroundParticlesScriptReference.applyRandomInitialVelocityOnRebirth = EditorGUILayout.Toggle ("Random Velocity", playgroundParticlesScriptReference.applyRandomInitialVelocityOnRebirth);
				playgroundParticlesScriptReference.applyInitialColorOnRebirth = EditorGUILayout.Toggle ("Force Initial Color", playgroundParticlesScriptReference.applyInitialColorOnRebirth);
				GUILayout.EndVertical();
				EditorGUILayout.Separator();

				GUILayout.BeginVertical(boxStyle);
				playgroundParticlesScriptReference.applyLockPosition = EditorGUILayout.ToggleLeft("Lock Position", playgroundParticlesScriptReference.applyLockPosition);
				GUI.enabled = playgroundParticlesScriptReference.applyLockPosition;
				playgroundParticlesScriptReference.lockPosition = EditorGUILayout.Vector3Field ("Position", playgroundParticlesScriptReference.lockPosition);
				playgroundParticlesScriptReference.lockPositionIsLocal = EditorGUILayout.Toggle("Position Is Local", playgroundParticlesScriptReference.lockPositionIsLocal);
				GUI.enabled = true;
				EditorGUILayout.Separator();
				playgroundParticlesScriptReference.applyLockRotation = EditorGUILayout.ToggleLeft("Lock Rotation", playgroundParticlesScriptReference.applyLockRotation);
				GUI.enabled = playgroundParticlesScriptReference.applyLockRotation;
				playgroundParticlesScriptReference.lockRotation = EditorGUILayout.Vector3Field ("Rotation", playgroundParticlesScriptReference.lockRotation);
				playgroundParticlesScriptReference.lockRotationIsLocal = EditorGUILayout.Toggle("Rotation Is Local", playgroundParticlesScriptReference.lockRotationIsLocal);
				GUI.enabled = true;
				EditorGUILayout.Separator();
				playgroundParticlesScriptReference.applyLockScale = EditorGUILayout.ToggleLeft("Lock Scale", playgroundParticlesScriptReference.applyLockScale);
				GUI.enabled = playgroundParticlesScriptReference.applyLockScale;
				playgroundParticlesScriptReference.lockScale = EditorGUILayout.Vector3Field ("Scale", playgroundParticlesScriptReference.lockScale);
				GUI.enabled = true;
				GUILayout.EndVertical();
				EditorGUILayout.Separator();

				playgroundParticlesScriptReference.syncPositionsOnMainThread = EditorGUILayout.Toggle ("Sync Threaded Positions", playgroundParticlesScriptReference.syncPositionsOnMainThread);
				playgroundParticlesScriptReference.pauseCalculationWhenInvisible = EditorGUILayout.Toggle ("Auto-Pause Calculation", playgroundParticlesScriptReference.pauseCalculationWhenInvisible);
				EditorGUILayout.Separator();

				GUILayout.BeginHorizontal();
				EditorGUILayout.PrefixLabel("Particle Pool");
				
				// Clear
				if(GUILayout.Button("Clear", EditorStyles.toolbarButton, GUILayout.Width(50))){
					PlaygroundParticlesC.Clear(playgroundParticlesScriptReference);
				}
				
				// Rebuild
				if(GUILayout.Button("Rebuild", EditorStyles.toolbarButton, GUILayout.Width(50))){
					PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.particleCount);
					playgroundParticlesScriptReference.Start();
					//LifetimeSorting();
				}
				GUILayout.EndHorizontal();
				
				EditorGUILayout.Separator();
				
			}

			EditorGUILayout.EndVertical();
			
			if (playgroundParticlesScriptReference.shurikenParticleSystem.isPaused || playgroundParticlesScriptReference.shurikenParticleSystem.isStopped)
				playgroundParticlesScriptReference.shurikenParticleSystem.Play();
			
			previousSource = playgroundParticlesScriptReference.source;
			playgroundParticles.ApplyModifiedProperties();
			
		}
		
		EditorGUILayout.EndVertical();
		
		// Playground Manager - Particle Systems, Manipulators
		PlaygroundInspectorC.RenderPlaygroundSettings();

		// Wireframes in Scene View
		if (currentWireframe!=PlaygroundC.reference.drawWireframe)
			SetWireframeVisibility();
	}
		// Emit number of particles set by quantity, position and minimum - maximum random velocity
		public void Emit (int quantity, Vector3 givePosition, Vector3 randomVelocityMin, Vector3 randomVelocityMax, Color32 giveColor) {
			source = SOURCEC.Script;
			for (int i = 0; i<quantity; i++)
				EmitProcedure(
					givePosition,
					applyInitialVelocityShape?
					Vector3.Scale (RandomRange(internalRandom01, randomVelocityMin, randomVelocityMax), initialVelocityShape.Evaluate((i*1f)/(quantity*1f)))
					:
					RandomRange(internalRandom01, randomVelocityMin, randomVelocityMax),
					giveColor
				);
			particleSystemGameObject.SetActive(true);
		}
	void OnEnable () {

		lastActiveTool = Tools.current;
		
		// Playground Particles
		playgroundParticlesScriptReference = target as PlaygroundParticlesC;
		playgroundParticles = new SerializedObject(playgroundParticlesScriptReference);
		
		shurikenRenderer = playgroundParticlesScriptReference.particleSystemGameObject.particleSystem.renderer as ParticleSystemRenderer;
		
		manipulators = playgroundParticles.FindProperty("manipulators");
		events = playgroundParticles.FindProperty("events");
		snapshots = playgroundParticles.FindProperty("snapshots");
		source = playgroundParticles.FindProperty("source");
		sorting = playgroundParticles.FindProperty("sorting");
		lifetimeSorting = playgroundParticles.FindProperty("lifetimeSorting");
		nearestNeighborOrigin = playgroundParticles.FindProperty("nearestNeighborOrigin");
		activeState = playgroundParticles.FindProperty("activeState");
		particleCount = playgroundParticles.FindProperty("particleCount");
		emissionRate = playgroundParticles.FindProperty("emissionRate");
		updateRate = playgroundParticles.FindProperty("updateRate");
		emit = playgroundParticles.FindProperty("emit");
		loop = playgroundParticles.FindProperty("loop");
		disableOnDone = playgroundParticles.FindProperty("disableOnDone");
		calculate = playgroundParticles.FindProperty("calculate");
		deltaMovementStrength = playgroundParticles.FindProperty("deltaMovementStrength");
		particleTimescale = playgroundParticles.FindProperty("particleTimescale");
		sizeMin = playgroundParticles.FindProperty("sizeMin");
		sizeMax = playgroundParticles.FindProperty("sizeMax");
		overflowOffset = playgroundParticles.FindProperty("overflowOffset");
		overflowMode = playgroundParticles.FindProperty("overflowMode");
		lifetime = playgroundParticles.FindProperty("lifetime");
		lifetimeSize = playgroundParticles.FindProperty("lifetimeSize");
		turbulenceLifetimeStrength = playgroundParticles.FindProperty("turbulenceLifetimeStrength");
		lifetimeVelocity = playgroundParticles.FindProperty("lifetimeVelocity");
		initialVelocityShape = playgroundParticles.FindProperty("initialVelocityShape");
		initialVelocityMin = playgroundParticles.FindProperty("initialVelocityMin");
		initialVelocityMax = playgroundParticles.FindProperty("initialVelocityMax");
		initialLocalVelocityMin = playgroundParticles.FindProperty("initialLocalVelocityMin");
		initialLocalVelocityMax = playgroundParticles.FindProperty("initialLocalVelocityMax");
		lifetimeColor = playgroundParticles.FindProperty("lifetimeColor");
		lifetimeColors = playgroundParticles.FindProperty ("lifetimeColors");
		colorSource = playgroundParticles.FindProperty("colorSource");
		collision = playgroundParticles.FindProperty("collision");
		affectRigidbodies = playgroundParticles.FindProperty("affectRigidbodies");
		mass = playgroundParticles.FindProperty("mass");
		collisionRadius = playgroundParticles.FindProperty("collisionRadius");
		collisionMask = playgroundParticles.FindProperty("collisionMask");
		collisionType = playgroundParticles.FindProperty("collisionType");
		bounciness = playgroundParticles.FindProperty("bounciness");
		states = playgroundParticles.FindProperty("states");
		worldObject = playgroundParticles.FindProperty("worldObject");
		skinnedWorldObject = playgroundParticles.FindProperty("skinnedWorldObject");
		sourceTransform = playgroundParticles.FindProperty("sourceTransform");
		worldObjectUpdateVertices = playgroundParticles.FindProperty ("worldObjectUpdateVertices");
		worldObjectUpdateNormals = playgroundParticles.FindProperty("worldObjectUpdateNormals");
		sourcePaint = playgroundParticles.FindProperty("paint");
		sourceProjection = playgroundParticles.FindProperty("projection");
		lifetimeStretching = playgroundParticles.FindProperty("stretchLifetime");

		playgroundParticlesScriptReference.shurikenParticleSystem = playgroundParticlesScriptReference.GetComponent<ParticleSystem>();
		playgroundParticlesScriptReference.particleSystemRenderer = playgroundParticlesScriptReference.shurikenParticleSystem.renderer;
		particleMaterial = playgroundParticlesScriptReference.particleSystemRenderer.sharedMaterial;
		
		onlySourcePositioning = playgroundParticles.FindProperty("onlySourcePositioning");
		
		applyLifetimeVelocity = playgroundParticles.FindProperty("applyLifetimeVelocity");
		lifeTimeVelocityX = lifetimeVelocity.FindPropertyRelative("x");
		lifeTimeVelocityY = lifetimeVelocity.FindPropertyRelative("y");
		lifeTimeVelocityZ = lifetimeVelocity.FindPropertyRelative("z");
		
		initialVelocityShapeX = initialVelocityShape.FindPropertyRelative("x");
		initialVelocityShapeY = initialVelocityShape.FindPropertyRelative("y");
		initialVelocityShapeZ = initialVelocityShape.FindPropertyRelative("z");
		
		applyInitialVelocity = playgroundParticles.FindProperty("applyInitialVelocity");
		applyInitialLocalVelocity = playgroundParticles.FindProperty("applyInitialLocalVelocity");
		applyVelocityBending = playgroundParticles.FindProperty("applyVelocityBending");
		velocityBendingType = playgroundParticles.FindProperty("velocityBendingType");

		movementCompensationLifetimeStrength = playgroundParticles.FindProperty ("movementCompensationLifetimeStrength");
		
		worldObjectGameObject = worldObject.FindPropertyRelative("gameObject");
		skinnedWorldObjectGameObject = skinnedWorldObject.FindPropertyRelative("gameObject");

		// Lifetime colors
		if (playgroundParticlesScriptReference.lifetimeColors==null)
			playgroundParticlesScriptReference.lifetimeColors = new List<PlaygroundGradientC>();

		// Sorting
		prevLifetimeSortingKeys = playgroundParticlesScriptReference.lifetimeSorting.keys;
		
		// Manipulator list
		manipulatorListFoldout = new List<bool>();
		manipulatorListFoldout.AddRange(new bool[playgroundParticlesScriptReference.manipulators.Count]);

		// Events list
		eventListFoldout = new List<bool>();
		eventListFoldout.AddRange(new bool[playgroundParticlesScriptReference.events.Count]);

		// States foldout
		statesListFoldout = new List<bool>();
		statesListFoldout.AddRange(new bool[playgroundParticlesScriptReference.states.Count]);

		previousSource = playgroundParticlesScriptReference.source;
		
		// Playground
		playgroundScriptReference = FindObjectOfType<PlaygroundC>();
		
		
		// Create a manager if no existing instance is in the scene
		if (!playgroundScriptReference && Selection.activeTransform!=null) {
			PlaygroundC.ResourceInstantiate("Playground Manager");
			playgroundScriptReference = FindObjectOfType<PlaygroundC>();
		}
		
		if (playgroundScriptReference!=null) {
			PlaygroundC.reference = playgroundScriptReference;

			// Serialize Playground
			playground = new SerializedObject(playgroundScriptReference);
			
			PlaygroundInspectorC.Initialize(playgroundScriptReference);
			
			
			// Add this PlaygroundParticles if not existing in Playground list
			if (!playgroundParticlesScriptReference.isSnapshot && !playgroundScriptReference.particleSystems.Contains(playgroundParticlesScriptReference) && Selection.activeTransform!=null)
				playgroundScriptReference.particleSystems.Add(playgroundParticlesScriptReference);
				
			// Cache components
			playgroundParticlesScriptReference.particleSystemGameObject = playgroundParticlesScriptReference.gameObject;
			playgroundParticlesScriptReference.particleSystemTransform = playgroundParticlesScriptReference.transform;
			playgroundParticlesScriptReference.particleSystemRenderer = playgroundParticlesScriptReference.renderer;
			playgroundParticlesScriptReference.shurikenParticleSystem = playgroundParticlesScriptReference.particleSystemGameObject.GetComponent<ParticleSystem>();
			playgroundParticlesScriptReference.particleSystemRenderer2 = playgroundParticlesScriptReference.particleSystemGameObject.particleSystem.renderer as ParticleSystemRenderer;
			
			// Set manager as parent 
			if (PlaygroundC.reference.autoGroup && playgroundParticlesScriptReference.particleSystemTransform!=null && playgroundParticlesScriptReference.particleSystemTransform.parent == null && Selection.activeTransform!=null)
				playgroundParticlesScriptReference.particleSystemTransform.parent = PlaygroundC.referenceTransform;
			
			// Issue a quick refresh
			if (!EditorApplication.isPlaying)
				foreach (PlaygroundParticlesC p in PlaygroundC.reference.particleSystems)
					p.Start();
		}

		selectedSort = sorting.intValue;

		// State initial values
		if (addStateTransform==null)
			addStateTransform = (Transform)playgroundParticlesScriptReference.particleSystemTransform;
		
		// Visiblity of Shuriken component in Inspector
		if (!playgroundScriptReference || playgroundScriptReference && !playgroundScriptReference.showShuriken)
			playgroundParticlesScriptReference.shurikenParticleSystem.hideFlags = HideFlags.HideInInspector;
		else
			playgroundParticlesScriptReference.shurikenParticleSystem.hideFlags = HideFlags.None;

		SetWireframeVisibility();

		// Set paint init
		paintLayerMask = sourcePaint.FindPropertyRelative("layerMask");
		paintCollisionType = sourcePaint.FindPropertyRelative("collisionType");
		
		LoadBrushes();
		
		// Set projection init
		projectionMask = sourceProjection.FindPropertyRelative("projectionMask");
		projectionCollisionType = sourceProjection.FindPropertyRelative("collisionType");

		// Snapshots
		if (playgroundParticlesScriptReference.snapshots.Count>0) {
			if (playgroundParticlesScriptReference.snapshots.Count>0) {
				for (int i = 0; i<playgroundParticlesScriptReference.snapshots.Count; i++)
					if (playgroundParticlesScriptReference.snapshots[i].settings==null)
						playgroundParticlesScriptReference.snapshots.RemoveAt(i);
			}
			saveName += " "+(playgroundParticlesScriptReference.snapshots.Count+1).ToString();
		}
	}
		/// <summary>
		/// Emits a single particle at previously set scripted emission position, velocity and color.
		/// </summary>
		public int Emit () {
			source = SOURCEC.Script;
			int returnIndex = scriptedEmissionIndex;
			EmitProcedure(scriptedEmissionPosition, scriptedEmissionVelocity, scriptedEmissionColor);
			return returnIndex;
		}
	public override void OnInspectorGUI () {
		if (boxStyle==null)
			boxStyle = GUI.skin.FindStyle("box");
		if (PlaygroundInspectorC.boxStyle==null)
			PlaygroundInspectorC.boxStyle = GUI.skin.FindStyle("box");
		isEditingInHierarchy = Selection.activeTransform!=null;
		/*
		if (isEditingInHierarchy) {
			EditorGUILayout.LabelField(playgroundLanguage.editFromHierarchyOnly);
			return;
		}
		*/


		if (Event.current.type == EventType.ValidateCommand &&
			Event.current.commandName == "UndoRedoPerformed") {			
				LifetimeSorting();
		}
		
		playgroundParticles.Update();
		
		EditorGUILayout.Separator();
		
		GUILayout.BeginHorizontal();
		EditorGUILayout.LabelField(playgroundLanguage.playgroundName+" "+PlaygroundC.version+PlaygroundC.specialVersion, EditorStyles.largeLabel, GUILayout.Height(20));
		
		EditorGUILayout.Separator();
		
		if(GUILayout.Button(playgroundLanguage.playgroundWizard, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
			PlaygroundParticleWindowC.ShowWindow();
		}
		if(GUILayout.Button(playgroundLanguage.createPreset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
			PlaygroundCreatePresetWindowC.ShowWindow();
		}
		GUILayout.EndHorizontal();
		
		EditorGUILayout.Separator();

		if (playgroundParticlesScriptReference.particleSystemTransform.localScale.x != 1f ||
		    playgroundParticlesScriptReference.particleSystemTransform.localScale.y != 1f ||
		    playgroundParticlesScriptReference.particleSystemTransform.localScale.z != 1f) {
			EditorGUILayout.BeginVertical(boxStyle);
			EditorGUILayout.HelpBox(playgroundLanguage.localScaleWarning, MessageType.Warning);
			if (GUILayout.Button (playgroundLanguage.fix, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
				playgroundParticlesScriptReference.particleSystemTransform.localScale = new Vector3(1f,1f,1f);
			EditorGUILayout.EndVertical();
		}
		if (playgroundParticlesScriptReference.GetComponent<ParticleSystem>().simulationSpace!=ParticleSystemSimulationSpace.Local && 
		    playgroundParticlesScriptReference.source!=SOURCEC.Projection &&
			(playgroundParticlesScriptReference.particleSystemTransform.rotation.x != 0 ||
		    playgroundParticlesScriptReference.particleSystemTransform.rotation.y != 0 ||
		    playgroundParticlesScriptReference.particleSystemTransform.rotation.z != 0)) {
			EditorGUILayout.BeginVertical(boxStyle);
			EditorGUILayout.HelpBox(playgroundLanguage.rotationSimulationSpace, MessageType.Info);
			if (GUILayout.Button (playgroundLanguage.setLocalSpaceSimulation, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
				playgroundParticlesScriptReference.GetComponent<ParticleSystem>().simulationSpace = ParticleSystemSimulationSpace.Local;
			EditorGUILayout.EndVertical();
		}

		// Particles
		EditorGUILayout.BeginVertical(boxStyle);
		if (playgroundParticlesScriptReference.eventControlledBy.Count>0)
			playgroundSettings.particlesFoldout = GUILayout.Toggle(playgroundSettings.particlesFoldout, playgroundLanguage.playgroundParticles+" ("+playgroundLanguage.eventControlled+")", EditorStyles.foldout);
		else if (playgroundParticlesScriptReference.isSnapshot)
			playgroundSettings.particlesFoldout = GUILayout.Toggle(playgroundSettings.particlesFoldout, playgroundLanguage.playgroundParticles+" ("+playgroundLanguage.snapshot+")", EditorStyles.foldout);
		else
			playgroundSettings.particlesFoldout = GUILayout.Toggle(playgroundSettings.particlesFoldout, playgroundLanguage.playgroundParticles, EditorStyles.foldout);
		if (playgroundSettings.particlesFoldout) {

			EditorGUILayout.BeginVertical(boxStyle);
			
			// Source Settings
			if (GUILayout.Button(playgroundLanguage.source+" ("+playgroundParticlesScriptReference.source.ToString()+")", EditorStyles.toolbarDropDown)) playgroundSettings.sourceFoldout=!playgroundSettings.sourceFoldout;
			if (playgroundSettings.sourceFoldout) {
				
				EditorGUILayout.Separator();
				
				if (previousSource!=playgroundParticlesScriptReference.source) {
					LifetimeSorting();
				}
				EditorGUILayout.PropertyField(source, new GUIContent(
					playgroundLanguage.source, 
					playgroundLanguage.sourceDescription)
				);
				
				EditorGUILayout.Separator();
				
				// Source is State
				if (source.intValue == 0) {
					RenderStateSettings();
					
				// Source is Projection
				} else if (source.intValue == 6) {
					RenderProjectionSettings();
				
				// Source is Transforms
				} else if (source.intValue == 1) {

					playgroundParticlesScriptReference.treatAsOneTransform = EditorGUILayout.Toggle (playgroundLanguage.treatAsOneTransform, playgroundParticlesScriptReference.treatAsOneTransform);
					
					EditorGUILayout.Separator();
					
					EditorGUILayout.BeginVertical(boxStyle);
					GUILayout.BeginHorizontal();
					playgroundSettings.transformListFoldout = GUILayout.Toggle(playgroundSettings.transformListFoldout, playgroundLanguage.transforms, EditorStyles.foldout);
					GUILayout.Label (playgroundParticlesScriptReference.sourceTransforms.Count.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
					GUILayout.EndHorizontal();
					if (playgroundSettings.transformListFoldout) {
						bool hasDisabledTransform = false;
						if (playgroundParticlesScriptReference.sourceTransforms.Count>0) {
							for (int i = 0; i<playgroundParticlesScriptReference.sourceTransforms.Count; i++) {
								if (playgroundParticlesScriptReference.sourceTransforms[i].transform==null) hasDisabledTransform = true;
								EditorGUILayout.BeginVertical(boxStyle);
								EditorGUILayout.BeginHorizontal();
								GUILayout.Label(i.ToString(), EditorStyles.miniLabel, new GUILayoutOption[]{GUILayout.Width(18)});
								playgroundParticlesScriptReference.sourceTransforms[i].unfolded = GUILayout.Toggle(playgroundParticlesScriptReference.sourceTransforms[i].unfolded, playgroundLanguage.transform, EditorStyles.foldout);
								playgroundParticlesScriptReference.sourceTransforms[i].transform = (Transform)EditorGUILayout.ObjectField(playgroundParticlesScriptReference.sourceTransforms[i].transform, typeof(Transform), true);

								GUI.enabled = playgroundParticlesScriptReference.sourceTransforms[i].transform!=null;
								if (GUILayout.Button (playgroundLanguage.edit, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
									Selection.activeTransform = playgroundParticlesScriptReference.sourceTransforms[i].transform;
								GUI.enabled = true;
								GUI.enabled = (playgroundParticlesScriptReference.sourceTransforms.Count>1);
								if(GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
									sourceTransforms.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.sourceTransforms.Count-1:i-1);
								}
								if(GUILayout.Button(playgroundLanguage.downSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
									sourceTransforms.MoveArrayElement(i, i<playgroundParticlesScriptReference.sourceTransforms.Count-1?i+1:0);
								}
								GUI.enabled = true;
								if (GUILayout.Button("+", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
									Transform newT = PlaygroundC.CreateTransform();
									newT.parent = playgroundParticlesScriptReference.particleSystemTransform;
									newT.position = playgroundParticlesScriptReference.sourceTransforms[i].transform.position;
									newT.name = "Source Transform "+(playgroundParticlesScriptReference.sourceTransforms.Count+1);
									playgroundParticlesScriptReference.sourceTransforms.Insert(i+1, new PlaygroundTransformC());
									playgroundParticlesScriptReference.sourceTransforms[i+1].transform = newT;
									playgroundParticles.ApplyModifiedProperties();
								}
								if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
									playgroundParticlesScriptReference.sourceTransforms.RemoveAt(i);
									playgroundParticles.ApplyModifiedProperties();
									return;
								}
								EditorGUILayout.EndHorizontal();
								if (playgroundParticlesScriptReference.sourceTransforms[i].unfolded) {
									if (playgroundParticlesScriptReference.sourceTransforms[i].transform!=null) {
										playgroundParticlesScriptReference.sourceTransforms[i].transform.position = EditorGUILayout.Vector3Field (playgroundLanguage.position, playgroundParticlesScriptReference.sourceTransforms[i].transform.position);
										playgroundParticlesScriptReference.sourceTransforms[i].transform.rotation = Quaternion.Euler(EditorGUILayout.Vector3Field(playgroundLanguage.rotation, playgroundParticlesScriptReference.sourceTransforms[i].transform.rotation.eulerAngles));
										playgroundParticlesScriptReference.sourceTransforms[i].transform.localScale = EditorGUILayout.Vector3Field(playgroundLanguage.scale, playgroundParticlesScriptReference.sourceTransforms[i].transform.localScale);
									} else {
										EditorGUILayout.HelpBox(playgroundLanguage.assignTransformMessage, MessageType.Info);
									}
								}
								EditorGUILayout.EndVertical();
							}
							EditorGUILayout.Separator();
							
						}

						if (hasDisabledTransform)
							EditorGUILayout.HelpBox(playgroundLanguage.allTransformsMustBeAssignedMessage, MessageType.Warning);
						
						EditorGUILayout.BeginHorizontal();
						if (GUILayout.Button (playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
							PlaygroundC.CreatePlaygroundTransform(playgroundParticlesScriptReference);
						}
						if (GUILayout.Button (playgroundLanguage.newEmpty, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
							playgroundParticlesScriptReference.sourceTransforms.Add (new PlaygroundTransformC());
						}
						EditorGUILayout.Separator();
						if (GUILayout.Button (playgroundLanguage.reverse, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
							playgroundParticlesScriptReference.sourceTransforms.Reverse();
						}
						EditorGUILayout.EndHorizontal();
					}
					EditorGUILayout.EndVertical();
				

					/*
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.transform);
					sourceTransform.objectReferenceValue = EditorGUILayout.ObjectField(sourceTransform.objectReferenceValue, typeof(Transform), true);
					GUILayout.EndHorizontal();
					
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.points+":");
					EditorGUILayout.SelectableLabel(sourceTransform.objectReferenceValue!=null?"1":"0", GUILayout.MaxWidth(80));
					EditorGUILayout.Separator();
					if(GUILayout.Button(playgroundLanguage.setParticleCount, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) && isEditingInHierarchy){
						playgroundParticlesScriptReference.particleCount = sourceTransform.objectReferenceValue!=null?1:0;
					}
					GUI.enabled = (sourceTransform.objectReferenceValue!=null);
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
						particleCount.intValue = particleCount.intValue+1;
					GUI.enabled = true;
					GUILayout.EndHorizontal();
					*/

				// Source is World Object
				} else if (source.intValue == 2) {
					playgroundParticlesScriptReference.worldObject.gameObject = (GameObject)EditorGUILayout.ObjectField(playgroundLanguage.worldObject, playgroundParticlesScriptReference.worldObject.gameObject, typeof(GameObject), true);

					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.points+":");
					EditorGUILayout.SelectableLabel((playgroundParticlesScriptReference.worldObject.vertexPositions!=null && playgroundParticlesScriptReference.worldObject.vertexPositions.Length>0)?playgroundParticlesScriptReference.worldObject.vertexPositions.Length.ToString():playgroundLanguage.noMesh, GUILayout.MaxWidth(80));
					
					EditorGUILayout.Separator();

					if(GUILayout.Button(playgroundLanguage.setParticleCount, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) && playgroundParticlesScriptReference.worldObject.vertexPositions!=null && isEditingInHierarchy){
						playgroundParticlesScriptReference.particleCount = playgroundParticlesScriptReference.worldObject.vertexPositions.Length;
					}
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}) && playgroundParticlesScriptReference.worldObject.vertexPositions!=null)
						particleCount.intValue = particleCount.intValue+playgroundParticlesScriptReference.worldObject.vertexPositions.Length;
					GUILayout.EndHorizontal();
				
					GUILayout.BeginVertical(boxStyle);
					EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions);
					EditorGUILayout.PropertyField(worldObjectUpdateVertices, new GUIContent(
						playgroundLanguage.meshVerticesUpdate,
						playgroundLanguage.meshVerticesUpdateDescription
					));
					EditorGUILayout.PropertyField(worldObjectUpdateNormals, new GUIContent(
						playgroundLanguage.meshNormalsUpdate,
						playgroundLanguage.meshNormalsUpdateDescription
					));
					GUILayout.EndVertical();
					
				// Source is Skinned World Object
				} else if (source.intValue == 3) {
					playgroundParticlesScriptReference.skinnedWorldObject.gameObject = (GameObject)EditorGUILayout.ObjectField(playgroundLanguage.skinnedWorldObject, playgroundParticlesScriptReference.skinnedWorldObject.gameObject, typeof(GameObject), true);
					if (playgroundParticlesScriptReference.skinnedWorldObject.gameObject!=null && playgroundParticlesScriptReference.skinnedWorldObject.renderer!=null) {
						if (playgroundParticlesScriptReference.skinnedWorldObject.renderer.bones.Length==0)
							EditorGUILayout.HelpBox(playgroundLanguage.skinnedMeshOptimizeGameObjectsMessage, MessageType.Warning);
					}

					if (playgroundParticlesScriptReference.skinnedWorldObject.mesh) {
						int prevDownResolutionSkinned = playgroundParticlesScriptReference.skinnedWorldObject.downResolution;
						playgroundParticlesScriptReference.skinnedWorldObject.downResolution = EditorGUILayout.IntSlider(playgroundLanguage.sourceDownResolution, playgroundParticlesScriptReference.skinnedWorldObject.downResolution, 1, Mathf.RoundToInt (playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/2));
						if (prevDownResolutionSkinned!=playgroundParticlesScriptReference.skinnedWorldObject.downResolution)
							LifetimeSorting();
					}

					EditorGUILayout.PropertyField(forceSkinnedMeshUpdateOnMainThread, new GUIContent(
						playgroundLanguage.forceUpdateOnMainThread,
						playgroundLanguage.forceUpdateOnMainThreadDescription
					));

					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.points+":");
					if (playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions!=null && playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length>0) {
						if (playgroundParticlesScriptReference.skinnedWorldObject.downResolution<=1)
							EditorGUILayout.SelectableLabel(playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length.ToString(), GUILayout.MaxWidth(80));
						else
							EditorGUILayout.SelectableLabel((playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.skinnedWorldObject.downResolution).ToString()+" ("+playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length.ToString()+")", GUILayout.MaxWidth(160));
					} else EditorGUILayout.SelectableLabel(playgroundLanguage.noMesh);
					EditorGUILayout.Separator();
					if(GUILayout.Button(playgroundLanguage.setParticleCount, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) && playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions!=null && isEditingInHierarchy){
						playgroundParticlesScriptReference.particleCount = playgroundParticlesScriptReference.skinnedWorldObject.downResolution<=1?playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length:playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.skinnedWorldObject.downResolution;
					}
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}) && playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions!=null)
						particleCount.intValue = particleCount.intValue+(playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.skinnedWorldObject.downResolution);
					GUILayout.EndHorizontal();

					GUILayout.BeginVertical(boxStyle);
					EditorGUILayout.LabelField(playgroundLanguage.proceduralOptions);
					EditorGUILayout.PropertyField(worldObjectUpdateVertices, new GUIContent(
						playgroundLanguage.meshVerticesUpdate,
						playgroundLanguage.meshVerticesUpdateDescription
					));
					EditorGUILayout.PropertyField(worldObjectUpdateNormals, new GUIContent(
						playgroundLanguage.meshNormalsUpdate,
						playgroundLanguage.meshNormalsUpdateDescription
					));
					GUILayout.EndVertical();
					
				// Source is Script
				} else if (source.intValue == 4) {

					// Controlled by events
					if (playgroundParticlesScriptReference.eventControlledBy.Count>0) {
						GUILayout.BeginVertical (boxStyle);
						int eventCount = 0;
						EditorGUILayout.HelpBox(playgroundLanguage.controlledByAnotherEvent, MessageType.Info);
						for (int i = 0; i<playgroundParticlesScriptReference.eventControlledBy.Count; i++) {
							eventCount = 0;
							for (int x = 0; x<playgroundParticlesScriptReference.eventControlledBy[i].events.Count; x++)
								if (playgroundParticlesScriptReference.eventControlledBy[i].events[x].target==playgroundParticlesScriptReference) eventCount++;
							GUILayout.BeginHorizontal (boxStyle);
							GUILayout.Label (i.ToString(), EditorStyles.miniLabel, new GUILayoutOption[]{GUILayout.Width(18)});
							if (GUILayout.Button (playgroundParticlesScriptReference.eventControlledBy[i].name+" ("+eventCount+")", EditorStyles.label)) 
								Selection.activeGameObject = playgroundParticlesScriptReference.eventControlledBy[i].particleSystemGameObject;
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								if (EditorUtility.DisplayDialog(
									playgroundLanguage.removeEvent+" "+playgroundParticlesScriptReference.eventControlledBy[i].name+"?",
									playgroundLanguage.removeEventsText1+" "+playgroundParticlesScriptReference.eventControlledBy[i].name+" "+playgroundLanguage.removeEventsText2, 
									playgroundLanguage.yes, playgroundLanguage.no)) {
									for (int x = 0; x<playgroundParticlesScriptReference.eventControlledBy[i].events.Count; x++) {
										if (playgroundParticlesScriptReference.eventControlledBy[i].events[x].target == playgroundParticlesScriptReference) {
											playgroundParticlesScriptReference.eventControlledBy[i].events.RemoveAt(x);
											x--;
										}
									}
									playgroundParticlesScriptReference.eventControlledBy.RemoveAt (i);
								}
							}
							GUILayout.EndHorizontal ();
						}
						GUILayout.EndVertical ();
						GUI.enabled = false;
					} else EditorGUILayout.HelpBox(playgroundLanguage.controlledByScript, MessageType.Info);


					EditorGUILayout.Separator();
					
					EditorGUILayout.BeginVertical(boxStyle);
					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.scriptedEmissionIndex = EditorGUILayout.IntField(playgroundLanguage.emissionIndex, Mathf.Clamp(playgroundParticlesScriptReference.scriptedEmissionIndex, 0, playgroundParticlesScriptReference.particleCount-1));
					if(GUILayout.RepeatButton(playgroundLanguage.emit, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Height(16), GUILayout.ExpandWidth(false)})) {
						PlaygroundC.Emit(playgroundParticlesScriptReference);
					}
					EditorGUILayout.EndHorizontal();
					
					playgroundParticlesScriptReference.scriptedEmissionPosition = EditorGUILayout.Vector3Field(playgroundLanguage.position, playgroundParticlesScriptReference.scriptedEmissionPosition);
					playgroundParticlesScriptReference.scriptedEmissionVelocity = EditorGUILayout.Vector3Field(playgroundLanguage.velocity, playgroundParticlesScriptReference.scriptedEmissionVelocity);
					playgroundParticlesScriptReference.scriptedEmissionColor = EditorGUILayout.ColorField(playgroundLanguage.color, playgroundParticlesScriptReference.scriptedEmissionColor);

					EditorGUILayout.EndVertical();

					GUI.enabled = true;
					
				// Source is Paint
				} else if (source.intValue == 5) {
					
					if (playgroundParticlesScriptReference.paint==null) {
						PlaygroundC.PaintObject(playgroundParticlesScriptReference);
					}
					
					// Paint Mode
					EditorGUILayout.BeginVertical(boxStyle);
					EditorGUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.paintMode);
					selectedPaintMode = GUILayout.Toolbar (selectedPaintMode, new string[]{playgroundLanguage.dot,playgroundLanguage.brush,playgroundLanguage.eraser}, EditorStyles.toolbarButton);
					EditorGUILayout.EndHorizontal();
					
					// Dot
					if (selectedPaintMode!=0) {
						EditorGUILayout.Separator();
					}
					
					// Brush
					if (selectedPaintMode==1) {
						EditorGUI.indentLevel++;
						EditorGUILayout.BeginVertical(boxStyle);
						brushPresetFoldout = GUILayout.Toggle(brushPresetFoldout, playgroundLanguage.brushPresets, EditorStyles.foldout);
						EditorGUI.indentLevel--;
						if (brushPresetFoldout) {
							if (brushPresets==null)
								LoadBrushes();
							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.Separator();
							brushListStyle = GUILayout.Toolbar (brushListStyle, new string[]{playgroundLanguage.icons,playgroundLanguage.list}, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));
							EditorGUILayout.EndHorizontal();
							EditorGUILayout.Separator();
							int i;
							
							// Icons
							if (brushListStyle==0) {
								GUILayout.BeginHorizontal();
								for (i = 0; i<brushPresets.Length; i++) {
									EditorGUILayout.BeginVertical(new GUILayoutOption[]{GUILayout.Width(50), GUILayout.Height(62)});
									
									if (GUILayout.Button(brushPresets[i].texture, new GUILayoutOption[]{GUILayout.Width(32), GUILayout.Height(32)})){
										selectedBrushPreset = i;
										SetBrush(i);
									}
									if (brushNames.Length>0) {
										EditorGUILayout.LabelField(brushNames[i], EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[]{GUILayout.Width(50), GUILayout.Height(30)});
									}
									EditorGUILayout.EndVertical();
									if (i%(Screen.width/80)==0 && i>0) {
										EditorGUILayout.EndHorizontal();
										EditorGUILayout.BeginHorizontal();
									}
								}
								EditorGUILayout.EndHorizontal();
								
								
							// List
							} else {
								for (i = 0; i<brushPresets.Length; i++) {
									EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(22));
									EditorGUILayout.BeginHorizontal();
									if (GUILayout.Button(brushNames[i], EditorStyles.label)) {
										selectedBrushPreset = i;
										SetBrush(i);
									}
									EditorGUILayout.Separator();
									if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
										if (EditorUtility.DisplayDialog(playgroundLanguage.deleteBrush, 
											brushNames[i]+" "+playgroundLanguage.deleteBrushText, 
			                                playgroundLanguage.yes, 
			                                playgroundLanguage.no)) {
												AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(brushPrefabs[i] as UnityEngine.Object));
												LoadBrushes();
											}
									}
									EditorGUILayout.EndHorizontal();
									EditorGUILayout.EndVertical();
								}
							}
							
							// Create new brush
							if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
								PlaygroundCreateBrushWindowC.ShowWindow();
							}
						}
						
						EditorGUILayout.EndVertical();
						EditorGUILayout.Separator();
						
						GUILayout.BeginHorizontal();
						EditorGUILayout.PrefixLabel(playgroundLanguage.brushShape);
						paintTexture = EditorGUILayout.ObjectField(paintTexture, typeof(Texture2D), false) as Texture2D;
						GUILayout.EndHorizontal();
						playgroundParticlesScriptReference.paint.brush.detail = (BRUSHDETAILC)EditorGUILayout.EnumPopup(playgroundLanguage.detail, playgroundParticlesScriptReference.paint.brush.detail);
						playgroundParticlesScriptReference.paint.brush.scale = EditorGUILayout.Slider(playgroundLanguage.brushScale, playgroundParticlesScriptReference.paint.brush.scale, playgroundSettings.minimumAllowedBrushScale, playgroundSettings.maximumAllowedBrushScale);
						playgroundParticlesScriptReference.paint.brush.distance = EditorGUILayout.FloatField(playgroundLanguage.brushDistance, playgroundParticlesScriptReference.paint.brush.distance);
						
						if (paintTexture!=null && paintTexture!=playgroundParticlesScriptReference.paint.brush.texture) {
							playgroundParticlesScriptReference.paint.brush.SetTexture(paintTexture as Texture2D);
							selectedBrushPreset = -1;
						}
						
						useBrushColor = EditorGUILayout.Toggle(playgroundLanguage.useBrushColor, useBrushColor);
					}
					
					
					// Eraser
					if (selectedPaintMode==2) {
						eraserRadius = EditorGUILayout.Slider(playgroundLanguage.eraserRadius, eraserRadius, playgroundSettings.minimumEraserRadius, playgroundSettings.maximumEraserRadius);
					}
					
					EditorGUILayout.EndVertical();
					EditorGUILayout.Separator();
					
					if (selectedPaintMode==1 && useBrushColor) GUI.enabled = false;
					paintColor = EditorGUILayout.ColorField(playgroundLanguage.color, paintColor);
					GUI.enabled = true;
					if (showNoAlphaWarning && !useBrushColor) {
						EditorGUILayout.HelpBox(playgroundLanguage.noAlphaColorInPaint, MessageType.Warning);
					}
					showNoAlphaWarning = (paintColor.a == 0);

					EditorGUILayout.PropertyField(paintCollisionType, new GUIContent(playgroundLanguage.paintCollisionType));
					if (paintCollisionType.enumValueIndex==1) {
						GUILayout.BeginHorizontal();
						GUILayout.Space (16);
						GUILayout.Label(playgroundLanguage.depth);
						EditorGUILayout.Separator();
						float minDepth = playgroundParticlesScriptReference.paint.minDepth;
						float maxDepth = playgroundParticlesScriptReference.paint.maxDepth;
						EditorGUILayout.MinMaxSlider(ref minDepth, ref maxDepth, -playgroundSettings.maximumAllowedDepth, playgroundSettings.maximumAllowedDepth, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
						playgroundParticlesScriptReference.paint.minDepth = Mathf.Clamp (minDepth, -playgroundSettings.maximumAllowedDepth, playgroundSettings.maximumAllowedDepth);
						playgroundParticlesScriptReference.paint.maxDepth = Mathf.Clamp (maxDepth, -playgroundSettings.maximumAllowedDepth, playgroundSettings.maximumAllowedDepth);
						playgroundParticlesScriptReference.paint.minDepth = EditorGUILayout.FloatField(playgroundParticlesScriptReference.paint.minDepth, GUILayout.Width(50));
						playgroundParticlesScriptReference.paint.maxDepth = EditorGUILayout.FloatField(playgroundParticlesScriptReference.paint.maxDepth, GUILayout.Width(50));
						GUILayout.EndHorizontal();
					}
					EditorGUILayout.PropertyField(paintLayerMask, new GUIContent(playgroundLanguage.paintMask));
					playgroundParticlesScriptReference.paint.spacing = EditorGUILayout.Slider(playgroundLanguage.paintSpacing, playgroundParticlesScriptReference.paint.spacing, .0f, playgroundSettings.maximumAllowedPaintSpacing);
					if (isEditingInHierarchy)
						PlaygroundC.reference.paintMaxPositions = EditorGUILayout.IntSlider(playgroundLanguage.maxPaintPositions, PlaygroundC.reference.paintMaxPositions, 0, playgroundSettings.maximumAllowedPaintPositions);
					playgroundParticlesScriptReference.paint.exceedMaxStopsPaint = EditorGUILayout.Toggle(playgroundLanguage.exceedMaxStopsPaint, playgroundParticlesScriptReference.paint.exceedMaxStopsPaint);
					if (playgroundParticlesScriptReference.paint.exceedMaxStopsPaint && playgroundParticlesScriptReference.paint.positionLength>=PlaygroundC.reference.paintMaxPositions) {
						EditorGUILayout.HelpBox(playgroundLanguage.exceededMaxPaint, MessageType.Warning);
					}

					if (isEditingInHierarchy) {
						GUILayout.BeginHorizontal();
						EditorGUILayout.PrefixLabel(playgroundLanguage.paint+":");
						ProgressBar((playgroundParticlesScriptReference.paint.positionLength*1f)/PlaygroundC.reference.paintMaxPositions, playgroundParticlesScriptReference.paint.positionLength+"/"+PlaygroundC.reference.paintMaxPositions, Mathf.FloorToInt(Screen.width/2.2f)-65);
						EditorGUILayout.Separator();
						if(GUILayout.Button(playgroundLanguage.setParticleCount, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) && isEditingInHierarchy){
							playgroundParticlesScriptReference.particleCount = playgroundParticlesScriptReference.paint.positionLength;
						}
						if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
							particleCount.intValue = particleCount.intValue+playgroundParticlesScriptReference.paint.positionLength;
						GUILayout.EndHorizontal();
					}
					EditorGUILayout.Separator();
					
					GUILayout.BeginHorizontal();
					GUI.enabled = GUI.enabled&&isEditingInHierarchy;
					if (inPaintMode && GUI.enabled)
						GUI.backgroundColor = paintActiveColor;
					if (GUILayout.Button((inPaintMode?playgroundLanguage.stop:playgroundLanguage.start)+" "+playgroundLanguage.paint+" ", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
						StartStopPaint();
					}
					GUI.enabled = (playgroundParticlesScriptReference.paint.positionLength>0);
					if(GUILayout.Button(playgroundLanguage.clear, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
						ClearPaint();
					}
					GUI.enabled = true;
					GUILayout.EndHorizontal();
					EditorGUILayout.Separator();
					GUI.backgroundColor = whiteColor;
					if (inPaintMode && selectedPaintMode==1 && paintTexture==null)
						EditorGUILayout.HelpBox(playgroundLanguage.assignATexture, MessageType.Warning);
					if (playgroundParticlesScriptReference.paint.positionLength-1>playgroundParticlesScriptReference.particleCount)
						EditorGUILayout.HelpBox(playgroundLanguage.morePaintThanPositions, MessageType.Warning);
					
					if (GUI.changed) {
						SetBrushStyle();
					}
				
				// Source is Spline
				} else if (source.intValue == 7) {
					playgroundParticlesScriptReference.splineTimeOffset = EditorGUILayout.Slider (playgroundLanguage.timeOffset, playgroundParticlesScriptReference.splineTimeOffset, 0, 1f);
					GUI.enabled = playgroundParticlesScriptReference.splines.Count>1;
					playgroundParticlesScriptReference.treatAsOneSpline = EditorGUILayout.Toggle (playgroundLanguage.treatAsOneSpline, playgroundParticlesScriptReference.treatAsOneSpline);
					GUI.enabled = true;

					EditorGUILayout.Separator();

					EditorGUILayout.BeginVertical(boxStyle);
					GUILayout.BeginHorizontal();
					playgroundSettings.splineListFoldout = GUILayout.Toggle(playgroundSettings.splineListFoldout, playgroundLanguage.splines, EditorStyles.foldout);
					GUILayout.Label (playgroundParticlesScriptReference.splines.Count.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
					GUILayout.EndHorizontal();
					if (playgroundSettings.splineListFoldout) {
						bool hasDisabledSpline = false;
						if (playgroundParticlesScriptReference.splines.Count>0) {
							for (int i = 0; i<playgroundParticlesScriptReference.splines.Count; i++) {
								if (playgroundParticlesScriptReference.splines[i]==null || !playgroundParticlesScriptReference.splines[i].enabled) hasDisabledSpline = true;
								EditorGUILayout.BeginHorizontal(boxStyle);

								GUILayout.Label(i.ToString(), EditorStyles.miniLabel, new GUILayoutOption[]{GUILayout.Width(18)});
								PlaygroundSpline currentSpline = playgroundParticlesScriptReference.splines[i];
								playgroundParticlesScriptReference.splines[i] = (PlaygroundSpline)EditorGUILayout.ObjectField(playgroundLanguage.spline, playgroundParticlesScriptReference.splines[i], typeof(PlaygroundSpline), true);
								if (playgroundParticlesScriptReference.splines[i]!=null) {
									if (currentSpline!=playgroundParticlesScriptReference.splines[i]) {
										playgroundParticlesScriptReference.splines[i].AddUser (playgroundParticlesScriptReference.transform);
									}
								}
								GUI.enabled = playgroundParticlesScriptReference.splines[i]!=null;
								if (GUILayout.Button (playgroundLanguage.edit, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
									Selection.activeGameObject = playgroundParticlesScriptReference.splines[i].gameObject;
								GUI.enabled = true;
								GUI.enabled = (playgroundParticlesScriptReference.splines.Count>1);
								if(GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
									sourceSplines.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.splines.Count-1:i-1);
								}
								if(GUILayout.Button(playgroundLanguage.downSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
									sourceSplines.MoveArrayElement(i, i<playgroundParticlesScriptReference.splines.Count-1?i+1:0);
								}
								GUI.enabled = true;
								if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
									playgroundParticlesScriptReference.splines.RemoveAt(i);
									playgroundParticles.ApplyModifiedProperties();
									return;
								}
								EditorGUILayout.EndHorizontal();
							}
							EditorGUILayout.Separator();

						} else {
							EditorGUILayout.HelpBox(playgroundLanguage.noSplinesCreated, MessageType.Info);
						}
						if (playgroundParticlesScriptReference.splines.Count==1 && playgroundParticlesScriptReference.splines[0]==null)
							EditorGUILayout.HelpBox(playgroundLanguage.newSplineMessage, MessageType.Info);
						else if (hasDisabledSpline)
							EditorGUILayout.HelpBox(playgroundLanguage.allSplinesMustBeAssignedMessage, MessageType.Warning);
					
						EditorGUILayout.BeginHorizontal();
						if (GUILayout.Button (playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
							PlaygroundC.CreateSpline(playgroundParticlesScriptReference);
							Selection.activeGameObject = playgroundParticlesScriptReference.splines[playgroundParticlesScriptReference.splines.Count-1].gameObject;
						}
						if (GUILayout.Button (playgroundLanguage.newEmpty, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
							playgroundParticlesScriptReference.splines.Add (null);
						}
						EditorGUILayout.Separator();
						if (GUILayout.Button (playgroundLanguage.reverse, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
							playgroundParticlesScriptReference.splines.Reverse();
						}
						EditorGUILayout.EndHorizontal();
					}
					EditorGUILayout.EndVertical();
				}

				EditorGUILayout.Separator();
				
			}
			
			// Particle Settings
			if (GUILayout.Button(playgroundLanguage.particleSettings+" ("+playgroundParticlesScriptReference.particleCount+")", EditorStyles.toolbarDropDown)) playgroundSettings.particleSettingsFoldout=!playgroundSettings.particleSettingsFoldout;
			if (playgroundSettings.particleSettingsFoldout) {
				
				if (source.intValue==4)
					EditorGUILayout.HelpBox(playgroundLanguage.someFeaturesInScript, MessageType.Info);

				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.particleSettingsParticleCountFoldout = GUILayout.Toggle(playgroundSettings.particleSettingsParticleCountFoldout, playgroundLanguage.particleCount, EditorStyles.foldout);
				GUILayout.Label (playgroundParticlesScriptReference.particleCount.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.particleSettingsParticleCountFoldout) {
					GUILayout.BeginHorizontal();
					GUI.enabled = !playgroundParticlesScriptReference.isSnapshot;
					particleCount.intValue = EditorGUILayout.IntSlider(playgroundLanguage.particleCount, particleCount.intValue, 0, playgroundSettings.maximumAllowedParticles);
					if(GUILayout.Button("x2", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
						particleCount.intValue *= 2;
					GUI.enabled = true;
					GUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();

				// Overflow Offset
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.particleSettingsOverflowOffsetFoldout = GUILayout.Toggle(playgroundSettings.particleSettingsOverflowOffsetFoldout, playgroundLanguage.overflowOffset, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.HasOverflow()?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.particleSettingsOverflowOffsetFoldout) {
					GUI.enabled=(source.intValue!=4&&source.intValue!=7);
					EditorGUILayout.PropertyField(overflowMode, new GUIContent(
						playgroundLanguage.overflowMode, 
						playgroundLanguage.overflowModeDescription)
					);
					overflowOffset.vector3Value = EditorGUILayout.Vector3Field(playgroundLanguage.overflowOffset, overflowOffset.vector3Value);
					GUI.enabled=true;
					if (source.intValue==7)
						EditorGUILayout.HelpBox(playgroundLanguage.overflowOffsetSplineMessage, MessageType.Info);
				}
				GUILayout.EndVertical();

				// Source Scattering
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.particleSettingsScatterFoldout = GUILayout.Toggle(playgroundSettings.particleSettingsScatterFoldout, playgroundLanguage.sourceScatter, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.applySourceScatter?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.particleSettingsScatterFoldout) {
					GUI.enabled=(source.intValue!=4);
					bool prevScatterEnabled = playgroundParticlesScriptReference.applySourceScatter;
					MINMAXVECTOR3METHOD prevScatterMethod = playgroundParticlesScriptReference.sourceScatterMethod;
					Vector3 prevScatterMin = playgroundParticlesScriptReference.sourceScatterMin;
					Vector3 prevScatterMax = playgroundParticlesScriptReference.sourceScatterMax;

					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.applySourceScatter = EditorGUILayout.ToggleLeft(playgroundLanguage.sourceScatter, playgroundParticlesScriptReference.applySourceScatter);
					GUI.enabled = (source.intValue!=4 && playgroundParticlesScriptReference.applySourceScatter);
					if (GUILayout.Button (playgroundLanguage.reset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
						playgroundParticlesScriptReference.sourceScatterMin = Vector3.zero;
						playgroundParticlesScriptReference.sourceScatterMax = Vector3.zero;
					}
					EditorGUILayout.EndHorizontal();
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.sourceScatterMethod = (MINMAXVECTOR3METHOD)EditorGUILayout.EnumPopup (playgroundLanguage.method, playgroundParticlesScriptReference.sourceScatterMethod);
					EditorGUI.indentLevel--;

					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label(playgroundParticlesScriptReference.sourceScatterMethod==MINMAXVECTOR3METHOD.Rectangular||playgroundParticlesScriptReference.sourceScatterMethod==MINMAXVECTOR3METHOD.RectangularLinear?"X":playgroundLanguage.range, GUILayout.Width(50));
					EditorGUILayout.Separator();
					float sourceScatterMinX = playgroundParticlesScriptReference.sourceScatterMin.x;
					float sourceScatterMaxX = playgroundParticlesScriptReference.sourceScatterMax.x;
					EditorGUILayout.MinMaxSlider(ref sourceScatterMinX, ref sourceScatterMaxX, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
					playgroundParticlesScriptReference.sourceScatterMin.x = Mathf.Clamp (sourceScatterMinX, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter);
					playgroundParticlesScriptReference.sourceScatterMax.x = Mathf.Clamp (sourceScatterMaxX, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter);
					playgroundParticlesScriptReference.sourceScatterMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.sourceScatterMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					
					if (playgroundParticlesScriptReference.sourceScatterMethod==MINMAXVECTOR3METHOD.Rectangular || playgroundParticlesScriptReference.sourceScatterMethod==MINMAXVECTOR3METHOD.RectangularLinear) {
						// Y
						GUILayout.BeginHorizontal();
						GUILayout.Space(16);
						GUILayout.Label("Y");
						EditorGUILayout.Separator();
						float sourceScatterMinY = playgroundParticlesScriptReference.sourceScatterMin.y;
						float sourceScatterMaxY = playgroundParticlesScriptReference.sourceScatterMax.y;
						EditorGUILayout.MinMaxSlider(ref sourceScatterMinY, ref sourceScatterMaxY, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
						playgroundParticlesScriptReference.sourceScatterMin.y = Mathf.Clamp (sourceScatterMinY, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter);
						playgroundParticlesScriptReference.sourceScatterMax.y = Mathf.Clamp (sourceScatterMaxY, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter);
						playgroundParticlesScriptReference.sourceScatterMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.y, GUILayout.Width(50));
						playgroundParticlesScriptReference.sourceScatterMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.y, GUILayout.Width(50));
						GUILayout.EndHorizontal();
						// Z
						GUILayout.BeginHorizontal();
						GUILayout.Space(16);
						GUILayout.Label("Z");
						EditorGUILayout.Separator();
						float sourceScatterMinZ = playgroundParticlesScriptReference.sourceScatterMin.z;
						float sourceScatterMaxZ = playgroundParticlesScriptReference.sourceScatterMax.z;
						EditorGUILayout.MinMaxSlider(ref sourceScatterMinZ, ref sourceScatterMaxZ, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
						playgroundParticlesScriptReference.sourceScatterMin.z = Mathf.Clamp (sourceScatterMinZ, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter);
						playgroundParticlesScriptReference.sourceScatterMax.z = Mathf.Clamp (sourceScatterMaxZ, -playgroundSettings.maximumAllowedSourceScatter, playgroundSettings.maximumAllowedSourceScatter);
						playgroundParticlesScriptReference.sourceScatterMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.z, GUILayout.Width(50));
						playgroundParticlesScriptReference.sourceScatterMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.z, GUILayout.Width(50));
						GUILayout.EndHorizontal();
					}
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.scatterScale = EditorGUILayout.Vector3Field (playgroundLanguage.scale, playgroundParticlesScriptReference.scatterScale);
					EditorGUI.indentLevel--;
					/*
					if (playgroundParticlesScriptReference.sourceScatterMethod==MINMAXVECTOR3METHOD.SphericalSector || playgroundParticlesScriptReference.sourceScatterMethod==MINMAXVECTOR3METHOD.SphericalSectorLinear) {
						EditorGUI.indentLevel++;
						playgroundParticlesScriptReference.sourceScatterMin.y = EditorGUILayout.Slider(playgroundLanguage.sectorA, playgroundParticlesScriptReference.sourceScatterMin.y, -1f, 1f);
						playgroundParticlesScriptReference.sourceScatterMax.y = EditorGUILayout.Slider(playgroundLanguage.sectorB, playgroundParticlesScriptReference.sourceScatterMax.y, 0, 1f);
						EditorGUI.indentLevel--;
					}
					*/
					GUI.enabled = true;
					
					if (prevScatterEnabled!=playgroundParticlesScriptReference.applySourceScatter || prevScatterMin!=playgroundParticlesScriptReference.sourceScatterMin || prevScatterMax!=playgroundParticlesScriptReference.sourceScatterMax || prevScatterMethod!=playgroundParticlesScriptReference.sourceScatterMethod) {
						if (isEditingInHierarchy) {
							LifetimeSorting();
							playgroundParticlesScriptReference.RefreshScatter();
						}
					}
				}
				GUILayout.EndVertical();

				// Emission
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.particleSettingsEmissionFoldout = GUILayout.Toggle(playgroundSettings.particleSettingsEmissionFoldout, playgroundLanguage.emission, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.emit?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.particleSettingsEmissionFoldout) {
					bool prevEmit = playgroundParticlesScriptReference.emit;
					bool prevLoop = playgroundParticlesScriptReference.loop;
					playgroundParticlesScriptReference.emit = EditorGUILayout.Toggle(playgroundLanguage.emitParticles, playgroundParticlesScriptReference.emit);
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.loop = EditorGUILayout.Toggle(playgroundLanguage.loop, playgroundParticlesScriptReference.loop);
					if (prevEmit!=playgroundParticlesScriptReference.emit || prevLoop!=playgroundParticlesScriptReference.loop&&playgroundParticlesScriptReference.loop && !playgroundParticlesScriptReference.IsPrewarming()) {
						//playgroundParticlesScriptReference.simulationStarted = PlaygroundC.globalTime;
						//playgroundParticlesScriptReference.loopExceeded = false;
						//playgroundParticlesScriptReference.loopExceededOnParticle = -1;
						playgroundParticlesScriptReference.particleSystemGameObject.SetActive(true);
					}
					GUI.enabled = !loop.boolValue;

					EditorGUI.indentLevel++;
					EditorGUILayout.BeginHorizontal();
					disableOnDone.boolValue = EditorGUILayout.Toggle(playgroundLanguage.disableOnDone, disableOnDone.boolValue, GUILayout.ExpandWidth(false));
					GUI.enabled = GUI.enabled&&disableOnDone.boolValue;
					EditorGUILayout.PropertyField(disableOnDoneRoutine, new GUIContent(""), GUILayout.ExpandWidth(true));
					EditorGUILayout.EndHorizontal();
					EditorGUI.indentLevel--;

					GUI.enabled = true;
					playgroundParticlesScriptReference.clearParticlesOnEmissionStop = EditorGUILayout.Toggle (playgroundLanguage.clearOnStop, playgroundParticlesScriptReference.clearParticlesOnEmissionStop);
					EditorGUI.indentLevel--;
					GUI.enabled=(source.intValue!=4);
					emissionRate.floatValue = EditorGUILayout.Slider(playgroundLanguage.emissionRate, emissionRate.floatValue, 0, 1f);
				}
				GUILayout.EndVertical();

				// Size
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.particleSettingsSizeFoldout = GUILayout.Toggle(playgroundSettings.particleSettingsSizeFoldout, playgroundLanguage.size, EditorStyles.foldout);
				GUILayout.Label (playgroundParticlesScriptReference.sizeMin.ToString("f1")+"-"+playgroundParticlesScriptReference.sizeMax.ToString("f1")+" ("+playgroundParticlesScriptReference.scale.ToString("f1")+")", EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.particleSettingsSizeFoldout) {
					GUILayout.BeginHorizontal();
					GUILayout.Label(playgroundLanguage.size);
					EditorGUILayout.Separator();
					float sizeMin = playgroundParticlesScriptReference.sizeMin;
					float sizeMax = playgroundParticlesScriptReference.sizeMax;
					EditorGUILayout.MinMaxSlider(ref sizeMin, ref sizeMax, 0, playgroundSettings.maximumAllowedSize, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
					playgroundParticlesScriptReference.sizeMin = Mathf.Clamp(sizeMin, 0, playgroundSettings.maximumAllowedSize);
					playgroundParticlesScriptReference.sizeMax = Mathf.Clamp(sizeMax, 0, playgroundSettings.maximumAllowedSize);
					playgroundParticlesScriptReference.sizeMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sizeMin, GUILayout.Width(50));
					playgroundParticlesScriptReference.sizeMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sizeMax, GUILayout.Width(50));
					GUILayout.EndHorizontal();

					playgroundParticlesScriptReference.scale = EditorGUILayout.Slider(playgroundLanguage.particleScale, playgroundParticlesScriptReference.scale, 0, playgroundSettings.maximumAllowedScale);

					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.applyLifetimeSize = EditorGUILayout.ToggleLeft (playgroundLanguage.lifetimeSize, playgroundParticlesScriptReference.applyLifetimeSize, GUILayout.Width (120));
					GUILayout.FlexibleSpace();
					GUI.enabled = playgroundParticlesScriptReference.applyLifetimeSize;
					lifetimeSize.animationCurveValue = EditorGUILayout.CurveField(lifetimeSize.animationCurveValue, GUILayout.Width (Mathf.CeilToInt(Screen.width/1.805f)));
					GUI.enabled = true;
					EditorGUILayout.EndHorizontal();

					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.applyParticleArraySize = EditorGUILayout.ToggleLeft (playgroundLanguage.arraySize, playgroundParticlesScriptReference.applyParticleArraySize, GUILayout.Width (120));
					GUILayout.FlexibleSpace();
					GUI.enabled = playgroundParticlesScriptReference.applyParticleArraySize;
					arraySize.animationCurveValue = EditorGUILayout.CurveField(arraySize.animationCurveValue, GUILayout.Width (Mathf.CeilToInt(Screen.width/1.805f)));
					GUI.enabled = true;
					EditorGUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();

				// Rotation
				GUILayout.BeginVertical(boxStyle);
				bool hasRotation = playgroundParticlesScriptReference.initialRotationMin!=0||playgroundParticlesScriptReference.initialRotationMax!=0||playgroundParticlesScriptReference.rotationSpeedMin!=0||playgroundParticlesScriptReference.rotationSpeedMax!=0||playgroundParticlesScriptReference.rotateTowardsDirection;
				GUILayout.BeginHorizontal();
				playgroundSettings.particleSettingsRotationFoldout = GUILayout.Toggle(playgroundSettings.particleSettingsRotationFoldout, playgroundLanguage.rotation, EditorStyles.foldout);
				GUILayout.Label ((hasRotation?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.particleSettingsRotationFoldout) {
					GUILayout.BeginHorizontal();
					GUILayout.Label(playgroundLanguage.initialRotation);
					EditorGUILayout.Separator();
					float initialRotationMin = playgroundParticlesScriptReference.initialRotationMin;
					float initialRotationMax = playgroundParticlesScriptReference.initialRotationMax;
					EditorGUILayout.MinMaxSlider(ref initialRotationMin, ref initialRotationMax, -playgroundSettings.maximumAllowedRotation, playgroundSettings.maximumAllowedRotation, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
					playgroundParticlesScriptReference.initialRotationMin = Mathf.Clamp (initialRotationMin, -playgroundSettings.maximumAllowedRotation, playgroundSettings.maximumAllowedRotation);
					playgroundParticlesScriptReference.initialRotationMax = Mathf.Clamp (initialRotationMax, -playgroundSettings.maximumAllowedRotation, playgroundSettings.maximumAllowedRotation);
					playgroundParticlesScriptReference.initialRotationMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialRotationMin, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialRotationMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialRotationMax, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					
					GUI.enabled = !playgroundParticlesScriptReference.rotateTowardsDirection;
					GUILayout.BeginHorizontal();
					GUILayout.Label(playgroundLanguage.rotation);
					EditorGUILayout.Separator();
					float rotationSpeedMin = playgroundParticlesScriptReference.rotationSpeedMin;
					float rotationSpeedMax = playgroundParticlesScriptReference.rotationSpeedMax;
					EditorGUILayout.MinMaxSlider(ref rotationSpeedMin, ref rotationSpeedMax, -playgroundSettings.maximumAllowedRotation, playgroundSettings.maximumAllowedRotation, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
					playgroundParticlesScriptReference.rotationSpeedMin = Mathf.Clamp (rotationSpeedMin, -playgroundSettings.maximumAllowedRotation, playgroundSettings.maximumAllowedRotation);
					playgroundParticlesScriptReference.rotationSpeedMax = Mathf.Clamp (rotationSpeedMax, -playgroundSettings.maximumAllowedRotation, playgroundSettings.maximumAllowedRotation);
					playgroundParticlesScriptReference.rotationSpeedMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.rotationSpeedMin, GUILayout.Width(50));
					playgroundParticlesScriptReference.rotationSpeedMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.rotationSpeedMax, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					GUI.enabled = true;
					
					playgroundParticlesScriptReference.rotateTowardsDirection = EditorGUILayout.Toggle(playgroundLanguage.rotateTowardsDirection, playgroundParticlesScriptReference.rotateTowardsDirection);
					GUI.enabled = playgroundParticlesScriptReference.rotateTowardsDirection;
						EditorGUI.indentLevel++;
						playgroundParticlesScriptReference.rotationNormal = EditorGUILayout.Vector3Field(playgroundLanguage.rotationNormal, playgroundParticlesScriptReference.rotationNormal);
						playgroundParticlesScriptReference.rotationNormal.x = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.x, -1, 1);
						playgroundParticlesScriptReference.rotationNormal.y = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.y, -1, 1);
						playgroundParticlesScriptReference.rotationNormal.z = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.z, -1, 1);
						EditorGUI.indentLevel--;
					
					GUI.enabled = true;
				}
				GUILayout.EndVertical();

				// Lifetime
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.particleSettingsLifetimeFoldout = GUILayout.Toggle(playgroundSettings.particleSettingsLifetimeFoldout, playgroundLanguage.lifetime, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.lifetimeValueMethod==VALUEMETHOD.Constant?playgroundParticlesScriptReference.lifetime.ToString("f1"):playgroundParticlesScriptReference.lifetimeMin.ToString("f1")+"-"+playgroundParticlesScriptReference.lifetime.ToString("f1"))+" ("+playgroundParticlesScriptReference.sorting.ToString()+")", EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.particleSettingsLifetimeFoldout) {
					EditorGUILayout.BeginHorizontal();
					if (playgroundParticlesScriptReference.lifetimeValueMethod==VALUEMETHOD.Constant) {
						lifetime.floatValue = EditorGUILayout.Slider(playgroundLanguage.lifetime, lifetime.floatValue, 0, playgroundSettings.maximumAllowedLifetime);
					} else {
						GUILayout.Label(playgroundLanguage.lifetime);
						EditorGUILayout.Separator();
						float lifetimeMin = playgroundParticlesScriptReference.lifetimeMin;
						float lifetimeMax = playgroundParticlesScriptReference.lifetime;
						EditorGUILayout.MinMaxSlider(ref lifetimeMin, ref lifetimeMax, 0, playgroundSettings.maximumAllowedLifetime, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-125));
						playgroundParticlesScriptReference.lifetimeMin = Mathf.Clamp (lifetimeMin, 0, playgroundSettings.maximumAllowedLifetime);
						playgroundParticlesScriptReference.lifetime = Mathf.Clamp (lifetimeMax, 0, playgroundSettings.maximumAllowedLifetime);
						playgroundParticlesScriptReference.lifetimeMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.lifetimeMin, GUILayout.Width(50));
						playgroundParticlesScriptReference.lifetime = EditorGUILayout.FloatField(playgroundParticlesScriptReference.lifetime, GUILayout.Width(50));
					}
					playgroundParticlesScriptReference.lifetimeValueMethod = (VALUEMETHOD)EditorGUILayout.EnumPopup(playgroundParticlesScriptReference.lifetimeValueMethod, EditorStyles.toolbarDropDown, GUILayout.MaxWidth (12));
					EditorGUILayout.EndHorizontal();
					EditorGUI.indentLevel++;
					// Sorting
					GUI.enabled=(source.intValue!=4);
					selectedSort = sorting.intValue;
					EditorGUILayout.PropertyField(sorting, new GUIContent(
						playgroundLanguage.lifetimeSorting, 
						playgroundLanguage.lifetimeSortingDescription)
					);
					
					if (sorting.intValue==5||sorting.intValue==6) {
						EditorGUI.indentLevel++;
						EditorGUILayout.BeginHorizontal();

						switch (playgroundParticlesScriptReference.nearestNeighborOriginMethod) {
						case NEARESTNEIGHBORORIGINMETHOD.SourcePoint:
							playgroundParticlesScriptReference.nearestNeighborOrigin = EditorGUILayout.IntSlider(playgroundLanguage.sortOrigin, playgroundParticlesScriptReference.nearestNeighborOrigin, 0, playgroundParticlesScriptReference.particleCount>0?playgroundParticlesScriptReference.particleCount-1:0);
						break;
						case NEARESTNEIGHBORORIGINMETHOD.Vector3:
							playgroundParticlesScriptReference.nearestNeighborOriginVector3 = EditorGUILayout.Vector3Field (playgroundLanguage.sortOrigin, playgroundParticlesScriptReference.nearestNeighborOriginVector3);
						break;
						case NEARESTNEIGHBORORIGINMETHOD.Transform:
							playgroundParticlesScriptReference.nearestNeighborOriginTransform = (Transform)EditorGUILayout.ObjectField(playgroundLanguage.sortOrigin, playgroundParticlesScriptReference.nearestNeighborOriginTransform, typeof(Transform), true);
						break;
						}
						if (GUILayout.Button(playgroundParticlesScriptReference.nearestNeighborOriginMethod==NEARESTNEIGHBORORIGINMETHOD.SourcePoint?playgroundLanguage.sourcePoint:playgroundParticlesScriptReference.nearestNeighborOriginMethod==NEARESTNEIGHBORORIGINMETHOD.Vector3?playgroundLanguage.vector3:playgroundLanguage.transform, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
							if (playgroundParticlesScriptReference.nearestNeighborOriginMethod==NEARESTNEIGHBORORIGINMETHOD.SourcePoint)
								playgroundParticlesScriptReference.nearestNeighborOriginMethod = NEARESTNEIGHBORORIGINMETHOD.Vector3;
							else if (playgroundParticlesScriptReference.nearestNeighborOriginMethod==NEARESTNEIGHBORORIGINMETHOD.Vector3)
								playgroundParticlesScriptReference.nearestNeighborOriginMethod = NEARESTNEIGHBORORIGINMETHOD.Transform;
							else if (playgroundParticlesScriptReference.nearestNeighborOriginMethod==NEARESTNEIGHBORORIGINMETHOD.Transform)
								playgroundParticlesScriptReference.nearestNeighborOriginMethod = NEARESTNEIGHBORORIGINMETHOD.SourcePoint;
						}
						EditorGUILayout.EndHorizontal();
						EditorGUI.indentLevel--;
					}
					
					// Custom lifetime sorting
					if (sorting.intValue==7) {
						EditorGUI.indentLevel++;
						playgroundParticlesScriptReference.lifetimeSorting = EditorGUILayout.CurveField(playgroundLanguage.customSorting, playgroundParticlesScriptReference.lifetimeSorting);
						EditorGUI.indentLevel--;
						bool changed = prevLifetimeSortingKeys.Length!=playgroundParticlesScriptReference.lifetimeSorting.keys.Length;
						if (!changed)
							for (int k = 0; k<prevLifetimeSortingKeys.Length; k++) {
								if (playgroundParticlesScriptReference.lifetimeSorting.keys[k].value != prevLifetimeSortingKeys[k].value || playgroundParticlesScriptReference.lifetimeSorting.keys[k].time != prevLifetimeSortingKeys[k].time) {
									changed = true;
								}
							}
						if (changed) {
							LifetimeSorting();
							prevLifetimeSortingKeys = playgroundParticlesScriptReference.lifetimeSorting.keys;
						}
					}
					
					float prevLifetimeOffset = playgroundParticlesScriptReference.lifetimeOffset;
					playgroundParticlesScriptReference.lifetimeOffset = EditorGUILayout.Slider(playgroundLanguage.lifetimeOffset, playgroundParticlesScriptReference.lifetimeOffset, -playgroundParticlesScriptReference.lifetime, playgroundParticlesScriptReference.lifetime);
					if (prevLifetimeOffset!=playgroundParticlesScriptReference.lifetimeOffset) {
						LifetimeSortingAll();
					}
					EditorGUI.indentLevel--;
					GUI.enabled = GUI.enabled&&playgroundParticlesScriptReference.sorting!=SORTINGC.Burst;
					playgroundParticlesScriptReference.lifetimeEmission = EditorGUILayout.Slider (playgroundLanguage.lifetimeEmission, playgroundParticlesScriptReference.lifetimeEmission, 0, 1f);
					GUI.enabled=true;
				}
				GUILayout.EndVertical();

				// Particle Mask
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.particleSettingsMaskFoldout = GUILayout.Toggle(playgroundSettings.particleSettingsMaskFoldout, playgroundLanguage.particleMask, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.applyParticleMask?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.particleSettingsMaskFoldout) {
					playgroundParticlesScriptReference.applyParticleMask = EditorGUILayout.Toggle (playgroundLanguage.particleMask, playgroundParticlesScriptReference.applyParticleMask);
					GUI.enabled = playgroundParticlesScriptReference.applyParticleMask;
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.particleMask = EditorGUILayout.IntSlider(playgroundLanguage.particleMask, playgroundParticlesScriptReference.particleMask, 0, particleCount.intValue);
					playgroundParticlesScriptReference.particleMaskTime = EditorGUILayout.Slider(playgroundLanguage.maskTime, playgroundParticlesScriptReference.particleMaskTime, 0, playgroundSettings.maximumAllowedTransitionTime);
					playgroundParticlesScriptReference.particleMaskSorting = (MASKSORTINGC)EditorGUILayout.EnumPopup(playgroundLanguage.maskSorting, playgroundParticlesScriptReference.particleMaskSorting);
					EditorGUI.indentLevel--;
					GUI.enabled = true;
				}
				GUILayout.EndVertical();
			}
						
			// Force Settings
			if (GUILayout.Button(onlySourcePositioning.boolValue||playgroundParticlesScriptReference.onlyLifetimePositioning||(playgroundParticlesScriptReference.axisConstraints.x&&playgroundParticlesScriptReference.axisConstraints.y&&playgroundParticlesScriptReference.axisConstraints.z)?playgroundLanguage.forces+" ("+playgroundLanguage.off+")":playgroundParticlesScriptReference.turbulenceType==TURBULENCETYPE.None?playgroundLanguage.forces:playgroundLanguage.forces+" ("+playgroundParticlesScriptReference.turbulenceType+" "+playgroundLanguage.turbulence+")", EditorStyles.toolbarDropDown)) 
				playgroundSettings.forcesFoldout=!playgroundSettings.forcesFoldout;
			if (playgroundSettings.forcesFoldout) {

				// Force annihilation messages
				if (onlySourcePositioning.boolValue) {
					GUI.enabled = true;
					EditorGUILayout.HelpBox(playgroundLanguage.onlySourcePositionsDescription, MessageType.Info);
				}
				if (playgroundParticlesScriptReference.onlyLifetimePositioning && !onlySourcePositioning.boolValue) {
					GUI.enabled = true;
					EditorGUILayout.HelpBox(playgroundLanguage.onlyLifetimePositioningDescription, MessageType.Info);
				}
				if (playgroundParticlesScriptReference.axisConstraints.x&&playgroundParticlesScriptReference.axisConstraints.y&&playgroundParticlesScriptReference.axisConstraints.z && !playgroundParticlesScriptReference.onlyLifetimePositioning && !onlySourcePositioning.boolValue) {
					GUI.enabled = true;
					EditorGUILayout.HelpBox(playgroundLanguage.axisConstraintsDescription, MessageType.Info);
				}

				// Force Annihilation
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.forceAnnihilationFoldout = GUILayout.Toggle(playgroundSettings.forceAnnihilationFoldout, playgroundLanguage.forceAnnihilation, EditorStyles.foldout);
				GUILayout.Label (((playgroundParticlesScriptReference.onlyLifetimePositioning||onlySourcePositioning.boolValue||playgroundParticlesScriptReference.axisConstraints.x||playgroundParticlesScriptReference.axisConstraints.y||playgroundParticlesScriptReference.axisConstraints.z||playgroundParticlesScriptReference.maxVelocity==0||playgroundParticlesScriptReference.transitionBackToSource)?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.forceAnnihilationFoldout) {

					EditorGUILayout.Separator();

					onlySourcePositioning.boolValue = EditorGUILayout.Toggle(playgroundLanguage.onlySourcePositions, onlySourcePositioning.boolValue);
					
					EditorGUILayout.Separator();
					
					GUI.enabled = !onlySourcePositioning.boolValue;

					// Lifetime positioning
					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.onlyLifetimePositioning = EditorGUILayout.ToggleLeft(playgroundLanguage.lifetimePositioning, playgroundParticlesScriptReference.onlyLifetimePositioning, GUILayout.MaxWidth(Mathf.CeilToInt(EditorGUIUtility.labelWidth)-14));
					GUI.enabled = (playgroundParticlesScriptReference.onlyLifetimePositioning&&!onlySourcePositioning.boolValue);
					EditorGUILayout.Separator();
					if (GUILayout.Button (playgroundLanguage.reset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
					    playgroundParticlesScriptReference.lifetimePositioning.Reset();
						playgroundParticlesScriptReference.lifetimePositioningTimeScale.Reset1();
						playgroundParticlesScriptReference.lifetimePositioningPositionScale.Reset1();
					}

					EditorGUILayout.EndHorizontal();

					EditorGUI.indentLevel++;

					EditorGUILayout.BeginHorizontal();
					lifetimePositioningX.animationCurveValue = EditorGUILayout.CurveField("X", lifetimePositioningX.animationCurveValue);
					playgroundParticlesScriptReference.lifetimePositioning.xRepeat = EditorGUILayout.FloatField (playgroundParticlesScriptReference.lifetimePositioning.xRepeat, GUILayout.Width(48));
					EditorGUILayout.EndHorizontal();
					EditorGUILayout.BeginHorizontal();
					lifetimePositioningY.animationCurveValue = EditorGUILayout.CurveField("Y", lifetimePositioningY.animationCurveValue);
					playgroundParticlesScriptReference.lifetimePositioning.yRepeat = EditorGUILayout.FloatField (playgroundParticlesScriptReference.lifetimePositioning.yRepeat, GUILayout.Width(48));
					EditorGUILayout.EndHorizontal();
					EditorGUILayout.BeginHorizontal();
					lifetimePositioningZ.animationCurveValue = EditorGUILayout.CurveField("Z", lifetimePositioningZ.animationCurveValue);
					playgroundParticlesScriptReference.lifetimePositioning.zRepeat = EditorGUILayout.FloatField (playgroundParticlesScriptReference.lifetimePositioning.zRepeat, GUILayout.Width(48));
					EditorGUILayout.EndHorizontal();

					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.applyLifetimePositioningPositionScale = EditorGUILayout.ToggleLeft (playgroundLanguage.positionScale, playgroundParticlesScriptReference.applyLifetimePositioningPositionScale, GUILayout.Width (Mathf.CeilToInt(Screen.width/4f)));
					GUI.enabled = GUI.enabled&&playgroundParticlesScriptReference.applyLifetimePositioningPositionScale;
					GUILayout.FlexibleSpace();
					lifetimePositioningPositionScale.animationCurveValue = EditorGUILayout.CurveField(lifetimePositioningPositionScale.animationCurveValue, GUILayout.Width (Mathf.CeilToInt(Screen.width/1.805f)));
					GUI.enabled = (playgroundParticlesScriptReference.onlyLifetimePositioning&&!onlySourcePositioning.boolValue);
					EditorGUILayout.EndHorizontal();

					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.applyLifetimePositioningTimeScale = EditorGUILayout.ToggleLeft (playgroundLanguage.timeScale, playgroundParticlesScriptReference.applyLifetimePositioningTimeScale, GUILayout.Width (Mathf.CeilToInt(Screen.width/4f)));
					GUI.enabled = GUI.enabled&&playgroundParticlesScriptReference.applyLifetimePositioningTimeScale;
					GUILayout.FlexibleSpace();
					lifetimePositioningTimeScale.animationCurveValue = EditorGUILayout.CurveField(lifetimePositioningTimeScale.animationCurveValue, GUILayout.Width (Mathf.CeilToInt(Screen.width/1.805f)));
					GUI.enabled = (playgroundParticlesScriptReference.onlyLifetimePositioning&&!onlySourcePositioning.boolValue);
					EditorGUILayout.EndHorizontal();

					playgroundParticlesScriptReference.lifetimePositioningScale = EditorGUILayout.FloatField (playgroundLanguage.scale, playgroundParticlesScriptReference.lifetimePositioningScale);
					playgroundParticlesScriptReference.lifetimePositioningUsesSourceDirection = EditorGUILayout.Toggle (playgroundLanguage.useSourceDirection, playgroundParticlesScriptReference.lifetimePositioningUsesSourceDirection);


					EditorGUI.indentLevel--;
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;

					EditorGUILayout.Separator();

					// Transition back to source
					playgroundParticlesScriptReference.transitionBackToSource = EditorGUILayout.Toggle(playgroundLanguage.transitionBackToSource, playgroundParticlesScriptReference.transitionBackToSource);
					EditorGUI.indentLevel++;
					GUI.enabled = GUI.enabled&&playgroundParticlesScriptReference.transitionBackToSource;
					playgroundParticlesScriptReference.transitionBackToSourceAmount = EditorGUILayout.CurveField(playgroundLanguage.transitionAmount, playgroundParticlesScriptReference.transitionBackToSourceAmount);
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;
					EditorGUI.indentLevel--;

					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));
					playgroundParticlesScriptReference.axisConstraints.x = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.x, GUILayout.Width(16));
					GUILayout.Label("Y", GUILayout.Width(10));
					playgroundParticlesScriptReference.axisConstraints.y = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.y, GUILayout.Width(16));
					GUILayout.Label("Z", GUILayout.Width(10));
					playgroundParticlesScriptReference.axisConstraints.z = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.z, GUILayout.Width(16));
					GUILayout.EndHorizontal();
					playgroundParticlesScriptReference.maxVelocity = EditorGUILayout.Slider(playgroundLanguage.maxVelocity, playgroundParticlesScriptReference.maxVelocity, 0, playgroundSettings.maximumAllowedVelocity);
				}
				EditorGUILayout.EndVertical();

				GUI.enabled = true;
				
				// Initial Velocity
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.forceInitialVelocityFoldout = GUILayout.Toggle(playgroundSettings.forceInitialVelocityFoldout, playgroundLanguage.initialVelocity, EditorStyles.foldout);
				GUILayout.Label (((playgroundParticlesScriptReference.calculateDeltaMovement||applyInitialVelocity.boolValue||applyInitialLocalVelocity.boolValue)?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.forceInitialVelocityFoldout) {

					// Delta Movement
					if (playgroundParticlesScriptReference.source==SOURCEC.State && playgroundParticlesScriptReference.states!=null && playgroundParticlesScriptReference.states.Count>0 && playgroundParticlesScriptReference.states[playgroundParticlesScriptReference.activeState].stateTransform==null) {
						EditorGUILayout.HelpBox(playgroundLanguage.assignTransformDeltaMovement, MessageType.Info);
						GUI.enabled = false;
					} else GUI.enabled = (source.intValue!=4 && !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
						playgroundParticlesScriptReference.calculateDeltaMovement = EditorGUILayout.ToggleLeft(playgroundLanguage.deltaMovement, playgroundParticlesScriptReference.calculateDeltaMovement);
					GUI.enabled = (GUI.enabled && playgroundParticlesScriptReference.calculateDeltaMovement && !onlySourcePositioning.boolValue);
					EditorGUI.indentLevel++;
					deltaMovementStrength.floatValue = EditorGUILayout.Slider(playgroundLanguage.deltaMovementStrength, deltaMovementStrength.floatValue, 0, playgroundSettings.maximumAllowedDeltaMovementStrength);
					EditorGUI.indentLevel--;
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;

					// Initial Velocity
					EditorGUILayout.Separator();
					EditorGUILayout.BeginHorizontal();
					applyInitialVelocity.boolValue = EditorGUILayout.ToggleLeft(playgroundLanguage.initialGlobalVelocity, applyInitialVelocity.boolValue);
					GUI.enabled = (applyInitialVelocity.boolValue&&!onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
					if (GUILayout.Button (playgroundLanguage.reset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
						playgroundParticlesScriptReference.initialVelocityMin = Vector3.zero;
						playgroundParticlesScriptReference.initialVelocityMax = Vector3.zero;
					}
					EditorGUILayout.EndHorizontal();
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.initialVelocityMethod = (MINMAXVECTOR3METHOD)EditorGUILayout.EnumPopup (playgroundLanguage.method, playgroundParticlesScriptReference.initialVelocityMethod);
					EditorGUI.indentLevel--;
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label(playgroundParticlesScriptReference.initialVelocityMethod==MINMAXVECTOR3METHOD.Rectangular||playgroundParticlesScriptReference.initialVelocityMethod==MINMAXVECTOR3METHOD.RectangularLinear?"X":playgroundLanguage.range, GUILayout.Width(50));
					EditorGUILayout.Separator();
					float initialVelocityMinX = playgroundParticlesScriptReference.initialVelocityMin.x;
					float initialVelocityMaxX = playgroundParticlesScriptReference.initialVelocityMax.x;
					EditorGUILayout.MinMaxSlider(ref initialVelocityMinX, ref initialVelocityMaxX, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
					playgroundParticlesScriptReference.initialVelocityMin.x = Mathf.Clamp (initialVelocityMinX, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
					playgroundParticlesScriptReference.initialVelocityMax.x = Mathf.Clamp (initialVelocityMaxX, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
					playgroundParticlesScriptReference.initialVelocityMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialVelocityMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					if (playgroundParticlesScriptReference.initialVelocityMethod==MINMAXVECTOR3METHOD.Rectangular || playgroundParticlesScriptReference.initialVelocityMethod==MINMAXVECTOR3METHOD.RectangularLinear) {
						// Y
						GUILayout.BeginHorizontal();
						GUILayout.Space(16);
						GUILayout.Label("Y");
						EditorGUILayout.Separator();
						float initialVelocityMinY = playgroundParticlesScriptReference.initialVelocityMin.y;
						float initialVelocityMaxY = playgroundParticlesScriptReference.initialVelocityMax.y;
						EditorGUILayout.MinMaxSlider(ref initialVelocityMinY, ref initialVelocityMaxY, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
						playgroundParticlesScriptReference.initialVelocityMin.y = Mathf.Clamp (initialVelocityMinY, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
						playgroundParticlesScriptReference.initialVelocityMax.y = Mathf.Clamp (initialVelocityMaxY, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
						playgroundParticlesScriptReference.initialVelocityMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.y, GUILayout.Width(50));
						playgroundParticlesScriptReference.initialVelocityMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.y, GUILayout.Width(50));
						GUILayout.EndHorizontal();
						// Z
						GUILayout.BeginHorizontal();
						GUILayout.Space(16);
						GUILayout.Label("Z");
						EditorGUILayout.Separator();
						float initialVelocityMinZ = playgroundParticlesScriptReference.initialVelocityMin.z;
						float initialVelocityMaxZ = playgroundParticlesScriptReference.initialVelocityMax.z;
						EditorGUILayout.MinMaxSlider(ref initialVelocityMinZ, ref initialVelocityMaxZ, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
						playgroundParticlesScriptReference.initialVelocityMin.z = Mathf.Clamp (initialVelocityMinZ, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
						playgroundParticlesScriptReference.initialVelocityMax.z = Mathf.Clamp (initialVelocityMaxZ, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
						playgroundParticlesScriptReference.initialVelocityMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.z, GUILayout.Width(50));
						playgroundParticlesScriptReference.initialVelocityMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.z, GUILayout.Width(50));
						GUILayout.EndHorizontal();
					}
					/*
				if (playgroundParticlesScriptReference.initialVelocityMethod==MINMAXVECTOR3METHOD.SphericalSector || playgroundParticlesScriptReference.initialVelocityMethod==MINMAXVECTOR3METHOD.SphericalSectorLinear) {
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.initialVelocityMin.y = EditorGUILayout.Slider(playgroundLanguage.sectorA, playgroundParticlesScriptReference.initialVelocityMin.y, -1f, 1f);
					playgroundParticlesScriptReference.initialVelocityMax.y = EditorGUILayout.Slider(playgroundLanguage.sectorB, playgroundParticlesScriptReference.initialVelocityMax.y, 0, 1f);
					EditorGUI.indentLevel--;
				}
				*/
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;
					
					// Initial Local Velocity
					EditorGUILayout.Separator();
					GUI.enabled=(source.intValue!=4 && !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
					
					if (source.intValue==4) {
						GUI.enabled = true;
						EditorGUILayout.HelpBox(playgroundLanguage.initialLocalVelocityControlledByScript, MessageType.Info);
						GUI.enabled = false;
					}
					EditorGUILayout.BeginHorizontal();
					applyInitialLocalVelocity.boolValue = EditorGUILayout.ToggleLeft(playgroundLanguage.initialLocalVelocity, applyInitialLocalVelocity.boolValue);
					if (playgroundParticlesScriptReference.source==SOURCEC.State && playgroundParticlesScriptReference.states!=null && playgroundParticlesScriptReference.states.Count>0 && playgroundParticlesScriptReference.states[playgroundParticlesScriptReference.activeState].stateTransform==null) {
						EditorGUILayout.HelpBox(playgroundLanguage.assignTransformLocalVelocity, MessageType.Info);
						GUI.enabled = false;
					} else GUI.enabled = (applyInitialLocalVelocity.boolValue&&!onlySourcePositioning.boolValue&&source.intValue!=4&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
					
					if (GUILayout.Button (playgroundLanguage.reset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
						playgroundParticlesScriptReference.initialLocalVelocityMin = Vector3.zero;
						playgroundParticlesScriptReference.initialLocalVelocityMax = Vector3.zero;
					}
					EditorGUILayout.EndHorizontal();
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.initialLocalVelocityMethod = (MINMAXVECTOR3METHOD)EditorGUILayout.EnumPopup (playgroundLanguage.method, playgroundParticlesScriptReference.initialLocalVelocityMethod);
					EditorGUI.indentLevel--;
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label(playgroundParticlesScriptReference.initialLocalVelocityMethod==MINMAXVECTOR3METHOD.Rectangular||playgroundParticlesScriptReference.initialLocalVelocityMethod==MINMAXVECTOR3METHOD.RectangularLinear?"X":playgroundLanguage.range, GUILayout.Width(50));
					EditorGUILayout.Separator();
					float initialLocalVelocityMinX = playgroundParticlesScriptReference.initialLocalVelocityMin.x;
					float initialLocalVelocityMaxX = playgroundParticlesScriptReference.initialLocalVelocityMax.x;
					EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinX, ref initialLocalVelocityMaxX, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
					playgroundParticlesScriptReference.initialLocalVelocityMin.x = Mathf.Clamp (initialLocalVelocityMinX, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
					playgroundParticlesScriptReference.initialLocalVelocityMax.x = Mathf.Clamp (initialLocalVelocityMaxX, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
					playgroundParticlesScriptReference.initialLocalVelocityMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialLocalVelocityMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					if (playgroundParticlesScriptReference.initialLocalVelocityMethod==MINMAXVECTOR3METHOD.Rectangular || playgroundParticlesScriptReference.initialLocalVelocityMethod==MINMAXVECTOR3METHOD.RectangularLinear) {
						// Y
						GUILayout.BeginHorizontal();
						GUILayout.Space(16);
						GUILayout.Label("Y");
						EditorGUILayout.Separator();
						float initialLocalVelocityMinY = playgroundParticlesScriptReference.initialLocalVelocityMin.y;
						float initialLocalVelocityMaxY = playgroundParticlesScriptReference.initialLocalVelocityMax.y;
						EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinY, ref initialLocalVelocityMaxY, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
						playgroundParticlesScriptReference.initialLocalVelocityMin.y = Mathf.Clamp (initialLocalVelocityMinY, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
						playgroundParticlesScriptReference.initialLocalVelocityMax.y = Mathf.Clamp (initialLocalVelocityMaxY, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
						playgroundParticlesScriptReference.initialLocalVelocityMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.y, GUILayout.Width(50));
						playgroundParticlesScriptReference.initialLocalVelocityMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.y, GUILayout.Width(50));
						GUILayout.EndHorizontal();
						// Z
						GUILayout.BeginHorizontal();
						GUILayout.Space(16);
						GUILayout.Label("Z");
						EditorGUILayout.Separator();
						float initialLocalVelocityMinZ = playgroundParticlesScriptReference.initialLocalVelocityMin.z;
						float initialLocalVelocityMaxZ = playgroundParticlesScriptReference.initialLocalVelocityMax.z;
						EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinZ, ref initialLocalVelocityMaxZ, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
						playgroundParticlesScriptReference.initialLocalVelocityMin.z = Mathf.Clamp (initialLocalVelocityMinZ, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
						playgroundParticlesScriptReference.initialLocalVelocityMax.z = Mathf.Clamp (initialLocalVelocityMaxZ, -playgroundSettings.maximumAllowedInitialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
						playgroundParticlesScriptReference.initialLocalVelocityMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.z, GUILayout.Width(50));
						playgroundParticlesScriptReference.initialLocalVelocityMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.z, GUILayout.Width(50));
						GUILayout.EndHorizontal();
					}
					/*
				if (playgroundParticlesScriptReference.initialLocalVelocityMethod==MINMAXVECTOR3METHOD.SphericalSector || playgroundParticlesScriptReference.initialLocalVelocityMethod==MINMAXVECTOR3METHOD.SphericalSectorLinear) {
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.initialLocalVelocityMin.y = EditorGUILayout.Slider(playgroundLanguage.sectorA, playgroundParticlesScriptReference.initialLocalVelocityMin.y, -1f, 1f);
					playgroundParticlesScriptReference.initialLocalVelocityMax.y = EditorGUILayout.Slider(playgroundLanguage.sectorB, playgroundParticlesScriptReference.initialLocalVelocityMax.y, 0, 1f);
					EditorGUI.indentLevel--;
				}*/
					
					EditorGUILayout.Separator();
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;
					
					// Initial velocity shape
					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.applyInitialVelocityShape = EditorGUILayout.ToggleLeft(playgroundLanguage.initialVelocityShape, playgroundParticlesScriptReference.applyInitialVelocityShape);
					GUI.enabled = (playgroundParticlesScriptReference.applyInitialVelocityShape&&!onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
					if (GUILayout.Button (playgroundLanguage.reset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
						playgroundParticlesScriptReference.initialVelocityShape.Reset1();
					EditorGUILayout.EndHorizontal();
					EditorGUI.indentLevel++;
					initialVelocityShapeX.animationCurveValue = EditorGUILayout.CurveField("X", initialVelocityShapeX.animationCurveValue);
					initialVelocityShapeY.animationCurveValue = EditorGUILayout.CurveField("Y", initialVelocityShapeY.animationCurveValue);
					initialVelocityShapeZ.animationCurveValue = EditorGUILayout.CurveField("Z", initialVelocityShapeZ.animationCurveValue);
					playgroundParticlesScriptReference.initialVelocityShapeScale = EditorGUILayout.FloatField (playgroundLanguage.scale, playgroundParticlesScriptReference.initialVelocityShapeScale);
					EditorGUI.indentLevel--;
				}
				EditorGUILayout.EndVertical();

				GUI.enabled = true;

				// Lifetime velocity
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.forceLifetimeVelocityFoldout = GUILayout.Toggle(playgroundSettings.forceLifetimeVelocityFoldout, playgroundLanguage.lifetimeVelocity, EditorStyles.foldout);
				GUILayout.Label ((applyLifetimeVelocity.boolValue?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.forceLifetimeVelocityFoldout) {
					EditorGUILayout.BeginHorizontal();
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;
					applyLifetimeVelocity.boolValue = EditorGUILayout.ToggleLeft(playgroundLanguage.lifetimeVelocity, applyLifetimeVelocity.boolValue);
					GUI.enabled = (applyLifetimeVelocity.boolValue&&!onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
					if (GUILayout.Button (playgroundLanguage.reset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
						playgroundParticlesScriptReference.lifetimeVelocity.Reset();
					EditorGUILayout.EndHorizontal();

					EditorGUI.indentLevel++;
					lifeTimeVelocityX.animationCurveValue = EditorGUILayout.CurveField("X", lifeTimeVelocityX.animationCurveValue);
					lifeTimeVelocityY.animationCurveValue = EditorGUILayout.CurveField("Y", lifeTimeVelocityY.animationCurveValue);
					lifeTimeVelocityZ.animationCurveValue = EditorGUILayout.CurveField("Z", lifeTimeVelocityZ.animationCurveValue);
					playgroundParticlesScriptReference.lifetimeVelocityScale = EditorGUILayout.FloatField (playgroundLanguage.scale, playgroundParticlesScriptReference.lifetimeVelocityScale);
					EditorGUI.indentLevel--;
				}
				EditorGUILayout.EndVertical();

				GUI.enabled = true;
				
				// Velocity Bending
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.forceVelocityBendingFoldout = GUILayout.Toggle(playgroundSettings.forceVelocityBendingFoldout, playgroundLanguage.velocityBending, EditorStyles.foldout);
				GUILayout.Label ((applyVelocityBending.boolValue?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.forceVelocityBendingFoldout) {
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;
					applyVelocityBending.boolValue = EditorGUILayout.ToggleLeft(playgroundLanguage.velocityBending, applyVelocityBending.boolValue);
					GUI.enabled = (applyVelocityBending.boolValue&&!onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
						EditorGUI.indentLevel++;
						EditorGUILayout.PropertyField (velocityBendingType, new GUIContent(playgroundLanguage.type));
						playgroundParticlesScriptReference.velocityBending = EditorGUILayout.Vector3Field(playgroundLanguage.bending, playgroundParticlesScriptReference.velocityBending);
						EditorGUI.indentLevel--;
					EditorGUILayout.Separator();
				}
				EditorGUILayout.EndVertical();

				GUI.enabled = true;

				// Turbulence
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.forceTurbulenceFoldout = GUILayout.Toggle(playgroundSettings.forceTurbulenceFoldout, playgroundLanguage.turbulence, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.turbulenceType==TURBULENCETYPE.None?playgroundLanguage.off:playgroundLanguage.on), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.forceTurbulenceFoldout) {
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;
					playgroundParticlesScriptReference.turbulenceType = (TURBULENCETYPE)EditorGUILayout.EnumPopup(playgroundLanguage.turbulence, playgroundParticlesScriptReference.turbulenceType);
					GUI.enabled = (playgroundParticlesScriptReference.turbulenceType!=TURBULENCETYPE.None && !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.turbulenceStrength = EditorGUILayout.Slider(playgroundLanguage.strength, playgroundParticlesScriptReference.turbulenceStrength, 0f, playgroundSettings.maximumAllowedTurbulenceStrength);
					playgroundParticlesScriptReference.turbulenceScale = EditorGUILayout.Slider(playgroundLanguage.scale, playgroundParticlesScriptReference.turbulenceScale, 0f, playgroundSettings.maximumAllowedTurbulenceScale);
					playgroundParticlesScriptReference.turbulenceTimeScale = EditorGUILayout.Slider(playgroundLanguage.timeScale, playgroundParticlesScriptReference.turbulenceTimeScale, 0f, playgroundSettings.maximumAllowedTurbulenceTimeScale);
					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.turbulenceApplyLifetimeStrength = EditorGUILayout.ToggleLeft (playgroundLanguage.lifetimeStrength, playgroundParticlesScriptReference.turbulenceApplyLifetimeStrength, GUILayout.MaxWidth(Mathf.CeilToInt(EditorGUIUtility.labelWidth)-28));
					GUI.enabled = (playgroundParticlesScriptReference.turbulenceApplyLifetimeStrength && playgroundParticlesScriptReference.turbulenceType!=TURBULENCETYPE.None && !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning);
					turbulenceLifetimeStrength.animationCurveValue = EditorGUILayout.CurveField(turbulenceLifetimeStrength.animationCurveValue);
					EditorGUILayout.EndHorizontal();
					EditorGUI.indentLevel--;

				}
				EditorGUILayout.EndVertical();

				GUI.enabled = true;

				// Constant Force
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.forceConstantForceFoldout = GUILayout.Toggle(playgroundSettings.forceConstantForceFoldout, playgroundLanguage.constantForce, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.gravity==Vector3.zero&&playgroundParticlesScriptReference.damping==0?playgroundLanguage.off:playgroundLanguage.on), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.forceConstantForceFoldout) {
					GUI.enabled = !onlySourcePositioning.boolValue&&!playgroundParticlesScriptReference.onlyLifetimePositioning;
					playgroundParticlesScriptReference.gravity = EditorGUILayout.Vector3Field(playgroundLanguage.gravity, playgroundParticlesScriptReference.gravity);
					playgroundParticlesScriptReference.damping = EditorGUILayout.Slider(playgroundLanguage.damping, playgroundParticlesScriptReference.damping, 0f, playgroundSettings.maximumAllowedDamping);
					playgroundParticlesScriptReference.velocityScale = EditorGUILayout.Slider(playgroundLanguage.velocityScale, playgroundParticlesScriptReference.velocityScale, 0f, playgroundSettings.maximumAllowedVelocity);
				}
				EditorGUILayout.EndVertical();
				GUI.enabled = true;
			}

			// Collision Settings
			if (GUILayout.Button(collision.boolValue?collisionType.intValue==0?playgroundLanguage.collision+" ("+playgroundLanguage.threeDimensional+")":playgroundLanguage.collision+" ("+playgroundLanguage.twoDimensional+")":playgroundLanguage.collision+" ("+playgroundLanguage.off+")", EditorStyles.toolbarDropDown)) playgroundSettings.collisionFoldout=!playgroundSettings.collisionFoldout;
			if (playgroundSettings.collisionFoldout) {

				if (playgroundParticlesScriptReference.onlySourcePositioning||playgroundParticlesScriptReference.onlyLifetimePositioning) {
					EditorGUILayout.HelpBox(playgroundLanguage.collisionDisabledDescription, MessageType.Info);
					EditorGUILayout.Separator();
				}

				EditorGUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.collisionSettingsFoldout = GUILayout.Toggle(playgroundSettings.collisionSettingsFoldout, playgroundLanguage.collisionSettings, EditorStyles.foldout);
				GUILayout.Label ((collision.boolValue?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.collisionSettingsFoldout) {
					GUI.enabled = !playgroundParticlesScriptReference.onlySourcePositioning&&!playgroundParticlesScriptReference.onlyLifetimePositioning;
					collision.boolValue = EditorGUILayout.ToggleLeft(playgroundLanguage.collision, collision.boolValue);
					EditorGUI.indentLevel++;
					GUI.enabled = GUI.enabled&&collision.boolValue;
					EditorGUILayout.PropertyField(collisionType, new GUIContent(playgroundLanguage.collisionType));
					if (collisionType.enumValueIndex==1) {
						GUILayout.BeginHorizontal();
						GUILayout.Space (16);
						GUILayout.Label(playgroundLanguage.depth);
						EditorGUILayout.Separator();
						float minDepth = playgroundParticlesScriptReference.minCollisionDepth;
						float maxDepth = playgroundParticlesScriptReference.maxCollisionDepth;
						EditorGUILayout.MinMaxSlider(ref minDepth, ref maxDepth, -playgroundSettings.maximumAllowedDepth, playgroundSettings.maximumAllowedDepth, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-110));
						playgroundParticlesScriptReference.minCollisionDepth = Mathf.Clamp (minDepth, -playgroundSettings.maximumAllowedDepth, playgroundSettings.maximumAllowedDepth);
						playgroundParticlesScriptReference.maxCollisionDepth = Mathf.Clamp (maxDepth, -playgroundSettings.maximumAllowedDepth, playgroundSettings.maximumAllowedDepth);
						playgroundParticlesScriptReference.minCollisionDepth = EditorGUILayout.FloatField(playgroundParticlesScriptReference.minCollisionDepth, GUILayout.Width(50));
						playgroundParticlesScriptReference.maxCollisionDepth = EditorGUILayout.FloatField(playgroundParticlesScriptReference.maxCollisionDepth, GUILayout.Width(50));
						GUILayout.EndHorizontal();
					}
					EditorGUILayout.PropertyField(collisionMask, new GUIContent(playgroundLanguage.collisionMask));
					affectRigidbodies.boolValue = EditorGUILayout.Toggle(playgroundLanguage.collideWithRigidbodies, affectRigidbodies.boolValue);
					playgroundParticlesScriptReference.inverseRigidbodyCollision = EditorGUILayout.Toggle (playgroundLanguage.inverseRigidbodyCollision, playgroundParticlesScriptReference.inverseRigidbodyCollision);
					mass.floatValue = EditorGUILayout.Slider(playgroundLanguage.mass, mass.floatValue, 0, playgroundSettings.maximumAllowedMass);
					collisionRadius.floatValue = EditorGUILayout.Slider(playgroundLanguage.collisionRadius, collisionRadius.floatValue, 0, playgroundSettings.maximumAllowedCollisionRadius);
					playgroundParticlesScriptReference.lifetimeLoss = EditorGUILayout.Slider(playgroundLanguage.lifetimeLoss, playgroundParticlesScriptReference.lifetimeLoss, 0f, 1f);
					
					EditorGUILayout.Separator();
					bounciness.floatValue = EditorGUILayout.Slider(playgroundLanguage.bounciness, bounciness.floatValue, 0, playgroundSettings.maximumAllowedBounciness);
					EditorGUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.randomBounce);
					EditorGUILayout.Separator ();
					if (GUILayout.Button (playgroundLanguage.reset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
						playgroundParticlesScriptReference.bounceRandomMin = Vector3.zero;
						playgroundParticlesScriptReference.bounceRandomMax = Vector3.zero;
					}
					EditorGUILayout.EndHorizontal();
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(32);
					GUILayout.Label("X", GUILayout.Width(50));
					EditorGUILayout.Separator();
					float bounceRandomMinX = playgroundParticlesScriptReference.bounceRandomMin.x;
					float bounceRandomMaxX = playgroundParticlesScriptReference.bounceRandomMax.x;
					EditorGUILayout.MinMaxSlider(ref bounceRandomMinX, ref bounceRandomMaxX, -1f, 1f, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-100));
					playgroundParticlesScriptReference.bounceRandomMin.x = Mathf.Clamp (bounceRandomMinX, -1f, 1f);
					playgroundParticlesScriptReference.bounceRandomMax.x = Mathf.Clamp (bounceRandomMaxX, -1f, 1f);
					playgroundParticlesScriptReference.bounceRandomMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.bounceRandomMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Y
					GUILayout.BeginHorizontal();
					GUILayout.Space(32);
					GUILayout.Label("Y");
					EditorGUILayout.Separator();
					float bounceRandomMinY = playgroundParticlesScriptReference.bounceRandomMin.y;
					float bounceRandomMaxY = playgroundParticlesScriptReference.bounceRandomMax.y;
					EditorGUILayout.MinMaxSlider(ref bounceRandomMinY, ref bounceRandomMaxY, -1f, 1f, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-100));
					playgroundParticlesScriptReference.bounceRandomMin.y = Mathf.Clamp (bounceRandomMinY, -1f, 1f);
					playgroundParticlesScriptReference.bounceRandomMax.y = Mathf.Clamp (bounceRandomMaxY, -1f, 1f);
					playgroundParticlesScriptReference.bounceRandomMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.y, GUILayout.Width(50));
					playgroundParticlesScriptReference.bounceRandomMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.y, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Z
					GUILayout.BeginHorizontal();
					GUILayout.Space(32);
					GUILayout.Label("Z");
					EditorGUILayout.Separator();
					float bounceRandomMinZ = playgroundParticlesScriptReference.bounceRandomMin.z;
					float bounceRandomMaxZ = playgroundParticlesScriptReference.bounceRandomMax.z;
					EditorGUILayout.MinMaxSlider(ref bounceRandomMinZ, ref bounceRandomMaxZ, -1f, 1f, GUILayout.Width(Mathf.CeilToInt(Screen.width/1.805f)-100));
					playgroundParticlesScriptReference.bounceRandomMin.z = Mathf.Clamp (bounceRandomMinZ, -1f, 1f);
					playgroundParticlesScriptReference.bounceRandomMax.z = Mathf.Clamp (bounceRandomMaxZ, -1f, 1f);
					playgroundParticlesScriptReference.bounceRandomMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.z, GUILayout.Width(50));
					playgroundParticlesScriptReference.bounceRandomMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.z, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					
					EditorGUI.indentLevel--;
					EditorGUILayout.Separator();
				}
				EditorGUILayout.EndVertical();
				
				// Collision planes List
				GUI.enabled = true;
				EditorGUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.collisionPlanesFoldout = GUILayout.Toggle(playgroundSettings.collisionPlanesFoldout, playgroundLanguage.collisionPlanes, EditorStyles.foldout);
				GUILayout.Label (playgroundParticlesScriptReference.colliders.Count.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.collisionPlanesFoldout) {
					if (playgroundParticlesScriptReference.colliders.Count>0) {
						for (int c = 0; c<playgroundParticlesScriptReference.colliders.Count; c++) {
							EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
							EditorGUILayout.BeginHorizontal();
							
							playgroundParticlesScriptReference.colliders[c].enabled = EditorGUILayout.Toggle("", playgroundParticlesScriptReference.colliders[c].enabled, GUILayout.Width(16));
							GUI.enabled = (GUI.enabled&&playgroundParticlesScriptReference.colliders[c].enabled);
							playgroundParticlesScriptReference.colliders[c].transform = EditorGUILayout.ObjectField("", playgroundParticlesScriptReference.colliders[c].transform, typeof(Transform), true) as Transform;
							playgroundParticlesScriptReference.colliders[c].offset = EditorGUILayout.Vector3Field("", playgroundParticlesScriptReference.colliders[c].offset, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-142));
							GUI.enabled = true;
							
							EditorGUILayout.Separator();
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								playgroundParticlesScriptReference.colliders.RemoveAt(c);
							}
							
							EditorGUILayout.EndHorizontal();
							EditorGUILayout.EndVertical();
						}
					} else {
						EditorGUILayout.HelpBox(playgroundLanguage.noCollisionPlanes, MessageType.Info);
					}
					
					if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth (false))){
						playgroundParticlesScriptReference.colliders.Add(new PlaygroundColliderC());
					}
					
					EditorGUILayout.Separator();
					playgroundScriptReference.collisionPlaneScale = EditorGUILayout.Slider(playgroundLanguage.gizmoScale, playgroundScriptReference.collisionPlaneScale, 0, 1);
					EditorGUILayout.Separator();
				}
				EditorGUILayout.EndVertical();

				// Collision Exclusion list
				GUI.enabled = true;
				EditorGUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.collisionExclusionFoldout = GUILayout.Toggle(playgroundSettings.collisionExclusionFoldout, playgroundLanguage.collisionExclusion, EditorStyles.foldout);
				GUILayout.Label (playgroundParticlesScriptReference.collisionExclusion.Count.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.collisionExclusionFoldout) {
					if (playgroundParticlesScriptReference.collisionExclusion.Count>0) {
						for (int c = 0; c<playgroundParticlesScriptReference.collisionExclusion.Count; c++) {
							EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
							EditorGUILayout.BeginHorizontal();
							playgroundParticlesScriptReference.collisionExclusion[c] = EditorGUILayout.ObjectField("", playgroundParticlesScriptReference.collisionExclusion[c], typeof(Transform), true) as Transform;
							EditorGUILayout.Separator();
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								playgroundParticlesScriptReference.collisionExclusion.RemoveAt(c);
							}
							
							EditorGUILayout.EndHorizontal();
							EditorGUILayout.EndVertical();
						}
					} else {
						EditorGUILayout.HelpBox(playgroundLanguage.collisionExclusionMessage, MessageType.Info);
					}
					
					if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth (false))){
						playgroundParticlesScriptReference.collisionExclusion.Add(null);
					}
				}
				EditorGUILayout.EndVertical();
				
				GUI.enabled = true;				
			}
			
			// Render Settings
			if (GUILayout.Button(playgroundLanguage.rendering+" ("+playgroundParticlesScriptReference.colorSource+")", EditorStyles.toolbarDropDown)) playgroundSettings.renderingFoldout=!playgroundSettings.renderingFoldout;
			if (playgroundSettings.renderingFoldout) {

				// Material
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.renderingMaterialFoldout = GUILayout.Toggle(playgroundSettings.renderingMaterialFoldout, playgroundLanguage.material, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.particleSystemRenderer.sharedMaterial!=null?playgroundParticlesScriptReference.particleSystemRenderer.sharedMaterial.name:playgroundLanguage.none), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.renderingMaterialFoldout) {
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.material);
					Material currentMat = particleMaterial as Material;
					particleMaterial = EditorGUILayout.ObjectField(particleMaterial, typeof(Material), false);
					if (currentMat!=particleMaterial) 
						PlaygroundParticlesC.SetMaterial(playgroundParticlesScriptReference, particleMaterial as Material);
					GUILayout.EndHorizontal();
				}
				EditorGUILayout.EndVertical();

				// Color
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.renderingColorFoldout = GUILayout.Toggle(playgroundSettings.renderingColorFoldout, playgroundLanguage.color, EditorStyles.foldout);
				GUILayout.Label (playgroundParticlesScriptReference.colorSource.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.renderingColorFoldout) {
					playgroundParticlesScriptReference.colorSource = (COLORSOURCEC)EditorGUILayout.EnumPopup(playgroundLanguage.colorSource, playgroundParticlesScriptReference.colorSource);
					playgroundParticlesScriptReference.colorMethod = (COLORMETHOD)EditorGUILayout.EnumPopup(playgroundLanguage.colorMethod, playgroundParticlesScriptReference.colorMethod);
					switch (playgroundParticlesScriptReference.colorSource) {
					case COLORSOURCEC.Source: 
						EditorGUILayout.PropertyField(lifetimeColor, new GUIContent(playgroundParticlesScriptReference.colorMethod==COLORMETHOD.Lifetime?playgroundLanguage.lifetimeColor:playgroundLanguage.arrayColor));
						playgroundParticlesScriptReference.sourceUsesLifetimeAlpha = EditorGUILayout.Toggle(playgroundLanguage.sourceUsesLifetimeAlpha, playgroundParticlesScriptReference.sourceUsesLifetimeAlpha);
						break;
					case COLORSOURCEC.LifetimeColor:
						EditorGUILayout.PropertyField(lifetimeColor, new GUIContent(playgroundParticlesScriptReference.colorMethod==COLORMETHOD.Lifetime?playgroundLanguage.lifetimeColor:playgroundLanguage.arrayColor));
						break;
					case COLORSOURCEC.LifetimeColors:
						if (lifetimeColors.arraySize>0) {
							
							SerializedProperty thisLifetimeColor;
							for (int c = 0; c<lifetimeColors.arraySize; c++) {
								thisLifetimeColor = lifetimeColors.GetArrayElementAtIndex(c).FindPropertyRelative("gradient");
								GUILayout.BeginHorizontal(boxStyle);
								EditorGUILayout.PropertyField (thisLifetimeColor);
								if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})) {
									lifetimeColors.DeleteArrayElementAtIndex(c);
									playgroundParticles.ApplyModifiedProperties();
								}
								GUILayout.EndHorizontal();
							}
							
						} else {
							EditorGUILayout.HelpBox(playgroundLanguage.noLifetimeColors, MessageType.Info);
						}
						if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
							playgroundParticlesScriptReference.lifetimeColors.Add (new PlaygroundGradientC());
							playgroundParticlesScriptReference.lifetimeColors[playgroundParticlesScriptReference.lifetimeColors.Count-1].gradient = new Gradient();
							playgroundParticles.ApplyModifiedProperties();
						}
						break;
					}
					if (playgroundParticlesScriptReference.colorMethod==COLORMETHOD.ParticleArray) {
						EditorGUILayout.PropertyField(arrayColor, new GUIContent(playgroundLanguage.arrayAlpha));
						playgroundParticlesScriptReference.arrayColorUsesAlpha = EditorGUILayout.Toggle(playgroundLanguage.applyArrayAlpha, playgroundParticlesScriptReference.arrayColorUsesAlpha);
					}
				}
				EditorGUILayout.EndVertical ();

				// Render mode
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.renderingRenderModeFoldout = GUILayout.Toggle(playgroundSettings.renderingRenderModeFoldout, playgroundLanguage.renderMode, EditorStyles.foldout);
				GUILayout.Label (playgroundParticlesScriptReference.particleSystemRenderer2.renderMode.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.renderingRenderModeFoldout) {
					shurikenRenderer.renderMode = (ParticleSystemRenderMode)EditorGUILayout.EnumPopup(playgroundLanguage.renderMode, shurikenRenderer.renderMode);
					switch (shurikenRenderer.renderMode) {
					case ParticleSystemRenderMode.Stretch:
						EditorGUI.indentLevel++;
						shurikenRenderer.cameraVelocityScale = EditorGUILayout.Slider(playgroundLanguage.cameraScale, shurikenRenderer.cameraVelocityScale, -playgroundSettings.maximumRenderSliders, playgroundSettings.maximumRenderSliders);
						shurikenRenderer.velocityScale = EditorGUILayout.Slider(playgroundLanguage.speedScale, shurikenRenderer.velocityScale, -playgroundSettings.maximumRenderSliders, playgroundSettings.maximumRenderSliders);
						shurikenRenderer.lengthScale = EditorGUILayout.Slider(playgroundLanguage.lengthScale, shurikenRenderer.lengthScale, -playgroundSettings.maximumRenderSliders, playgroundSettings.maximumRenderSliders);
						playgroundParticlesScriptReference.stretchSpeed = EditorGUILayout.Slider(playgroundLanguage.stretchSpeed, playgroundParticlesScriptReference.stretchSpeed, 0, playgroundSettings.maximumAllowedStretchSpeed);

						EditorGUILayout.BeginHorizontal();
						playgroundParticlesScriptReference.applyStretchStartDirection = EditorGUILayout.ToggleLeft (playgroundLanguage.startStretch, playgroundParticlesScriptReference.applyStretchStartDirection, GUILayout.Width (140));
						GUILayout.FlexibleSpace();
						playgroundParticlesScriptReference.stretchStartDirection = EditorGUILayout.Vector3Field ("", playgroundParticlesScriptReference.stretchStartDirection);
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.BeginHorizontal();
						playgroundParticlesScriptReference.applyLifetimeStretching = EditorGUILayout.ToggleLeft (playgroundLanguage.lifetimeStretch, playgroundParticlesScriptReference.applyLifetimeStretching, GUILayout.Width (140));
						GUILayout.FlexibleSpace();
						GUI.enabled = (playgroundParticlesScriptReference.applyLifetimeStretching);
						lifetimeStretching.animationCurveValue = EditorGUILayout.CurveField(lifetimeStretching.animationCurveValue);
						EditorGUILayout.EndHorizontal();
						EditorGUI.indentLevel--;
						break;
					case ParticleSystemRenderMode.Mesh:
						shurikenRenderer.mesh = EditorGUILayout.ObjectField(shurikenRenderer.mesh, typeof(Mesh), false) as Mesh;
						break;
					}
					EditorGUILayout.Separator();
					GUI.enabled = true;
					shurikenRenderer.maxParticleSize = EditorGUILayout.FloatField(playgroundLanguage.maxParticleSize, shurikenRenderer.maxParticleSize);
					shurikenRenderer.enabled = EditorGUILayout.Toggle(playgroundLanguage.renderer, shurikenRenderer.enabled);
				}
				EditorGUILayout.EndVertical();
				GUI.enabled = true;

				// Shadows
				EditorGUILayout.BeginVertical (boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.renderingShadowsFoldout = GUILayout.Toggle(playgroundSettings.renderingShadowsFoldout, playgroundLanguage.shadows, EditorStyles.foldout);
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
				GUILayout.Label (playgroundParticlesScriptReference.particleSystemRenderer2.castShadows||playgroundParticlesScriptReference.particleSystemRenderer2.receiveShadows?playgroundLanguage.on:playgroundLanguage.off, EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
#else
				GUILayout.Label (shurikenRenderer.shadowCastingMode!=UnityEngine.Rendering.ShadowCastingMode.Off||playgroundParticlesScriptReference.particleSystemRenderer2.receiveShadows?playgroundLanguage.on:playgroundLanguage.off, EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
#endif
				GUILayout.EndHorizontal();
				if (playgroundSettings.renderingShadowsFoldout) {
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
					shurikenRenderer.castShadows = EditorGUILayout.Toggle (playgroundLanguage.castShadows, shurikenRenderer.castShadows);
#else
					shurikenRenderer.shadowCastingMode = (UnityEngine.Rendering.ShadowCastingMode)EditorGUILayout.EnumPopup (playgroundLanguage.castShadows, shurikenRenderer.shadowCastingMode);
#endif
					shurikenRenderer.receiveShadows = EditorGUILayout.Toggle (playgroundLanguage.receiveShadows, shurikenRenderer.receiveShadows);
				}
				EditorGUILayout.EndVertical();

				// Sorting
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.sortingFoldout = GUILayout.Toggle(playgroundSettings.sortingFoldout, playgroundLanguage.sorting, EditorStyles.foldout);
				GUILayout.Label (sortMode.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.sortingFoldout) {
				
					// Sort order
					sortMode = (SortMode)EditorGUILayout.EnumPopup(playgroundLanguage.sortMode, sortMode);
					sortingMode.intValue = (int)sortMode;
					EditorGUILayout.PropertyField(sortingFudge, new GUIContent(playgroundLanguage.sortingFudge));
					shurikenRendererSO.ApplyModifiedProperties();

					EditorGUILayout.Separator();

					// Sorting Layers
					int prevSelectedSortingLayer = selectedSortingLayer;
					selectedSortingLayer = EditorGUILayout.Popup(playgroundLanguage.sortingLayer, selectedSortingLayer, rendererSortingLayers);
					if (prevSelectedSortingLayer!=selectedSortingLayer) {
						shurikenRenderer.sortingLayerName = rendererSortingLayers[selectedSortingLayer];
					}
					shurikenRenderer.sortingOrder = EditorGUILayout.IntField (playgroundLanguage.orderInLayer, shurikenRenderer.sortingOrder);
				}
				GUILayout.EndVertical();

				// Texture Sheet Animation
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.textureSheetAnimationFoldout = GUILayout.Toggle(playgroundSettings.textureSheetAnimationFoldout, playgroundLanguage.textureSheetAnimation, EditorStyles.foldout);
				GUILayout.Label (uvModule_enabled.boolValue?playgroundLanguage.on:playgroundLanguage.off, EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.textureSheetAnimationFoldout) {
					shuriken.UpdateIfDirtyOrScript();
					uvModule_enabled.boolValue = EditorGUILayout.ToggleLeft(playgroundLanguage.enabled, uvModule_enabled.boolValue);
					EditorGUI.indentLevel++;
					EditorGUILayout.BeginHorizontal();
					GUI.enabled = uvModule_enabled.boolValue;
					EditorGUILayout.PrefixLabel(playgroundLanguage.tiles);
					EditorGUIUtility.labelWidth = 16f;
					EditorGUI.indentLevel--;
					EditorGUILayout.PropertyField(uvModule_tilesX, new GUIContent("X"));
					EditorGUILayout.PropertyField(uvModule_tilesY, new GUIContent("Y"));
					EditorGUI.indentLevel++;
					EditorGUIUtility.labelWidth = 0;
					EditorGUILayout.EndHorizontal();
					uv_animationType = (AnimationType)EditorGUILayout.EnumPopup(playgroundLanguage.animation, uv_animationType);
					uvModule_animationType.intValue = (int)uv_animationType;
					if (uvModule_animationType.intValue==1) {
						EditorGUILayout.PropertyField(uvModule_randomRow, new GUIContent(playgroundLanguage.randomRow));
						if (!uvModule_randomRow.boolValue)
							EditorGUILayout.PropertyField(uvModule_rowIndex, new GUIContent(playgroundLanguage.row));
					}
					uv_minMaxState = (MinMaxState)EditorGUILayout.EnumPopup(playgroundLanguage.animationMethod, uv_minMaxState);
					uvModule_frameOverTime_minMaxState.intValue = (int)uv_minMaxState;
					switch (uvModule_frameOverTime_minMaxState.intValue) {
					case 0:
						EditorGUILayout.PropertyField (uvModule_frameOverTime_scalar, new GUIContent(playgroundLanguage.frameOverTime));
					break;
					case 1:
						EditorGUILayout.PropertyField (uvModule_frameOverTime_maxCurve, new GUIContent(playgroundLanguage.frameOverTime));
					break;
					case 2:
						EditorGUILayout.PropertyField (uvModule_frameOverTime_maxCurve, new GUIContent(playgroundLanguage.frameOverTime));
						EditorGUILayout.PropertyField (uvModule_frameOverTime_minCurve, new GUIContent(" "));
					break;
					case 3:
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.PrefixLabel(playgroundLanguage.frameOverTime);
						EditorGUIUtility.labelWidth = 16f;
						EditorGUI.indentLevel--;
						EditorGUI.indentLevel--;
						float minFotVal = (float)uvModule_frameOverTime_minCurve.animationCurveValue[0].value*uvModule_frameOverTime_scalar.floatValue;
						minFotVal = EditorGUILayout.FloatField(" ", minFotVal);
						if (!Mathf.Approximately(uvModule_frameOverTime_minCurve.animationCurveValue[0].value*uvModule_frameOverTime_scalar.floatValue, minFotVal)) {
							AnimationCurve updCurve = new AnimationCurve();
							Keyframe[] updKeys = uvModule_frameOverTime_minCurve.animationCurveValue.keys;
							updKeys[0].value = minFotVal/uvModule_frameOverTime_scalar.floatValue;
							updCurve.keys = updKeys;
							uvModule_frameOverTime_minCurve.animationCurveValue = updCurve;
							EditorUtility.SetDirty(playgroundParticlesScriptReference.shurikenParticleSystem);
						}
						EditorGUILayout.PropertyField(uvModule_frameOverTime_scalar, new GUIContent(" "));
						EditorGUI.indentLevel++;
						EditorGUI.indentLevel++;
						EditorGUIUtility.labelWidth = 0;
						EditorGUILayout.EndHorizontal();
					break;
					}

					GUI.enabled = true;
					EditorGUILayout.Separator();
					playgroundParticlesScriptReference.minShurikenLifetime = EditorGUILayout.FloatField (playgroundLanguage.minimumShurikenLifetime, playgroundParticlesScriptReference.minShurikenLifetime);
					if (playgroundParticlesScriptReference.minShurikenLifetime<0) playgroundParticlesScriptReference.minShurikenLifetime = 0;
					EditorGUI.indentLevel--;
					shuriken.ApplyModifiedProperties();
				}
				EditorGUILayout.EndVertical();
			}
			
			// Manipulators Settings
			if (GUILayout.Button(playgroundLanguage.manipulators+" ("+playgroundParticlesScriptReference.manipulators.Count+")", EditorStyles.toolbarDropDown)) playgroundSettings.manipulatorsFoldout=!playgroundSettings.manipulatorsFoldout;
			if (playgroundSettings.manipulatorsFoldout) {
				
				EditorGUILayout.Separator();

				if (playgroundParticlesScriptReference.manipulators.Count>0) {
					if (PlaygroundInspectorC.playgroundSettings==null)
						PlaygroundInspectorC.playgroundSettings = PlaygroundSettingsC.GetReference();
					if (PlaygroundInspectorC.playgroundLanguage==null)
						PlaygroundInspectorC.playgroundLanguage = PlaygroundSettingsC.GetLanguage();
					string mName;
					for (int i = 0; i<playgroundParticlesScriptReference.manipulators.Count; i++) {
						if (!playgroundParticlesScriptReference.manipulators[i].enabled)
							GUI.contentColor = Color.gray;
						if (playgroundParticlesScriptReference.manipulators[i].transform.available && playgroundParticlesScriptReference.manipulators[i].transform.transform!=null) {
							mName = playgroundParticlesScriptReference.manipulators[i].transform.transform.name;
							if (mName.Length>24)
								mName = mName.Substring(0, 24)+"...";
						} else {
							GUI.color = Color.red;
							mName = "("+playgroundLanguage.missingTransform+")";
						}
						EditorGUILayout.BeginVertical("box");
						
						EditorGUILayout.BeginHorizontal();
						
						GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
						playgroundParticlesScriptReference.manipulators[i].unfolded = GUILayout.Toggle(playgroundParticlesScriptReference.manipulators[i].unfolded, PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type), EditorStyles.foldout, GUILayout.Width(Screen.width/4));
						if (playgroundParticlesScriptReference.manipulators[i].transform.available && playgroundParticlesScriptReference.manipulators[i].transform.transform!=null) {
							if (GUILayout.Button(" ("+mName+")", EditorStyles.label)) {
								Selection.activeGameObject = playgroundParticlesScriptReference.manipulators[i].transform.transform.gameObject;
							}
						} else {
							GUILayout.Button(PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type)+" ("+playgroundLanguage.missingTransform+")", EditorStyles.label);
						}
						GUI.contentColor = Color.white;
						EditorGUILayout.Separator();
						GUI.enabled = (playgroundParticlesScriptReference.manipulators.Count>1);
						if(GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							manipulators.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.manipulators.Count-1:i-1);
						}
						if(GUILayout.Button(playgroundLanguage.downSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							manipulators.MoveArrayElement(i, i<playgroundParticlesScriptReference.manipulators.Count-1?i+1:0);
						}
						GUI.enabled = true;
						if(GUILayout.Button("+", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							playgroundParticlesScriptReference.manipulators.Add(playgroundParticlesScriptReference.manipulators[i].Clone());
						}
						if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							
							if (playgroundParticlesScriptReference.manipulators[i].transform.transform==null || EditorUtility.DisplayDialog(
								playgroundLanguage.remove+" "+PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type)+" "+playgroundLanguage.manipulator+" "+i+"?",
								playgroundLanguage.removeManipulator+mName+"? "+playgroundLanguage.gameObjectIntact, 
								playgroundLanguage.yes, playgroundLanguage.no)) {
									manipulators.DeleteArrayElementAtIndex(i);
									playgroundParticles.ApplyModifiedProperties();
									return;
								}
						}

						GUI.color = Color.white;
						
						EditorGUILayout.EndHorizontal();
						
						if (playgroundParticlesScriptReference.manipulators[i].unfolded && i<manipulators.arraySize) {
							PlaygroundInspectorC.RenderManipulatorSettings(playgroundParticlesScriptReference.manipulators[i], manipulators.GetArrayElementAtIndex(i), false);
						}

						GUI.enabled = true;
						EditorGUILayout.Separator();
						EditorGUILayout.EndVertical();
					}
					
				} else {
					EditorGUILayout.HelpBox(playgroundLanguage.noManipulators, MessageType.Info);
				}
				
				if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
					if (Selection.gameObjects.Length>0) {
						Transform mTrans = new GameObject().transform;
						mTrans.parent = playgroundParticlesScriptReference.particleSystemTransform;
						mTrans.localPosition = Vector3.up;
						if (playgroundParticlesScriptReference.manipulators.Count>0)
							mTrans.name = "Manipulator "+(playgroundParticlesScriptReference.manipulators.Count+1)+" ("+playgroundParticlesScriptReference.name+")";
						else mTrans.name = "Manipulator "+"("+playgroundParticlesScriptReference.name+")";
						PlaygroundC.ManipulatorObject(mTrans, playgroundParticlesScriptReference);
					} else {
						manipulators.InsertArrayElementAtIndex(manipulators.arraySize);
					}
					SceneView.RepaintAll();
				}
				
				EditorGUILayout.Separator();
			}

			// Event Settings
			if (GUILayout.Button(playgroundLanguage.events+" ("+playgroundParticlesScriptReference.events.Count+")", EditorStyles.toolbarDropDown)) playgroundSettings.eventsFoldout=!playgroundSettings.eventsFoldout;
			if (playgroundSettings.eventsFoldout) {
				
				EditorGUILayout.Separator();

				if (playgroundParticlesScriptReference.events.Count>0) {

					if (playgroundParticlesScriptReference.events.Count!=eventListFoldout.Count) {
						eventListFoldout = new List<bool>();
						eventListFoldout.AddRange(new bool[playgroundParticlesScriptReference.events.Count]);
					}

					string eName;
					for (int i = 0; i<playgroundParticlesScriptReference.events.Count; i++) {
						if (playgroundParticlesScriptReference.events[i].broadcastType!=EVENTBROADCASTC.EventListeners) {
							if (playgroundParticlesScriptReference.events[i].target!=null) {
								eName = playgroundParticlesScriptReference.events[i].target.name;
								if (eName.Length>24)
									eName = eName.Substring(0, 24)+"...";
							} else eName = "("+playgroundLanguage.noTarget+")";
						} else eName = "("+playgroundLanguage.eventListener+")";

						EditorGUILayout.BeginVertical("box");
						
						EditorGUILayout.BeginHorizontal();
						
						GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
						eventListFoldout[i] = GUILayout.Toggle(eventListFoldout[i], playgroundParticlesScriptReference.events[i].eventType.ToString(), EditorStyles.foldout, GUILayout.Width(Screen.width/4));
						if (playgroundParticlesScriptReference.events[i].target!=null) {
							if (GUILayout.Button(" ("+eName+")", EditorStyles.label)) {
								Selection.activeGameObject = playgroundParticlesScriptReference.events[i].target.gameObject;
							}
						} else {
							GUILayout.Button(eName, EditorStyles.label);
						}

						EditorGUILayout.Separator();
						GUI.enabled = (playgroundParticlesScriptReference.events.Count>1);
						if(GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							events.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.events.Count-1:i-1);
						}
						if(GUILayout.Button(playgroundLanguage.downSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							events.MoveArrayElement(i, i<playgroundParticlesScriptReference.events.Count-1?i+1:0);
						}
						GUI.enabled = true;
						if(GUILayout.Button("+", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							playgroundParticlesScriptReference.events.Add(playgroundParticlesScriptReference.events[i].Clone());
							eventListFoldout.Add(eventListFoldout[i]);
						}
						if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							
							if (playgroundParticlesScriptReference.events[i].target==null || EditorUtility.DisplayDialog(
								playgroundLanguage.remove+" "+playgroundParticlesScriptReference.events[i].eventType.ToString()+" "+playgroundLanguage.eventName+" "+i+"?",
								playgroundLanguage.removeEventInEventList, 
								playgroundLanguage.yes, playgroundLanguage.no)) {
								PlaygroundC.RemoveEvent (i, playgroundParticlesScriptReference);
								eventListFoldout.RemoveAt(i);
								playgroundParticles.ApplyModifiedProperties();
								return;
							}
						}
						
						EditorGUILayout.EndHorizontal();
						
						if (eventListFoldout[i] && i<events.arraySize) {
							RenderEventSettings(playgroundParticlesScriptReference.events[i], events.GetArrayElementAtIndex(i));
						}
						GUI.enabled = true;
						EditorGUILayout.Separator();
						EditorGUILayout.EndVertical();
					}
				} else {
					EditorGUILayout.HelpBox(playgroundLanguage.noEvents, MessageType.Info);
				}

				if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
					PlaygroundC.CreateEvent(playgroundParticlesScriptReference);
					eventListFoldout.Add(true);
				}
				
				EditorGUILayout.Separator();
			}

			// Snapshot Settings
			if (!playgroundParticlesScriptReference.isSnapshot) {
				if (GUILayout.Button(playgroundLanguage.snapshots+" ("+playgroundParticlesScriptReference.snapshots.Count+")", EditorStyles.toolbarDropDown)) playgroundSettings.saveLoadFoldout=!playgroundSettings.saveLoadFoldout;
				if (playgroundSettings.saveLoadFoldout) {

					EditorGUILayout.Separator();
					bool setThisLoadFrom = false;
					string loadModeButton = "";
					if (playgroundParticlesScriptReference.snapshots.Count>0 && isEditingInHierarchy) {
						GUILayout.BeginHorizontal();
						playgroundParticlesScriptReference.loadTransition = EditorGUILayout.ToggleLeft(playgroundLanguage.transitionTime, playgroundParticlesScriptReference.loadTransition, GUILayout.Width (Mathf.CeilToInt((Screen.width-140)/2)));
						GUI.enabled = playgroundParticlesScriptReference.loadTransition;
						playgroundParticlesScriptReference.loadTransitionTime = EditorGUILayout.Slider(playgroundParticlesScriptReference.loadTransitionTime, 0, playgroundSettings.maximumAllowedTransitionTime);
						GUILayout.EndHorizontal();
						EditorGUI.indentLevel++;
						playgroundParticlesScriptReference.loadTransitionType = (TRANSITIONTYPEC)EditorGUILayout.EnumPopup(playgroundLanguage.transitionType, playgroundParticlesScriptReference.loadTransitionType);
						EditorGUI.indentLevel--;
						GUI.enabled = true;
						EditorGUILayout.Separator();
						playgroundParticlesScriptReference.loadFromStart = EditorGUILayout.ToggleLeft(playgroundLanguage.loadFromStart, playgroundParticlesScriptReference.loadFromStart);

						for (int i = 0; i<playgroundParticlesScriptReference.snapshots.Count; i++) {
							setThisLoadFrom = false;
							GUILayout.BeginVertical (boxStyle);
							GUILayout.BeginHorizontal();

							if (playgroundParticlesScriptReference.loadFrom == i) {
								EditorGUILayout.Toggle (true, EditorStyles.radioButton, GUILayout.Width(14));
							} else
								setThisLoadFrom = EditorGUILayout.Toggle (setThisLoadFrom, EditorStyles.radioButton, GUILayout.Width(14));
							if (setThisLoadFrom)
								playgroundParticlesScriptReference.loadFrom = i;
							GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
							if (PlaygroundC.reference.showSnapshotsInHierarchy) {
								playgroundParticlesScriptReference.snapshots[i].unfolded = GUILayout.Toggle(playgroundParticlesScriptReference.snapshots[i].unfolded, "", EditorStyles.foldout);
								playgroundParticlesScriptReference.snapshots[i].settings.name = EditorGUILayout.TextField(playgroundParticlesScriptReference.snapshots[i].settings.name, EditorStyles.toolbarTextField);
								playgroundParticlesScriptReference.snapshots[i].name = playgroundParticlesScriptReference.snapshots[i].settings.name;
							} else {
								if (GUILayout.Button(playgroundParticlesScriptReference.snapshots[i].settings.name, EditorStyles.label, GUILayout.MinWidth (100)))
									playgroundParticlesScriptReference.loadFrom = i;
							}

							playgroundParticlesScriptReference.snapshots[i].loadTransform = EditorGUILayout.ToggleLeft (playgroundLanguage.transform, playgroundParticlesScriptReference.snapshots[i].loadTransform, EditorStyles.miniButton, GUILayout.MaxWidth(playgroundLanguage.transform.Length*10));
							playgroundParticlesScriptReference.snapshots[i].loadMaterial = EditorGUILayout.ToggleLeft (playgroundLanguage.material, playgroundParticlesScriptReference.snapshots[i].loadMaterial, EditorStyles.miniButton, GUILayout.MaxWidth(playgroundLanguage.material.Length*10));
							switch (playgroundParticlesScriptReference.snapshots[i].loadMode) {
							case 0: loadModeButton = playgroundLanguage.settingsAndParticles; break;
							case 1: loadModeButton = playgroundLanguage.settingsOnly; break;
							case 2: loadModeButton = playgroundLanguage.particlesOnly; break;
							default: loadModeButton = playgroundLanguage.settingsAndParticles; break;
							}
							if (GUILayout.Button(loadModeButton, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
								playgroundParticlesScriptReference.snapshots[i].loadMode++;
								playgroundParticlesScriptReference.snapshots[i].loadMode = playgroundParticlesScriptReference.snapshots[i].loadMode%3;
							}
							GUI.enabled = (playgroundParticlesScriptReference.snapshots.Count>1);
							if(GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								snapshots.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.snapshots.Count-1:i-1);
							}
							if(GUILayout.Button(playgroundLanguage.downSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								snapshots.MoveArrayElement(i, i<playgroundParticlesScriptReference.snapshots.Count-1?i+1:0);
							}
							GUI.enabled = true;
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								if (EditorUtility.DisplayDialog(
									playgroundLanguage.remove+" "+playgroundParticlesScriptReference.snapshots[i].name+"?",
									playgroundLanguage.removeSnapshot+" "+playgroundParticlesScriptReference.snapshots[i].name+" ("+i.ToString()+")?", 
									playgroundLanguage.yes, playgroundLanguage.no)) {
									DestroyImmediate (playgroundParticlesScriptReference.snapshots[i].settings.gameObject);
									playgroundParticlesScriptReference.snapshots.RemoveAt(i);
									if (playgroundParticlesScriptReference.loadFrom>=playgroundParticlesScriptReference.snapshots.Count)
										playgroundParticlesScriptReference.loadFrom = playgroundParticlesScriptReference.snapshots.Count-1;
									return;
								}
							}
							GUILayout.EndHorizontal();
							if (PlaygroundC.reference.showSnapshotsInHierarchy && playgroundParticlesScriptReference.snapshots[i].unfolded) {
								EditorGUILayout.Separator();
								EditorGUI.indentLevel+=3;
								PlaygroundParticlesC currentSnapshot = playgroundParticlesScriptReference.snapshots[i].settings;
								playgroundParticlesScriptReference.snapshots[i].settings = (PlaygroundParticlesC)EditorGUILayout.ObjectField(playgroundLanguage.snapshot, playgroundParticlesScriptReference.snapshots[i].settings, typeof(PlaygroundParticlesC), true);
								if (playgroundParticlesScriptReference.snapshots[i].settings!=currentSnapshot) {
									if (!playgroundParticlesScriptReference.snapshots[i].settings.isSnapshot) {
										EditorUtility.DisplayDialog(
											playgroundParticlesScriptReference.snapshots[i].settings.name+" "+playgroundLanguage.notSnapshot,
											playgroundLanguage.notSnapshotText,
											playgroundLanguage.ok
											);
										playgroundParticlesScriptReference.snapshots[i].settings = currentSnapshot;
										continue;
									}
								}
								GUI.enabled = playgroundParticlesScriptReference.loadTransition;
								playgroundParticlesScriptReference.snapshots[i].transitionType = (INDIVIDUALTRANSITIONTYPEC)EditorGUILayout.EnumPopup(playgroundLanguage.transitionType, playgroundParticlesScriptReference.snapshots[i].transitionType);
								playgroundParticlesScriptReference.snapshots[i].transitionMultiplier = EditorGUILayout.FloatField(playgroundLanguage.transitionTimeMultiplier, playgroundParticlesScriptReference.snapshots[i].transitionMultiplier);
								playgroundParticlesScriptReference.snapshots[i].setMaterialAfterTransition = EditorGUILayout.Toggle(playgroundLanguage.setMaterialAfterTransition, playgroundParticlesScriptReference.snapshots[i].setMaterialAfterTransition);
								GUI.enabled = true;
								EditorGUI.indentLevel-=3;
								EditorGUILayout.Separator();
							}
							GUILayout.EndVertical ();
						}
						EditorGUILayout.Separator();
					} else {
						if (playgroundParticlesScriptReference.snapshots.Count>0)
							EditorGUILayout.HelpBox(playgroundLanguage.editFromHierarchyOnly, MessageType.Info);
						else
							EditorGUILayout.HelpBox(playgroundLanguage.noSnapshots, MessageType.Info);
					}
					if (isEditingInHierarchy) {
						GUILayout.BeginHorizontal();
						if(GUILayout.Button(playgroundLanguage.save, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
							saveName = playgroundLanguage.newSnapshotName+" "+(playgroundParticlesScriptReference.snapshots.Count+1).ToString();
							playgroundParticlesScriptReference.Save(saveName);
							if (playgroundParticlesScriptReference.loadFrom>=playgroundParticlesScriptReference.snapshots.Count && playgroundParticlesScriptReference.snapshots.Count>0)
								playgroundParticlesScriptReference.loadFrom = playgroundParticlesScriptReference.snapshots.Count-1;
						}
						GUI.enabled = (playgroundParticlesScriptReference.snapshots.Count>0);
						if(GUILayout.Button(playgroundLanguage.load, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
							playgroundParticlesScriptReference.Load(playgroundParticlesScriptReference.loadFrom);
						}
						GUILayout.FlexibleSpace();
						if (playgroundScriptReference!=null) {
							if(GUILayout.Button(playgroundScriptReference.showSnapshotsInHierarchy?playgroundLanguage.simple:playgroundLanguage.advanced, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
								playgroundScriptReference.showSnapshotsInHierarchy = !playgroundScriptReference.showSnapshotsInHierarchy;
								PlaygroundInspectorC.UpdateSnapshots();
							}
						}
						if(GUILayout.Button(playgroundLanguage.removeAll, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
							if (EditorUtility.DisplayDialog(
								playgroundLanguage.removeAllSnapshots,
								playgroundLanguage.removeAllSnapshotsText, 
								playgroundLanguage.yes, playgroundLanguage.no)) {
								for (int s = 0; s<playgroundParticlesScriptReference.snapshots.Count; s++) {
									DestroyImmediate (playgroundParticlesScriptReference.snapshots[s].settings.gameObject);
								}
								playgroundParticlesScriptReference.snapshots.Clear ();
								return;
							}
						}
						GUI.enabled = true;
						GUILayout.EndHorizontal();
					}
					EditorGUILayout.Separator();
				}
			}

			// Advanced Settings
			string localSimulationSpaceName = playgroundParticlesScriptReference.GetComponent<ParticleSystem>().simulationSpace==ParticleSystemSimulationSpace.Local?playgroundLanguage.localSpace:playgroundLanguage.globalSpace;
			if (GUILayout.Button(playgroundLanguage.advanced+" ("+localSimulationSpaceName+")", EditorStyles.toolbarDropDown)) playgroundSettings.advancedFoldout=!playgroundSettings.advancedFoldout;
			if (playgroundSettings.advancedFoldout) {

				// Simulation space
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.advancedSimulationFoldout = GUILayout.Toggle(playgroundSettings.advancedSimulationFoldout, playgroundLanguage.simulationSpace, EditorStyles.foldout);
				GUILayout.Label (playgroundParticlesScriptReference.GetComponent<ParticleSystem>().simulationSpace.ToString(), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.advancedSimulationFoldout) {
					GUI.enabled = (playgroundParticlesScriptReference.source!=SOURCEC.Projection);
					playgroundParticlesScriptReference.GetComponent<ParticleSystem>().simulationSpace = (ParticleSystemSimulationSpace)EditorGUILayout.EnumPopup(playgroundLanguage.simulationSpace, playgroundParticlesScriptReference.GetComponent<ParticleSystem>().simulationSpace);
					GUI.enabled = true;
					if (playgroundParticlesScriptReference.GetComponent<ParticleSystem>().simulationSpace==ParticleSystemSimulationSpace.Local && playgroundParticlesScriptReference.source!=SOURCEC.Projection) {

						playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation = EditorGUILayout.ToggleLeft (playgroundLanguage.movementCompensation, playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation);
						GUI.enabled = playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation;
						GUILayout.BeginHorizontal();
						EditorGUI.indentLevel++;
						playgroundParticlesScriptReference.applyMovementCompensationLifetimeStrength = EditorGUILayout.ToggleLeft (playgroundLanguage.movementCompensationLifetimeStrength, playgroundParticlesScriptReference.applyMovementCompensationLifetimeStrength, GUILayout.MaxWidth(Mathf.CeilToInt(EditorGUIUtility.labelWidth)-20));
						GUI.enabled = playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation && playgroundParticlesScriptReference.applyMovementCompensationLifetimeStrength;
						movementCompensationLifetimeStrength.animationCurveValue = EditorGUILayout.CurveField(movementCompensationLifetimeStrength.animationCurveValue);
						GUILayout.EndHorizontal();
						GUI.enabled = true;
						EditorGUI.indentLevel--;
						if (playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation && playgroundParticlesScriptReference.source==SOURCEC.Transform && playgroundParticlesScriptReference.sourceTransforms!=null && playgroundParticlesScriptReference.sourceTransforms[0].transform!=null && playgroundParticlesScriptReference.particleSystemTransform==playgroundParticlesScriptReference.sourceTransforms[0].transform)
							EditorGUILayout.HelpBox(playgroundLanguage.useAnotherSourceTransform, MessageType.Warning);


					} else if (playgroundParticlesScriptReference.source==SOURCEC.Projection) {
						EditorGUILayout.HelpBox(playgroundLanguage.projectionOnlyWorldSpace, MessageType.Info);
					}
				}
				GUILayout.EndVertical();

				EditorGUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.advancedTimeFoldout = GUILayout.Toggle(playgroundSettings.advancedTimeFoldout, playgroundLanguage.time, EditorStyles.foldout);
				GUILayout.Label (playgroundParticlesScriptReference.particleTimescale.ToString("F1"), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.advancedTimeFoldout) {
					
					// Update rate
					updateRate.intValue = EditorGUILayout.IntSlider(playgroundLanguage.updateRate, updateRate.intValue, playgroundSettings.minimumAllowedUpdateRate, 1);
					
					// Time scale
					playgroundParticlesScriptReference.particleTimescale = EditorGUILayout.Slider (playgroundLanguage.timeScale, playgroundParticlesScriptReference.particleTimescale, 0, playgroundSettings.maximumAllowedTimescale);
				}
				EditorGUILayout.EndVertical();


				// Rebirth Options
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				bool hasRebirthOptions = 
						playgroundParticlesScriptReference.applyRandomLifetimeOnRebirth||
						playgroundParticlesScriptReference.applyRandomSizeOnRebirth||
						playgroundParticlesScriptReference.applyRandomRotationOnRebirth||
						playgroundParticlesScriptReference.applyRandomScatterOnRebirth||
						playgroundParticlesScriptReference.applyRandomInitialVelocityOnRebirth||
						playgroundParticlesScriptReference.applyInitialColorOnRebirth||
						playgroundParticlesScriptReference.applyDeltaOnRebirth||
						playgroundParticlesScriptReference.calculateManipulatorOnRebirth;
				playgroundSettings.advancedRebirthOptionsFoldout = GUILayout.Toggle(playgroundSettings.advancedRebirthOptionsFoldout, playgroundLanguage.rebirthOptions, EditorStyles.foldout);
				GUILayout.Label (hasRebirthOptions?playgroundLanguage.on:playgroundLanguage.off, EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.advancedRebirthOptionsFoldout) {
					playgroundParticlesScriptReference.applyRandomLifetimeOnRebirth = EditorGUILayout.Toggle (playgroundLanguage.randomLifetime, playgroundParticlesScriptReference.applyRandomLifetimeOnRebirth);
					playgroundParticlesScriptReference.applyRandomSizeOnRebirth = EditorGUILayout.Toggle (playgroundLanguage.randomSize, playgroundParticlesScriptReference.applyRandomSizeOnRebirth);
					playgroundParticlesScriptReference.applyRandomRotationOnRebirth = EditorGUILayout.Toggle (playgroundLanguage.randomRotation, playgroundParticlesScriptReference.applyRandomRotationOnRebirth);
					playgroundParticlesScriptReference.applyRandomScatterOnRebirth = EditorGUILayout.Toggle (playgroundLanguage.randomScatter, playgroundParticlesScriptReference.applyRandomScatterOnRebirth);
					playgroundParticlesScriptReference.applyRandomInitialVelocityOnRebirth = EditorGUILayout.Toggle (playgroundLanguage.randomVelocity, playgroundParticlesScriptReference.applyRandomInitialVelocityOnRebirth);
					playgroundParticlesScriptReference.applyInitialColorOnRebirth = EditorGUILayout.Toggle (playgroundLanguage.forceInitialColor, playgroundParticlesScriptReference.applyInitialColorOnRebirth);
					playgroundParticlesScriptReference.applyDeltaOnRebirth = EditorGUILayout.Toggle (playgroundLanguage.deltaPositionAdjustment, playgroundParticlesScriptReference.applyDeltaOnRebirth);
					playgroundParticlesScriptReference.calculateManipulatorOnRebirth = EditorGUILayout.Toggle (playgroundLanguage.calculateManipulator, playgroundParticlesScriptReference.calculateManipulatorOnRebirth);
				}
				GUILayout.EndVertical();

				// Locks
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.advancedLocksFoldout = GUILayout.Toggle(playgroundSettings.advancedLocksFoldout, playgroundLanguage.locks, EditorStyles.foldout);
				GUILayout.Label ((playgroundParticlesScriptReference.applyLockPosition||playgroundParticlesScriptReference.applyLockRotation||playgroundParticlesScriptReference.applyLockScale?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.advancedLocksFoldout) {
					playgroundParticlesScriptReference.applyLockPosition = EditorGUILayout.ToggleLeft(playgroundLanguage.lockPosition, playgroundParticlesScriptReference.applyLockPosition);
					GUI.enabled = playgroundParticlesScriptReference.applyLockPosition;
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.lockPosition = EditorGUILayout.Vector3Field (playgroundLanguage.position, playgroundParticlesScriptReference.lockPosition);
					playgroundParticlesScriptReference.lockPositionIsLocal = EditorGUILayout.Toggle(playgroundLanguage.positionIsLocal, playgroundParticlesScriptReference.lockPositionIsLocal);
					EditorGUI.indentLevel--;
					GUI.enabled = true;
					EditorGUILayout.Separator();
					playgroundParticlesScriptReference.applyLockRotation = EditorGUILayout.ToggleLeft(playgroundLanguage.lockRotation, playgroundParticlesScriptReference.applyLockRotation);
					GUI.enabled = playgroundParticlesScriptReference.applyLockRotation;
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.lockRotation = EditorGUILayout.Vector3Field (playgroundLanguage.rotation, playgroundParticlesScriptReference.lockRotation);
					playgroundParticlesScriptReference.lockRotationIsLocal = EditorGUILayout.Toggle(playgroundLanguage.rotationIsLocal, playgroundParticlesScriptReference.lockRotationIsLocal);
					EditorGUI.indentLevel--;
					GUI.enabled = true;
					EditorGUILayout.Separator();
					playgroundParticlesScriptReference.applyLockScale = EditorGUILayout.ToggleLeft(playgroundLanguage.lockScale, playgroundParticlesScriptReference.applyLockScale);
					GUI.enabled = playgroundParticlesScriptReference.applyLockScale;
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.lockScale = EditorGUILayout.Vector3Field (playgroundLanguage.scale, playgroundParticlesScriptReference.lockScale);
					EditorGUI.indentLevel--;
					GUI.enabled = true;
				}
				GUILayout.EndVertical();
				
				// On Enable (Prewarm)
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.advancedOnEnableFoldout = GUILayout.Toggle(playgroundSettings.advancedOnEnableFoldout, playgroundLanguage.onEnable, EditorStyles.foldout);
				GUILayout.Label (playgroundLanguage.prewarm+" "+(playgroundParticlesScriptReference.prewarm?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.advancedOnEnableFoldout) {
					bool previousPrewarm = playgroundParticlesScriptReference.prewarm;
					float previousPrewarmTime = playgroundParticlesScriptReference.prewarmTime;
					int previousPrewarmCycles = playgroundParticlesScriptReference.prewarmCycles;
					playgroundParticlesScriptReference.prewarm = EditorGUILayout.ToggleLeft (playgroundLanguage.prewarm, playgroundParticlesScriptReference.prewarm);
					GUI.enabled = playgroundParticlesScriptReference.prewarm;
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.prewarmTime = EditorGUILayout.Slider (playgroundLanguage.prewarmLifetimeCycles, playgroundParticlesScriptReference.prewarmTime, 0, 2f);
					playgroundParticlesScriptReference.prewarmCycles = EditorGUILayout.IntField (playgroundLanguage.prewarmCyclesResolution, playgroundParticlesScriptReference.prewarmCycles);
					playgroundParticlesScriptReference.prewarmCycles = Mathf.Clamp (playgroundParticlesScriptReference.prewarmCycles, 8, playgroundSettings.maximumAllowedPrewarmCycles);
					EditorGUI.indentLevel--;
					if (previousPrewarm != playgroundParticlesScriptReference.prewarm || previousPrewarmTime != playgroundParticlesScriptReference.prewarmTime || previousPrewarmCycles != playgroundParticlesScriptReference.prewarmCycles)
						LifetimeSorting();
					GUI.enabled = true;
				}
				GUILayout.EndVertical();

				// Auto Pause
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.advancedAutoPauseFoldout = GUILayout.Toggle(playgroundSettings.advancedAutoPauseFoldout, playgroundLanguage.outOfView, EditorStyles.foldout);
				GUILayout.Label (playgroundLanguage.autoPause+" "+(playgroundParticlesScriptReference.pauseCalculationWhenInvisible?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.advancedAutoPauseFoldout) {
					playgroundParticlesScriptReference.pauseCalculationWhenInvisible = EditorGUILayout.ToggleLeft (playgroundLanguage.autoPauseCalculation, playgroundParticlesScriptReference.pauseCalculationWhenInvisible);
					EditorGUI.indentLevel++;
					GUI.enabled = playgroundParticlesScriptReference.pauseCalculationWhenInvisible;
					playgroundParticlesScriptReference.calculationTriggerTransform = (Transform)EditorGUILayout.ObjectField(playgroundLanguage.calculationTrigger, playgroundParticlesScriptReference.calculationTriggerTransform, typeof(Transform), true);
					playgroundParticlesScriptReference.calculationTriggerSize = EditorGUILayout.Vector3Field(playgroundLanguage.calculationTriggerSize, playgroundParticlesScriptReference.calculationTriggerSize);
					playgroundParticlesScriptReference.calculationTriggerOffset = EditorGUILayout.Vector3Field(playgroundLanguage.calculationTriggerOffset, playgroundParticlesScriptReference.calculationTriggerOffset);
					playgroundParticlesScriptReference.calculationTriggerSizeGizmo = EditorGUILayout.Toggle(playgroundLanguage.drawGizmo, playgroundParticlesScriptReference.calculationTriggerSizeGizmo);
					GUI.enabled = true;
					EditorGUI.indentLevel--;
				}
				EditorGUILayout.EndVertical();

				// Misc
				GUILayout.BeginVertical(boxStyle);
				GUILayout.BeginHorizontal();
				playgroundSettings.advancedMiscFoldout = GUILayout.Toggle(playgroundSettings.advancedMiscFoldout, playgroundLanguage.misc, EditorStyles.foldout);
				GUILayout.Label (playgroundLanguage.sync+" "+(playgroundParticlesScriptReference.syncPositionsOnMainThread?playgroundLanguage.on:playgroundLanguage.off), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
				GUILayout.EndHorizontal();
				if (playgroundSettings.advancedMiscFoldout) {
					playgroundParticlesScriptReference.syncPositionsOnMainThread = EditorGUILayout.Toggle (playgroundLanguage.syncParticlesToMainThread, playgroundParticlesScriptReference.syncPositionsOnMainThread);
					EditorGUILayout.PropertyField(threadMethod, new GUIContent(playgroundLanguage.particleThreadMethod, playgroundLanguage.threadMethodDescription));
					EditorGUILayout.Separator();
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.particlePool);
					
					// Clear
					if(GUILayout.Button(playgroundLanguage.clear, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) && isEditingInHierarchy){
						PlaygroundParticlesC.Clear(playgroundParticlesScriptReference);
					}
					
					// Rebuild
					if(GUILayout.Button(playgroundLanguage.rebuild, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) && isEditingInHierarchy){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.particleCount);
						playgroundParticlesScriptReference.Start();
					}
					GUILayout.EndHorizontal();
				}
				EditorGUILayout.EndVertical();
			}

			EditorGUILayout.EndVertical();

			previousSource = playgroundParticlesScriptReference.source;
			if (playgroundParticles.ApplyModifiedProperties())
				playgroundParticlesScriptReference.IsDoneThread = true;
		}
		
		EditorGUILayout.EndVertical();
		
		// Playground Manager - Particle Systems, Manipulators
		PlaygroundInspectorC.RenderPlaygroundSettings();

		// Wireframes in Scene View
		if (isEditingInHierarchy)
			if (currentWireframe!=PlaygroundC.reference.drawWireframe)
				SetWireframeVisibility();
	}
	void OnEnable () {

		lastActiveTool = Tools.current;
		isEditingInHierarchy = Selection.activeTransform!=null;

		// Load settings
		playgroundSettings = PlaygroundSettingsC.GetReference();
		
		// Load language
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
		
		// Playground Particles
		playgroundParticlesScriptReference = target as PlaygroundParticlesC;
		if (playgroundParticlesScriptReference==null) return;
		playgroundParticles = new SerializedObject(playgroundParticlesScriptReference);
		
		shurikenRenderer = playgroundParticlesScriptReference.particleSystemGameObject.GetComponent<ParticleSystem>().GetComponent<Renderer>() as ParticleSystemRenderer;

		// Sorting layers
		Type internalEditorUtilityType = typeof(InternalEditorUtility);
		PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
		rendererSortingLayers = (string[])sortingLayersProperty.GetValue(null, new object[0]);
		for (int i = 0; i<rendererSortingLayers.Length; i++) {
			if (shurikenRenderer.sortingLayerName == rendererSortingLayers[i])
				selectedSortingLayer = i;
		}

		// UV Module (Texture Sheet Animation)
		shuriken = new SerializedObject(playgroundParticlesScriptReference.shurikenParticleSystem);
		uvModule = shuriken.FindProperty("UVModule");
		uvModule_enabled = uvModule.FindPropertyRelative("enabled");
		uvModule_frameOverTime_scalar = uvModule.FindPropertyRelative("frameOverTime.scalar");
		uvModule_frameOverTime_minCurve = uvModule.FindPropertyRelative("frameOverTime.minCurve");
		uvModule_frameOverTime_maxCurve = uvModule.FindPropertyRelative("frameOverTime.maxCurve");
		uvModule_frameOverTime_minMaxState = uvModule.FindPropertyRelative("frameOverTime.minMaxState");
		uvModule_tilesX = uvModule.FindPropertyRelative("tilesX");
		uvModule_tilesY = uvModule.FindPropertyRelative("tilesY");
		uvModule_animationType = uvModule.FindPropertyRelative("animationType");
		uvModule_rowIndex = uvModule.FindPropertyRelative("rowIndex");
		uvModule_cycles = uvModule.FindPropertyRelative("cycles");
		uvModule_randomRow = uvModule.FindPropertyRelative("randomRow");
		uv_animationType = (AnimationType)uvModule_animationType.intValue;
		uv_minMaxState = (MinMaxState)uvModule_frameOverTime_minMaxState.intValue;


		shurikenRendererSO = new SerializedObject(shurikenRenderer);
		sortingMode = shurikenRendererSO.FindProperty("m_SortMode");
		sortingFudge = shurikenRendererSO.FindProperty("m_SortingFudge");
		sortMode = (SortMode)sortingMode.intValue;

		manipulators = playgroundParticles.FindProperty("manipulators");
		events = playgroundParticles.FindProperty("events");
		snapshots = playgroundParticles.FindProperty("snapshots");
		source = playgroundParticles.FindProperty("source");
		sorting = playgroundParticles.FindProperty("sorting");
		lifetimeSorting = playgroundParticles.FindProperty("lifetimeSorting");
		activeState = playgroundParticles.FindProperty("activeState");
		particleCount = playgroundParticles.FindProperty("particleCount");
		emissionRate = playgroundParticles.FindProperty("emissionRate");
		updateRate = playgroundParticles.FindProperty("updateRate");
		emit = playgroundParticles.FindProperty("emit");
		loop = playgroundParticles.FindProperty("loop");
		disableOnDone = playgroundParticles.FindProperty("disableOnDone");
		disableOnDoneRoutine = playgroundParticles.FindProperty("disableOnDoneRoutine");
		calculate = playgroundParticles.FindProperty("calculate");
		deltaMovementStrength = playgroundParticles.FindProperty("deltaMovementStrength");
		particleTimescale = playgroundParticles.FindProperty("particleTimescale");
		sizeMin = playgroundParticles.FindProperty("sizeMin");
		sizeMax = playgroundParticles.FindProperty("sizeMax");
		overflowOffset = playgroundParticles.FindProperty("overflowOffset");
		overflowMode = playgroundParticles.FindProperty("overflowMode");
		lifetime = playgroundParticles.FindProperty("lifetime");
		lifetimeSize = playgroundParticles.FindProperty("lifetimeSize");
		arraySize = playgroundParticles.FindProperty("particleArraySize");
		turbulenceLifetimeStrength = playgroundParticles.FindProperty("turbulenceLifetimeStrength");
		lifetimeVelocity = playgroundParticles.FindProperty("lifetimeVelocity");
		initialVelocityShape = playgroundParticles.FindProperty("initialVelocityShape");
		initialVelocityMin = playgroundParticles.FindProperty("initialVelocityMin");
		initialVelocityMax = playgroundParticles.FindProperty("initialVelocityMax");
		initialLocalVelocityMin = playgroundParticles.FindProperty("initialLocalVelocityMin");
		initialLocalVelocityMax = playgroundParticles.FindProperty("initialLocalVelocityMax");
		lifetimeColor = playgroundParticles.FindProperty("lifetimeColor");
		lifetimeColors = playgroundParticles.FindProperty ("lifetimeColors");
		arrayColor = playgroundParticles.FindProperty("arrayColorAlpha");
		colorSource = playgroundParticles.FindProperty("colorSource");
		collision = playgroundParticles.FindProperty("collision");
		affectRigidbodies = playgroundParticles.FindProperty("affectRigidbodies");
		mass = playgroundParticles.FindProperty("mass");
		collisionRadius = playgroundParticles.FindProperty("collisionRadius");
		collisionMask = playgroundParticles.FindProperty("collisionMask");
		collisionType = playgroundParticles.FindProperty("collisionType");
		bounciness = playgroundParticles.FindProperty("bounciness");
		states = playgroundParticles.FindProperty("states");
		worldObject = playgroundParticles.FindProperty("worldObject");
		skinnedWorldObject = playgroundParticles.FindProperty("skinnedWorldObject");
		forceSkinnedMeshUpdateOnMainThread = playgroundParticles.FindProperty ("forceSkinnedMeshUpdateOnMainThread");
		sourceTransform = playgroundParticles.FindProperty("sourceTransform");
		worldObjectUpdateVertices = playgroundParticles.FindProperty ("worldObjectUpdateVertices");
		worldObjectUpdateNormals = playgroundParticles.FindProperty("worldObjectUpdateNormals");
		sourcePaint = playgroundParticles.FindProperty("paint");
		sourceProjection = playgroundParticles.FindProperty("projection");
		sourceSplines = playgroundParticles.FindProperty("splines");
		sourceTransforms = playgroundParticles.FindProperty("sourceTransforms");
		lifetimeStretching = playgroundParticles.FindProperty("stretchLifetime");
		threadMethod = playgroundParticles.FindProperty("threadMethod");

		playgroundParticlesScriptReference.shurikenParticleSystem = playgroundParticlesScriptReference.GetComponent<ParticleSystem>();
		playgroundParticlesScriptReference.particleSystemRenderer = playgroundParticlesScriptReference.shurikenParticleSystem.GetComponent<Renderer>();
		particleMaterial = playgroundParticlesScriptReference.particleSystemRenderer.sharedMaterial;
		
		onlySourcePositioning = playgroundParticles.FindProperty("onlySourcePositioning");

		lifetimePositioning = playgroundParticles.FindProperty("lifetimePositioning");
		lifetimePositioningX = lifetimePositioning.FindPropertyRelative("x");
		lifetimePositioningY = lifetimePositioning.FindPropertyRelative("y");
		lifetimePositioningZ = lifetimePositioning.FindPropertyRelative("z");
		lifetimePositioningTimeScale = playgroundParticles.FindProperty ("lifetimePositioningTimeScale");
		lifetimePositioningPositionScale = playgroundParticles.FindProperty ("lifetimePositioningPositionScale");

		applyLifetimeVelocity = playgroundParticles.FindProperty("applyLifetimeVelocity");
		lifeTimeVelocityX = lifetimeVelocity.FindPropertyRelative("x");
		lifeTimeVelocityY = lifetimeVelocity.FindPropertyRelative("y");
		lifeTimeVelocityZ = lifetimeVelocity.FindPropertyRelative("z");
		
		initialVelocityShapeX = initialVelocityShape.FindPropertyRelative("x");
		initialVelocityShapeY = initialVelocityShape.FindPropertyRelative("y");
		initialVelocityShapeZ = initialVelocityShape.FindPropertyRelative("z");
		
		applyInitialVelocity = playgroundParticles.FindProperty("applyInitialVelocity");
		applyInitialLocalVelocity = playgroundParticles.FindProperty("applyInitialLocalVelocity");
		applyVelocityBending = playgroundParticles.FindProperty("applyVelocityBending");
		velocityBendingType = playgroundParticles.FindProperty("velocityBendingType");

		movementCompensationLifetimeStrength = playgroundParticles.FindProperty ("movementCompensationLifetimeStrength");
		
		worldObjectGameObject = worldObject.FindPropertyRelative("gameObject");
		skinnedWorldObjectGameObject = skinnedWorldObject.FindPropertyRelative("gameObject");

		// Lifetime colors
		if (playgroundParticlesScriptReference.lifetimeColors==null)
			playgroundParticlesScriptReference.lifetimeColors = new List<PlaygroundGradientC>();

		// Sorting
		prevLifetimeSortingKeys = playgroundParticlesScriptReference.lifetimeSorting.keys;

		// Events list
		eventListFoldout = new List<bool>();
		eventListFoldout.AddRange(new bool[playgroundParticlesScriptReference.events.Count]);

		// States foldout
		statesListFoldout = new List<bool>();
		statesListFoldout.AddRange(new bool[playgroundParticlesScriptReference.states.Count]);

		previousSource = playgroundParticlesScriptReference.source;
		
		// Playground
		playgroundScriptReference = FindObjectOfType<PlaygroundC>();
		
		
		// Create a manager if no existing instance is in the scene
		if (!playgroundScriptReference && Selection.activeTransform!=null) {
			PlaygroundC.ResourceInstantiate("Playground Manager");
			playgroundScriptReference = FindObjectOfType<PlaygroundC>();
		}
		
		if (playgroundScriptReference!=null) {

			PlaygroundC.reference = playgroundScriptReference;

			// Serialize Playground
			playground = new SerializedObject(playgroundScriptReference);
			
			PlaygroundInspectorC.Initialize(playgroundScriptReference);
			
			
			// Add this PlaygroundParticles if not existing in Playground list
			if (!playgroundParticlesScriptReference.isSnapshot && !playgroundScriptReference.particleSystems.Contains(playgroundParticlesScriptReference) && Selection.activeTransform!=null)
				playgroundScriptReference.particleSystems.Add(playgroundParticlesScriptReference);
				
			// Cache components
			playgroundParticlesScriptReference.particleSystemGameObject = playgroundParticlesScriptReference.gameObject;
			playgroundParticlesScriptReference.particleSystemTransform = playgroundParticlesScriptReference.transform;
			playgroundParticlesScriptReference.particleSystemRenderer = playgroundParticlesScriptReference.GetComponent<Renderer>();
			playgroundParticlesScriptReference.shurikenParticleSystem = playgroundParticlesScriptReference.particleSystemGameObject.GetComponent<ParticleSystem>();
			playgroundParticlesScriptReference.particleSystemRenderer2 = playgroundParticlesScriptReference.particleSystemGameObject.GetComponent<ParticleSystem>().GetComponent<Renderer>() as ParticleSystemRenderer;
			
			// Set manager as parent 
			//if (PlaygroundC.reference.autoGroup && playgroundParticlesScriptReference.particleSystemTransform!=null && playgroundParticlesScriptReference.particleSystemTransform.parent == null && Selection.activeTransform!=null)
			//	playgroundParticlesScriptReference.particleSystemTransform.parent = PlaygroundC.referenceTransform;
			
			// Issue a quick refresh

			if (!EditorApplication.isPlaying && isEditingInHierarchy) {
				foreach (PlaygroundParticlesC p in PlaygroundC.reference.particleSystems) {
					p.Start();
				}
			}
		}

		selectedSort = sorting.intValue;

		// State initial values
		if (addStateTransform==null)
			addStateTransform = (Transform)playgroundParticlesScriptReference.particleSystemTransform;
		
		// Visiblity of Shuriken component in Inspector
		if (!playgroundScriptReference || playgroundScriptReference && !playgroundScriptReference.showShuriken)
			playgroundParticlesScriptReference.shurikenParticleSystem.hideFlags = HideFlags.HideInInspector;
		else
			playgroundParticlesScriptReference.shurikenParticleSystem.hideFlags = HideFlags.None;

		SetWireframeVisibility();

		// Set paint init
		paintLayerMask = sourcePaint.FindPropertyRelative("layerMask");
		paintCollisionType = sourcePaint.FindPropertyRelative("collisionType");
		
		// Set projection init
		projectionMask = sourceProjection.FindPropertyRelative("projectionMask");
		projectionCollisionType = sourceProjection.FindPropertyRelative("collisionType");

		// Snapshots
		if (playgroundParticlesScriptReference.snapshots.Count>0) {
			if (playgroundParticlesScriptReference.snapshots.Count>0) {
				for (int i = 0; i<playgroundParticlesScriptReference.snapshots.Count; i++)
					if (playgroundParticlesScriptReference.snapshots[i].settings==null)
						playgroundParticlesScriptReference.snapshots.RemoveAt(i);
			}
			saveName += " "+(playgroundParticlesScriptReference.snapshots.Count+1).ToString();
		}

		SetMissingKeys();
	}
	public override void OnInspectorGUI () {
		if (boxStyle==null)
			boxStyle = GUI.skin.FindStyle("box");
		
		if (Selection.activeTransform==null) {
			EditorGUILayout.LabelField("Please edit this from Hieararchy only.");
			return;
		}
		
		if (Event.current.type == EventType.ValidateCommand &&
			Event.current.commandName == "UndoRedoPerformed") {			
				PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.particleCount);
				LifetimeSorting();
		}
		
		playgroundParticles.Update();
		
		EditorGUILayout.Separator();
		
		GUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Particle Playground v"+PlaygroundC.version.ToString(), EditorStyles.largeLabel, GUILayout.Height(20));
		
		EditorGUILayout.Separator();
		
		if(GUILayout.Button("Open Playground Wizard", EditorStyles.toolbarButton)) {
			PlaygroundParticleWindowC.ShowWindow();
		}
		GUILayout.EndHorizontal();
		
		EditorGUILayout.Separator();
		
		// Particles
		EditorGUILayout.BeginVertical(boxStyle);
		particlesFoldout = GUILayout.Toggle(particlesFoldout, "Playground Particles", EditorStyles.foldout);
		if (particlesFoldout) {
			
			EditorGUILayout.BeginVertical(boxStyle);
			
			// Source Settings
			if (GUILayout.Button("Source", EditorStyles.toolbarDropDown)) sourceFoldout=!sourceFoldout;
			if (sourceFoldout) {
				
				EditorGUILayout.Separator();
				
				if (previousSource!=playgroundParticlesScriptReference.source) {
					LifetimeSorting();
				}
				EditorGUILayout.PropertyField(source, new GUIContent(
					"Source", 
					"Source is the target method for the particles in this Particle Playground System.\n\nState: Target position and color in a stored state\n\nTransform: Target transforms live in the scene\n\nWorldObject: Target each vertex in a mesh live in the scene\n\nSkinnedWorldObject: Target each vertex in a skinned mesh live in the scene\n\nScript: Behaviour controlled by custom scripts\n\nPaint: Target painted positions and colors made with a brush\n\nProjection: Target projected positions and colors made with a texture")
				);
				
				EditorGUILayout.Separator();
				
				// Source is State
				if (source.intValue == 0) {
					RenderStateSettings();
					
				// Source is Projection
				} else if (source.intValue == 6) {
					RenderProjectionSettings();
				
				// Source is Transforms
				} else if (source.intValue == 1) {
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Transform");
					sourceTransform.objectReferenceValue = EditorGUILayout.ObjectField(sourceTransform.objectReferenceValue, typeof(Transform), true);
					GUILayout.EndHorizontal();
					
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Points:");
					EditorGUILayout.SelectableLabel(sourceTransform.objectReferenceValue!=null?"1":"0", GUILayout.MaxWidth(80));
					EditorGUILayout.Separator();
					if(GUILayout.Button("Set Particle Count", EditorStyles.toolbarButton)){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, sourceTransform.objectReferenceValue!=null?1:0);
						playgroundParticlesScriptReference.Start();
					}
					GUI.enabled = (sourceTransform.objectReferenceValue!=null);
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
						particleCount.intValue = particleCount.intValue+1;
					GUI.enabled = true;
					GUILayout.EndHorizontal();
					
				// Source is World Object
				} else if (source.intValue == 2) {
					GUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("World Object", GUILayout.Width(Mathf.FloorToInt(Screen.width/2.2f)-46));
					
					int worldObjRefId = worldObjectGameObject.objectReferenceInstanceIDValue;
					worldObjectGameObject.objectReferenceValue = EditorGUILayout.ObjectField(worldObjectGameObject.objectReferenceValue, typeof(GameObject), true);
					GUILayout.EndHorizontal();
					if (worldObjRefId!=playgroundParticlesScriptReference.worldObject.cachedId && worldObjectGameObject.objectReferenceValue!=null) {
						GameObject woGo = worldObjectGameObject.objectReferenceValue as GameObject;
						PlaygroundParticlesC.NewWorldObject(playgroundParticlesScriptReference, woGo.GetComponent<Transform>() as Transform);
					}
						
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Points:");
					EditorGUILayout.SelectableLabel(playgroundParticlesScriptReference.worldObject.vertexPositions.Length.ToString(), GUILayout.MaxWidth(80));
					
					EditorGUILayout.Separator();
					if(GUILayout.Button("Set Particle Count", EditorStyles.toolbarButton)){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.worldObject.vertexPositions.Length);
						playgroundParticlesScriptReference.Start();
					}
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
						particleCount.intValue = particleCount.intValue+playgroundParticlesScriptReference.worldObject.vertexPositions.Length;
					GUILayout.EndHorizontal();

					GUILayout.BeginVertical(boxStyle);
					EditorGUILayout.LabelField("Procedural Options");
					EditorGUILayout.PropertyField(worldObjectUpdateVertices, new GUIContent(
						"Mesh Vertices Update",
						"Enable this if the World Object's mesh is procedural and changes vertices over time."
					));
					EditorGUILayout.PropertyField(worldObjectUpdateNormals, new GUIContent(
						"Mesh Normals Update",
						"Enable this if the World Object's mesh is procedural and changes normals over time."
					));
					GUILayout.EndVertical();
					
				// Source is Skinned World Object
				} else if (source.intValue == 3) {
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Skinned World Object");
					
					int skinnedWorldObjRefId = skinnedWorldObjectGameObject.objectReferenceInstanceIDValue;
					skinnedWorldObjectGameObject.objectReferenceValue = EditorGUILayout.ObjectField(skinnedWorldObjectGameObject.objectReferenceValue, typeof(GameObject), true);
					GUILayout.EndHorizontal();
					if (skinnedWorldObjRefId!=playgroundParticlesScriptReference.skinnedWorldObject.cachedId && skinnedWorldObjectGameObject.objectReferenceValue!=null) {
						GameObject swoGo = skinnedWorldObjectGameObject.objectReferenceValue as GameObject;
						PlaygroundParticlesC.NewSkinnedWorldObject(playgroundParticlesScriptReference, swoGo.GetComponent<Transform>() as Transform);
					}
					
					if (playgroundParticlesScriptReference.skinnedWorldObject.mesh) {
						int prevDownResolutionSkinned = playgroundParticlesScriptReference.sourceDownResolution;
						playgroundParticlesScriptReference.sourceDownResolution = EditorGUILayout.IntSlider("Source Down Resolution", playgroundParticlesScriptReference.sourceDownResolution, 1, Mathf.RoundToInt (playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/2));
						if (prevDownResolutionSkinned!=playgroundParticlesScriptReference.sourceDownResolution)
							LifetimeSorting();
					}
					
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Points:");
					if (playgroundParticlesScriptReference.sourceDownResolution<=1)
						EditorGUILayout.SelectableLabel(playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length.ToString(), GUILayout.MaxWidth(80));
					else
						EditorGUILayout.SelectableLabel((playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.sourceDownResolution).ToString()+" ("+playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length.ToString()+")", GUILayout.MaxWidth(160));
					
					EditorGUILayout.Separator();
					if(GUILayout.Button("Set Particle Count", EditorStyles.toolbarButton)){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.sourceDownResolution<=1?playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length:playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.sourceDownResolution);
						playgroundParticlesScriptReference.Start();
					}
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
						particleCount.intValue = particleCount.intValue+(playgroundParticlesScriptReference.skinnedWorldObject.vertexPositions.Length/playgroundParticlesScriptReference.sourceDownResolution);
					GUILayout.EndHorizontal();
					
				// Source is Script
				} else if (source.intValue == 4) {
					
					EditorGUILayout.HelpBox("This Particle Playground System is controlled by script. You can only emit particles from script in this source mode using PlaygroundParticlesC.Emit(position, velocity, color, parent). Please see the manual for more details.", MessageType.Info);
					EditorGUILayout.Separator();
					
					EditorGUILayout.BeginVertical(boxStyle);
					EditorGUILayout.BeginHorizontal();
					playgroundParticlesScriptReference.scriptedEmissionIndex = EditorGUILayout.IntField("Emission Index", Mathf.Clamp(playgroundParticlesScriptReference.scriptedEmissionIndex, 0, playgroundParticlesScriptReference.particleCount-1));
					if(GUILayout.Button("►", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)}) || GUILayout.RepeatButton("►►", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(32), GUILayout.Height(16)})) {
						PlaygroundC.Emit(playgroundParticlesScriptReference);
					}
					EditorGUILayout.EndHorizontal();
					
					playgroundParticlesScriptReference.scriptedEmissionPosition = EditorGUILayout.Vector3Field("Position", playgroundParticlesScriptReference.scriptedEmissionPosition);
					playgroundParticlesScriptReference.scriptedEmissionVelocity = EditorGUILayout.Vector3Field("Velocity", playgroundParticlesScriptReference.scriptedEmissionVelocity);
					
					if (playgroundParticlesScriptReference.colorSource == COLORSOURCEC.LifetimeColor) EditorGUILayout.HelpBox("Color is set by Rendering > Lifetime Color.", MessageType.Info);
					GUI.enabled = playgroundParticlesScriptReference.colorSource == COLORSOURCEC.Source;
					playgroundParticlesScriptReference.scriptedEmissionColor = EditorGUILayout.ColorField("Color", playgroundParticlesScriptReference.scriptedEmissionColor);
					GUI.enabled = true;
					playgroundParticlesScriptReference.scriptedEmissionParent = EditorGUILayout.ObjectField("Parent", playgroundParticlesScriptReference.scriptedEmissionParent as Transform, typeof(Transform), true) as Transform;
					
					EditorGUILayout.EndVertical();
					
				// Source is Paint
				} else if (source.intValue == 5) {
					
					if (playgroundParticlesScriptReference.paint==null) {
						PlaygroundC.PaintObject(playgroundParticlesScriptReference);
					}
					
					// Paint Mode
					EditorGUILayout.BeginVertical(boxStyle);
					EditorGUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Paint Mode");
					selectedPaintMode = GUILayout.Toolbar (selectedPaintMode, new string[]{"Dot","Brush","Eraser"}, EditorStyles.toolbarButton);
					EditorGUILayout.EndHorizontal();
					
					// Dot
					if (selectedPaintMode!=0) {
						EditorGUILayout.Separator();
					}
					
					// Brush
					if (selectedPaintMode==1) {
						EditorGUI.indentLevel++;
						EditorGUILayout.BeginVertical(boxStyle);
						brushPresetFoldout = GUILayout.Toggle(brushPresetFoldout, "Brush Presets", EditorStyles.foldout);
						EditorGUI.indentLevel--;
						if (brushPresetFoldout) {
							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.Separator();
							brushListStyle = GUILayout.Toolbar (brushListStyle, new string[]{"Icons","List"}, EditorStyles.toolbarButton, GUILayout.MaxWidth(120));
							EditorGUILayout.EndHorizontal();
							EditorGUILayout.Separator();
							int i;
							
							// Icons
							if (brushListStyle==0) {
								GUILayout.BeginHorizontal();
								for (i = 0; i<brushPresets.Length; i++) {
									EditorGUILayout.BeginVertical(new GUILayoutOption[]{GUILayout.Width(50), GUILayout.Height(62)});
									
									if (GUILayout.Button(brushPresets[i].texture, new GUILayoutOption[]{GUILayout.Width(32), GUILayout.Height(32)})){
										selectedBrushPreset = i;
										SetBrush(i);
									}
									if (brushNames.Length>0) {
										EditorGUILayout.LabelField(brushNames[i], EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[]{GUILayout.Width(50), GUILayout.Height(30)});
									}
									EditorGUILayout.EndVertical();
									if (i%(Screen.width/80)==0 && i>0) {
										EditorGUILayout.EndHorizontal();
										EditorGUILayout.BeginHorizontal();
									}
								}
								EditorGUILayout.EndHorizontal();
								
								
							// List
							} else {
								for (i = 0; i<brushPresets.Length; i++) {
									EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(22));
									EditorGUILayout.BeginHorizontal();
									if (GUILayout.Button(brushNames[i], EditorStyles.label)) {
										selectedBrushPreset = i;
										SetBrush(i);
									}
									EditorGUILayout.Separator();
									if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
										if (EditorUtility.DisplayDialog("Permanently delete this brush?", 
											"The brush "+brushNames[i]+" will be removed, are you sure?", 
											"Yes", 
											"No")) {
												AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(brushPrefabs[i] as UnityEngine.Object));
												LoadBrushes();
											}
									}
									EditorGUILayout.EndHorizontal();
									EditorGUILayout.EndVertical();
								}
							}
							
							// Create new brush
							if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
								PlaygroundCreateBrushWindowC.ShowWindow();
							}
						}
						
						EditorGUILayout.EndVertical();
						EditorGUILayout.Separator();
						
						GUILayout.BeginHorizontal();
						EditorGUILayout.PrefixLabel("Brush Shape");
						paintTexture = EditorGUILayout.ObjectField(paintTexture, typeof(Texture2D), false) as Texture2D;
						GUILayout.EndHorizontal();
						playgroundParticlesScriptReference.paint.brush.detail = (BRUSHDETAILC)EditorGUILayout.EnumPopup("Detail", playgroundParticlesScriptReference.paint.brush.detail);
						playgroundParticlesScriptReference.paint.brush.scale = EditorGUILayout.Slider("Brush Scale", playgroundParticlesScriptReference.paint.brush.scale, playgroundScriptReference.minimumAllowedBrushScale, playgroundScriptReference.maximumAllowedBrushScale);
						playgroundParticlesScriptReference.paint.brush.distance = EditorGUILayout.FloatField("Brush Distance", playgroundParticlesScriptReference.paint.brush.distance);
						
						if (paintTexture!=null && paintTexture!=playgroundParticlesScriptReference.paint.brush.texture) {
							playgroundParticlesScriptReference.paint.brush.SetTexture(paintTexture as Texture2D);
							selectedBrushPreset = -1;
						}
						
						useBrushColor = EditorGUILayout.Toggle("Use Brush Color", useBrushColor);
					}
					
					
					// Eraser
					if (selectedPaintMode==2) {
						eraserRadius = EditorGUILayout.Slider("Eraser Radius", eraserRadius, playgroundScriptReference.minimumEraserRadius, playgroundScriptReference.maximumEraserRadius);
					}
					
					EditorGUILayout.EndVertical();
					EditorGUILayout.Separator();
					
					if (selectedPaintMode==1 && useBrushColor) GUI.enabled = false;
					paintColor = EditorGUILayout.ColorField("Color", paintColor);
					GUI.enabled = true;
					if (showNoAlphaWarning && !useBrushColor) {
						EditorGUILayout.HelpBox("You have no alpha in the color. No particle positions will be painted.", MessageType.Warning);
					}
					showNoAlphaWarning = (paintColor.a == 0);
					
					EditorGUILayout.PropertyField(paintLayerMask, new GUIContent("Paint Mask"));
					playgroundParticlesScriptReference.paint.spacing = EditorGUILayout.Slider("Paint Spacing", playgroundParticlesScriptReference.paint.spacing, .0f, playgroundScriptReference.maximumAllowedPaintSpacing);
					PlaygroundC.reference.paintMaxPositions = EditorGUILayout.IntSlider("Max Paint Positions", PlaygroundC.reference.paintMaxPositions, 0, playgroundScriptReference.maximumAllowedPaintPositions);
					playgroundParticlesScriptReference.paint.exceedMaxStopsPaint = EditorGUILayout.Toggle("Exceed Max Stops Paint", playgroundParticlesScriptReference.paint.exceedMaxStopsPaint);
					if (playgroundParticlesScriptReference.paint.exceedMaxStopsPaint && playgroundParticlesScriptReference.paint.positionLength>=PlaygroundC.reference.paintMaxPositions) {
						EditorGUILayout.HelpBox("You have exceeded max positions. No new paint positions are possible when Exceed Max Stops Paint is enabled.", MessageType.Warning);
					}
					
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel("Paint:");
					ProgressBar((playgroundParticlesScriptReference.paint.positionLength*1f)/PlaygroundC.reference.paintMaxPositions, playgroundParticlesScriptReference.paint.positionLength+"/"+PlaygroundC.reference.paintMaxPositions, Mathf.FloorToInt(Screen.width/2.2f)-65);
					EditorGUILayout.Separator();
					if(GUILayout.Button("Set Particle Count", EditorStyles.toolbarButton)){
						PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.paint.positionLength);
						playgroundParticlesScriptReference.Start();
					}
					if(GUILayout.Button("++", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
						particleCount.intValue = particleCount.intValue+playgroundParticlesScriptReference.paint.positionLength;
					GUILayout.EndHorizontal();
					
					EditorGUILayout.Separator();
					
					GUILayout.BeginHorizontal();
					GUI.enabled = !(selectedPaintMode==1 && paintTexture==null);
					if (GUILayout.Button((inPaintMode?"Stop":"Start")+" Paint ", EditorStyles.toolbarButton, GUILayout.Width(80))){
						StartStopPaint();
					}
					
					GUI.enabled = (playgroundParticlesScriptReference.paint.positionLength>0);
					if(GUILayout.Button("Clear", EditorStyles.toolbarButton, GUILayout.Width(50))){
						ClearPaint();
					}
					GUI.enabled = true;
					GUILayout.EndHorizontal();
					EditorGUILayout.Separator();
					
					if (playgroundParticlesScriptReference.paint.positionLength-1>playgroundParticlesScriptReference.particleCount)
						EditorGUILayout.HelpBox("You have more paint positions than particles. Increase Particle Count to see all painted positions.", MessageType.Warning);
					
					if (GUI.changed) {
						SetBrushStyle();
					}
					
				}
				EditorGUILayout.Separator();
				
			}
			
			// Particle Settings
			if (GUILayout.Button("Particle Settings", EditorStyles.toolbarDropDown)) particleSettingsFoldout=!particleSettingsFoldout;
			if (particleSettingsFoldout) {
				
				EditorGUILayout.Separator();
				
				if (source.intValue==4)
					EditorGUILayout.HelpBox("Some features are inactivated as this Particle Playground System is running in script mode.", MessageType.Info);
				
				GUILayout.BeginHorizontal();
				particleCount.intValue = EditorGUILayout.IntSlider("Particle Count", particleCount.intValue, 0, playgroundScriptReference.maximumAllowedParticles);
				if(GUILayout.Button("x2", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(24), GUILayout.Height(16)}))
					particleCount.intValue *= 2;
				GUILayout.EndHorizontal();
				
				GUI.enabled=(source.intValue!=4);
				emissionRate.floatValue = EditorGUILayout.Slider("Emisson Rate", emissionRate.floatValue, 0, 1f);
				
				EditorGUILayout.Separator();
				EditorGUILayout.PropertyField(overflowMode, new GUIContent(
					"Overflow Mode", 
					"The method to align the Overflow Offset by.")
				);
				if (playgroundParticlesScriptReference.overflowMode!=OVERFLOWMODEC.SourcePoint)
					overflowOffset.vector3Value = EditorGUILayout.Vector3Field("Overflow Offset", overflowOffset.vector3Value);
				else
					playgroundParticlesScriptReference.overflowOffset.z = EditorGUILayout.Slider("Overflow Offset (Z)", playgroundParticlesScriptReference.overflowOffset.z, -100.0f, 100.0f);
				EditorGUILayout.Separator();
				GUI.enabled=true;
				
				// Source Scattering
				GUI.enabled=(source.intValue!=4);
				bool prevScatterEnabled = playgroundParticlesScriptReference.applySourceScatter;
				Vector3 prevScatterMin = playgroundParticlesScriptReference.sourceScatterMin;
				Vector3 prevScatterMax = playgroundParticlesScriptReference.sourceScatterMax;
				playgroundParticlesScriptReference.applySourceScatter = EditorGUILayout.ToggleLeft("Source Scatter", playgroundParticlesScriptReference.applySourceScatter);
				GUI.enabled = (source.intValue!=4 && playgroundParticlesScriptReference.applySourceScatter);
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("X", GUILayout.Width(50));
					EditorGUILayout.Separator();
					float sourceScatterMinX = playgroundParticlesScriptReference.sourceScatterMin.x;
					float sourceScatterMaxX = playgroundParticlesScriptReference.sourceScatterMax.x;
					EditorGUILayout.MinMaxSlider(ref sourceScatterMinX, ref sourceScatterMaxX, -playgroundScriptReference.maximumAllowedSourceScatter, playgroundScriptReference.maximumAllowedSourceScatter, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.sourceScatterMin.x = sourceScatterMinX;
					playgroundParticlesScriptReference.sourceScatterMax.x = sourceScatterMaxX;
					playgroundParticlesScriptReference.sourceScatterMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.sourceScatterMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Y
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Y");
					EditorGUILayout.Separator();
					float sourceScatterMinY = playgroundParticlesScriptReference.sourceScatterMin.y;
					float sourceScatterMaxY = playgroundParticlesScriptReference.sourceScatterMax.y;
					EditorGUILayout.MinMaxSlider(ref sourceScatterMinY, ref sourceScatterMaxY, -playgroundScriptReference.maximumAllowedSourceScatter, playgroundScriptReference.maximumAllowedSourceScatter, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.sourceScatterMin.y = sourceScatterMinY;
					playgroundParticlesScriptReference.sourceScatterMax.y = sourceScatterMaxY;
					playgroundParticlesScriptReference.sourceScatterMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.y, GUILayout.Width(50));
					playgroundParticlesScriptReference.sourceScatterMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.y, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Z
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Z");
					EditorGUILayout.Separator();
					float sourceScatterMinZ = playgroundParticlesScriptReference.sourceScatterMin.z;
					float sourceScatterMaxZ = playgroundParticlesScriptReference.sourceScatterMax.z;
					EditorGUILayout.MinMaxSlider(ref sourceScatterMinZ, ref sourceScatterMaxZ, -playgroundScriptReference.maximumAllowedSourceScatter, playgroundScriptReference.maximumAllowedSourceScatter, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.sourceScatterMin.z = sourceScatterMinZ;
					playgroundParticlesScriptReference.sourceScatterMax.z = sourceScatterMaxZ;
					playgroundParticlesScriptReference.sourceScatterMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMin.z, GUILayout.Width(50));
					playgroundParticlesScriptReference.sourceScatterMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sourceScatterMax.z, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					

				GUI.enabled = true;
				
				if (prevScatterEnabled!=playgroundParticlesScriptReference.applySourceScatter || prevScatterMin!=playgroundParticlesScriptReference.sourceScatterMin || prevScatterMax!=playgroundParticlesScriptReference.sourceScatterMax) {
					LifetimeSorting();
					playgroundParticlesScriptReference.RefreshScatter();
				}
				
				EditorGUILayout.Separator();
				
				// Emission
				bool prevEmit = playgroundParticlesScriptReference.emit;
				bool prevLoop = playgroundParticlesScriptReference.loop;
				playgroundParticlesScriptReference.emit = EditorGUILayout.Toggle("Emit Particles", playgroundParticlesScriptReference.emit);
				playgroundParticlesScriptReference.loop = EditorGUILayout.Toggle("Loop", playgroundParticlesScriptReference.loop);
				if (prevEmit!=playgroundParticlesScriptReference.emit || prevLoop!=playgroundParticlesScriptReference.loop&&playgroundParticlesScriptReference.loop) {
					playgroundParticlesScriptReference.simulationStarted = PlaygroundC.globalTime;
					playgroundParticlesScriptReference.loopExceeded = false;
					playgroundParticlesScriptReference.loopExceededOnParticle = -1;
					playgroundParticlesScriptReference.particleSystemGameObject.SetActive(true);
				}
				GUI.enabled = !loop.boolValue;
				disableOnDone.boolValue = EditorGUILayout.Toggle("Disable On Done", disableOnDone.boolValue);
				GUI.enabled = true;
				calculate.boolValue = EditorGUILayout.Toggle("Calculate Particles", calculate.boolValue);
				
				EditorGUILayout.Separator();
				
				GUILayout.BeginHorizontal();
				GUILayout.Label("Size");
				EditorGUILayout.Separator();
				float sizeMin = playgroundParticlesScriptReference.sizeMin;
				float sizeMax = playgroundParticlesScriptReference.sizeMax;
				EditorGUILayout.MinMaxSlider(ref sizeMin, ref sizeMax, 0, playgroundScriptReference.maximumAllowedSize, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.sizeMin = sizeMin;
				playgroundParticlesScriptReference.sizeMax = sizeMax;
				playgroundParticlesScriptReference.sizeMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sizeMin, GUILayout.Width(50));
				playgroundParticlesScriptReference.sizeMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.sizeMax, GUILayout.Width(50));
				GUILayout.EndHorizontal();

				playgroundParticlesScriptReference.scale = EditorGUILayout.Slider("Scale", playgroundParticlesScriptReference.scale, 0, playgroundScriptReference.maximumAllowedScale);
				
				EditorGUILayout.Separator();
				
				GUILayout.BeginHorizontal();
				GUILayout.Label("Inital Rotation");
				EditorGUILayout.Separator();
				float initialRotationMin = playgroundParticlesScriptReference.initialRotationMin;
				float initialRotationMax = playgroundParticlesScriptReference.initialRotationMax;
				EditorGUILayout.MinMaxSlider(ref initialRotationMin, ref initialRotationMax, -playgroundScriptReference.maximumAllowedRotation, playgroundScriptReference.maximumAllowedRotation, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.initialRotationMin = initialRotationMin;
				playgroundParticlesScriptReference.initialRotationMax = initialRotationMax;
				playgroundParticlesScriptReference.initialRotationMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialRotationMin, GUILayout.Width(50));
				playgroundParticlesScriptReference.initialRotationMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialRotationMax, GUILayout.Width(50));
				GUILayout.EndHorizontal();
				
				GUI.enabled = !playgroundParticlesScriptReference.rotateTowardsDirection;
				GUILayout.BeginHorizontal();
				GUILayout.Label("Rotation");
				EditorGUILayout.Separator();
				float rotationSpeedMin = playgroundParticlesScriptReference.rotationSpeedMin;
				float rotationSpeedMax = playgroundParticlesScriptReference.rotationSpeedMax;
				EditorGUILayout.MinMaxSlider(ref rotationSpeedMin, ref rotationSpeedMax, -playgroundScriptReference.maximumAllowedRotation, playgroundScriptReference.maximumAllowedRotation, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.rotationSpeedMin = rotationSpeedMin;
				playgroundParticlesScriptReference.rotationSpeedMax = rotationSpeedMax;
				playgroundParticlesScriptReference.rotationSpeedMin = EditorGUILayout.FloatField(playgroundParticlesScriptReference.rotationSpeedMin, GUILayout.Width(50));
				playgroundParticlesScriptReference.rotationSpeedMax = EditorGUILayout.FloatField(playgroundParticlesScriptReference.rotationSpeedMax, GUILayout.Width(50));

				GUILayout.EndHorizontal();
				
				GUI.enabled = true;
				
				playgroundParticlesScriptReference.rotateTowardsDirection = EditorGUILayout.Toggle("Rotate Towards Direction", playgroundParticlesScriptReference.rotateTowardsDirection);
				GUI.enabled = playgroundParticlesScriptReference.rotateTowardsDirection;
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.rotationNormal = EditorGUILayout.Vector3Field("Rotation Normal", playgroundParticlesScriptReference.rotationNormal);
					playgroundParticlesScriptReference.rotationNormal.x = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.x, -1, 1);
					playgroundParticlesScriptReference.rotationNormal.y = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.y, -1, 1);
					playgroundParticlesScriptReference.rotationNormal.z = Mathf.Clamp(playgroundParticlesScriptReference.rotationNormal.z, -1, 1);
					EditorGUI.indentLevel--;
				
				GUI.enabled = true;
				
				EditorGUILayout.Separator();
				
				lifetime.floatValue = EditorGUILayout.Slider("Lifetime", lifetime.floatValue, 0, playgroundScriptReference.maximumAllowedLifetime);
				lifetimeSize.animationCurveValue = EditorGUILayout.CurveField("Lifetime Size", lifetimeSize.animationCurveValue);
				
				// Sorting
				GUI.enabled=(source.intValue!=4);
				if (selectedSort!=sorting.intValue || selectedOrigin!=nearestNeighborOrigin.intValue) {
					LifetimeSorting();
				}
				selectedSort = sorting.intValue;
				selectedOrigin = nearestNeighborOrigin.intValue;
				EditorGUILayout.PropertyField(sorting, new GUIContent(
					"Lifetime Sorting", 
					"Determines how the particles are ordered on rebirth.\nScrambled: Randomly placed.\nScrambled Linear: Randomly placed but never at the same time.\nBurst: Alfa and Omega.\nLinear: Alfa to Omega.\nReversed: Omega to Alfa.")
				);
				
				if (sorting.intValue==5||sorting.intValue==6) {
					EditorGUI.indentLevel++;
					nearestNeighborOrigin.intValue = EditorGUILayout.IntSlider("Sort Origin", nearestNeighborOrigin.intValue, 0, playgroundParticlesScriptReference.particleCount);
					EditorGUI.indentLevel--;
				}
				
				// Custom lifetime sorting
				if (sorting.intValue==7) {
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.lifetimeSorting = EditorGUILayout.CurveField("Custom Sorting", playgroundParticlesScriptReference.lifetimeSorting);
					EditorGUI.indentLevel--;
					bool changed = prevLifetimeSortingKeys.Length!=playgroundParticlesScriptReference.lifetimeSorting.keys.Length;
					if (!changed)
						for (int k = 0; k<prevLifetimeSortingKeys.Length; k++) {
							if (playgroundParticlesScriptReference.lifetimeSorting.keys[k].value != prevLifetimeSortingKeys[k].value || playgroundParticlesScriptReference.lifetimeSorting.keys[k].time != prevLifetimeSortingKeys[k].time) {
								changed = true;
							}
						}
					if (changed) {
						LifetimeSorting();
						prevLifetimeSortingKeys = playgroundParticlesScriptReference.lifetimeSorting.keys;
					}
				}
				
				float prevLifetimeOffset = playgroundParticlesScriptReference.lifetimeOffset;
				playgroundParticlesScriptReference.lifetimeOffset = EditorGUILayout.Slider("Lifetime Offset", playgroundParticlesScriptReference.lifetimeOffset, -playgroundParticlesScriptReference.lifetime, playgroundParticlesScriptReference.lifetime);
				if (prevLifetimeOffset!=playgroundParticlesScriptReference.lifetimeOffset) {
					LifetimeSortingAll();
				}
				GUI.enabled = true;
				
				EditorGUILayout.Separator();
			}
						
			// Force Settings
			if (GUILayout.Button("Forces", EditorStyles.toolbarDropDown)) forcesFoldout=!forcesFoldout;
			if (forcesFoldout) {
				
				EditorGUILayout.Separator();
				
				onlySourcePositioning.boolValue = EditorGUILayout.Toggle("Only Source Positions", onlySourcePositioning.boolValue);
				
				EditorGUILayout.Separator();
				
				GUI.enabled = !onlySourcePositioning.boolValue;
				
				// Delta Movement
				if (playgroundParticlesScriptReference.source==SOURCEC.State && playgroundParticlesScriptReference.states!=null && playgroundParticlesScriptReference.states.Count>0 && playgroundParticlesScriptReference.states[playgroundParticlesScriptReference.activeState].stateTransform==null) {
					EditorGUILayout.HelpBox("Assign a transform to the active state to enable Delta Movement.", MessageType.Info);
					GUI.enabled = false;
				} else GUI.enabled = (source.intValue!=4 && !onlySourcePositioning.boolValue);
					playgroundParticlesScriptReference.calculateDeltaMovement = EditorGUILayout.ToggleLeft("Delta Movement", playgroundParticlesScriptReference.calculateDeltaMovement);
				GUI.enabled = (GUI.enabled && playgroundParticlesScriptReference.calculateDeltaMovement && !onlySourcePositioning.boolValue);
					EditorGUI.indentLevel++;
					deltaMovementStrength.floatValue = EditorGUILayout.Slider("Delta Movement Strength", deltaMovementStrength.floatValue, 0, playgroundScriptReference.maximumAllowedDeltaMovementStrength);
					EditorGUI.indentLevel--;
				GUI.enabled = !onlySourcePositioning.boolValue;
				EditorGUILayout.Separator();
				
				// Lifetime velocity
				applyLifetimeVelocity.boolValue = EditorGUILayout.ToggleLeft("Lifetime Velocity", applyLifetimeVelocity.boolValue);
				GUI.enabled = (applyLifetimeVelocity.boolValue&&!onlySourcePositioning.boolValue);
				EditorGUI.indentLevel++;
				lifeTimeVelocityX.animationCurveValue = EditorGUILayout.CurveField("X", lifeTimeVelocityX.animationCurveValue);
				lifeTimeVelocityY.animationCurveValue = EditorGUILayout.CurveField("Y", lifeTimeVelocityY.animationCurveValue);
				lifeTimeVelocityZ.animationCurveValue = EditorGUILayout.CurveField("Z", lifeTimeVelocityZ.animationCurveValue);
				EditorGUI.indentLevel--;
				GUI.enabled = !onlySourcePositioning.boolValue;
				EditorGUILayout.Separator();
				
				// Initial Velocity
				EditorGUILayout.Separator();
				applyInitialVelocity.boolValue = EditorGUILayout.ToggleLeft("Initial Velocity", applyInitialVelocity.boolValue);
				GUI.enabled = (applyInitialVelocity.boolValue&&!onlySourcePositioning.boolValue);
					
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("X", GUILayout.Width(50));
					EditorGUILayout.Separator();
					float initialVelocityMinX = playgroundParticlesScriptReference.initialVelocityMin.x;
					float initialVelocityMaxX = playgroundParticlesScriptReference.initialVelocityMax.x;
					EditorGUILayout.MinMaxSlider(ref initialVelocityMinX, ref initialVelocityMaxX, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialVelocityMin.x = initialVelocityMinX;
					playgroundParticlesScriptReference.initialVelocityMax.x = initialVelocityMaxX;
					playgroundParticlesScriptReference.initialVelocityMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialVelocityMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Y
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Y");
					EditorGUILayout.Separator();
					float initialVelocityMinY = playgroundParticlesScriptReference.initialVelocityMin.y;
					float initialVelocityMaxY = playgroundParticlesScriptReference.initialVelocityMax.y;
					EditorGUILayout.MinMaxSlider(ref initialVelocityMinY, ref initialVelocityMaxY, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialVelocityMin.y = initialVelocityMinY;
					playgroundParticlesScriptReference.initialVelocityMax.y = initialVelocityMaxY;
					playgroundParticlesScriptReference.initialVelocityMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.y, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialVelocityMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.y, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Z
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Z");
					EditorGUILayout.Separator();
					float initialVelocityMinZ = playgroundParticlesScriptReference.initialVelocityMin.z;
					float initialVelocityMaxZ = playgroundParticlesScriptReference.initialVelocityMax.z;
					EditorGUILayout.MinMaxSlider(ref initialVelocityMinZ, ref initialVelocityMaxZ, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialVelocityMin.z = initialVelocityMinZ;
					playgroundParticlesScriptReference.initialVelocityMax.z = initialVelocityMaxZ;
					playgroundParticlesScriptReference.initialVelocityMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMin.z, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialVelocityMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialVelocityMax.z, GUILayout.Width(50));
					GUILayout.EndHorizontal();

				GUI.enabled = !onlySourcePositioning.boolValue;
				
				// Initial Local Velocity
				EditorGUILayout.Separator();
				GUI.enabled=(source.intValue!=4 && !onlySourcePositioning.boolValue);
				
				if (source.intValue==4) {
					GUI.enabled = true;
					EditorGUILayout.HelpBox("Initial Local Velocity is controlled by passed in velocity to Emit() in script mode.", MessageType.Info);
					GUI.enabled = false;
				}
				applyInitialLocalVelocity.boolValue = EditorGUILayout.ToggleLeft("Initial Local Velocity", applyInitialLocalVelocity.boolValue);
				if (playgroundParticlesScriptReference.source==SOURCEC.State && playgroundParticlesScriptReference.states!=null && playgroundParticlesScriptReference.states.Count>0 && playgroundParticlesScriptReference.states[playgroundParticlesScriptReference.activeState].stateTransform==null) {
					EditorGUILayout.HelpBox("Assign a transform to the active state to enable Initial Local Velocity.", MessageType.Info);
					GUI.enabled = false;
				} else GUI.enabled = (applyInitialLocalVelocity.boolValue&&!onlySourcePositioning.boolValue&&source.intValue!=4);
					
					// X
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("X", GUILayout.Width(50));
					EditorGUILayout.Separator();
					float initialLocalVelocityMinX = playgroundParticlesScriptReference.initialLocalVelocityMin.x;
					float initialLocalVelocityMaxX = playgroundParticlesScriptReference.initialLocalVelocityMax.x;
					EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinX, ref initialLocalVelocityMaxX, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialLocalVelocityMin.x = initialLocalVelocityMinX;
					playgroundParticlesScriptReference.initialLocalVelocityMax.x = initialLocalVelocityMaxX;
					playgroundParticlesScriptReference.initialLocalVelocityMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.x, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialLocalVelocityMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.x, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Y
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Y");
					EditorGUILayout.Separator();
					float initialLocalVelocityMinY = playgroundParticlesScriptReference.initialLocalVelocityMin.y;
					float initialLocalVelocityMaxY = playgroundParticlesScriptReference.initialLocalVelocityMax.y;
					EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinY, ref initialLocalVelocityMaxY, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialLocalVelocityMin.y = initialLocalVelocityMinY;
					playgroundParticlesScriptReference.initialLocalVelocityMax.y = initialLocalVelocityMaxY;
					playgroundParticlesScriptReference.initialLocalVelocityMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.y, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialLocalVelocityMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.y, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					// Z
					GUILayout.BeginHorizontal();
					GUILayout.Space(16);
					GUILayout.Label("Z");
					EditorGUILayout.Separator();
					float initialLocalVelocityMinZ = playgroundParticlesScriptReference.initialLocalVelocityMin.z;
					float initialLocalVelocityMaxZ = playgroundParticlesScriptReference.initialLocalVelocityMax.z;
					EditorGUILayout.MinMaxSlider(ref initialLocalVelocityMinZ, ref initialLocalVelocityMaxZ, -playgroundScriptReference.maximumAllowedInitialVelocity, playgroundScriptReference.maximumAllowedInitialVelocity, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
					playgroundParticlesScriptReference.initialLocalVelocityMin.z = initialLocalVelocityMinZ;
					playgroundParticlesScriptReference.initialLocalVelocityMax.z = initialLocalVelocityMaxZ;
					playgroundParticlesScriptReference.initialLocalVelocityMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMin.z, GUILayout.Width(50));
					playgroundParticlesScriptReference.initialLocalVelocityMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.initialLocalVelocityMax.z, GUILayout.Width(50));
					GUILayout.EndHorizontal();
					
				EditorGUILayout.Separator();
				GUI.enabled = !onlySourcePositioning.boolValue;
				
				// Initial velocity shape
				playgroundParticlesScriptReference.applyInitialVelocityShape = EditorGUILayout.ToggleLeft("Initial Velocity Shape", playgroundParticlesScriptReference.applyInitialVelocityShape);
				GUI.enabled = (playgroundParticlesScriptReference.applyInitialVelocityShape&&!onlySourcePositioning.boolValue);
				EditorGUI.indentLevel++;
				initialVelocityShapeX.animationCurveValue = EditorGUILayout.CurveField("X", initialVelocityShapeX.animationCurveValue);
				initialVelocityShapeY.animationCurveValue = EditorGUILayout.CurveField("Y", initialVelocityShapeY.animationCurveValue);
				initialVelocityShapeZ.animationCurveValue = EditorGUILayout.CurveField("Z", initialVelocityShapeZ.animationCurveValue);
				EditorGUI.indentLevel--;
				GUI.enabled = !onlySourcePositioning.boolValue;
				
				// Velocity Bending
				EditorGUILayout.Separator();
				applyVelocityBending.boolValue = EditorGUILayout.ToggleLeft("Velocity Bending", applyVelocityBending.boolValue);
				GUI.enabled = (applyVelocityBending.boolValue&&!onlySourcePositioning.boolValue);
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.velocityBending = EditorGUILayout.Vector3Field("", playgroundParticlesScriptReference.velocityBending);
					EditorGUI.indentLevel--;
				EditorGUILayout.Separator();
				GUI.enabled = !onlySourcePositioning.boolValue;
				
				playgroundParticlesScriptReference.gravity = EditorGUILayout.Vector3Field("Gravity", playgroundParticlesScriptReference.gravity);
				playgroundParticlesScriptReference.damping = EditorGUILayout.Slider("Damping", playgroundParticlesScriptReference.damping, 0f, playgroundScriptReference.maximumAllowedDamping);
				playgroundParticlesScriptReference.maxVelocity = EditorGUILayout.Slider("Max Velocity", playgroundParticlesScriptReference.maxVelocity, 0, playgroundScriptReference.maximumAllowedVelocity);
				
				// Axis constraints
				GUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("Axis Constraints", GUILayout.Width(Mathf.FloorToInt(Screen.width/2.2f)-46));
				
				GUILayout.Label("X", GUILayout.Width(10));
				playgroundParticlesScriptReference.axisConstraints.x = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.x, GUILayout.Width(16));
				GUILayout.Label("Y", GUILayout.Width(10));
				playgroundParticlesScriptReference.axisConstraints.y = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.y, GUILayout.Width(16));
				GUILayout.Label("Z", GUILayout.Width(10));
				playgroundParticlesScriptReference.axisConstraints.z = EditorGUILayout.Toggle(playgroundParticlesScriptReference.axisConstraints.z, GUILayout.Width(16));
				GUILayout.EndHorizontal();
				GUI.enabled = true;
				
				EditorGUILayout.Separator();
		
			}
			
			// Manipulators Settings
			if (GUILayout.Button("Manipulators ("+playgroundParticlesScriptReference.manipulators.Count+")", EditorStyles.toolbarDropDown)) manipulatorsFoldout=!manipulatorsFoldout;
			if (manipulatorsFoldout) {
				
				EditorGUILayout.Separator();
				
				if (playgroundParticlesScriptReference.manipulators.Count>0) {
							
					for (int i = 0; i<playgroundParticlesScriptReference.manipulators.Count; i++) {
						string mName;
						if (playgroundParticlesScriptReference.manipulators[i].transform) {
							mName = playgroundParticlesScriptReference.manipulators[i].transform.name;
							if (mName.Length>24)
								mName = mName.Substring(0, 24)+"...";
						} else mName = "(Missing Transform!)";
						
						EditorGUILayout.BeginVertical("box");
						
						EditorGUILayout.BeginHorizontal();
						
						GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
						manipulatorListFoldout[i] = GUILayout.Toggle(manipulatorListFoldout[i], PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type), EditorStyles.foldout, GUILayout.Width(Screen.width/4));
						if (playgroundParticlesScriptReference.manipulators[i].transform) {
							if (GUILayout.Button(" ("+mName+")", EditorStyles.label)) {
								Selection.activeGameObject = playgroundParticlesScriptReference.manipulators[i].transform.gameObject;
							}
						} else {
							GUILayout.Button(PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type)+" (Missing Transform!)", EditorStyles.label);
						}
						EditorGUILayout.Separator();
						GUI.enabled = (playgroundParticlesScriptReference.manipulators.Count>1);
						if(GUILayout.Button("U", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							manipulators.MoveArrayElement(i, i==0?playgroundParticlesScriptReference.manipulators.Count-1:i-1);
						}
						if(GUILayout.Button("D", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							manipulators.MoveArrayElement(i, i<playgroundParticlesScriptReference.manipulators.Count-1?i+1:0);
						}
						GUI.enabled = true;
						if(GUILayout.Button("+", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							playgroundParticlesScriptReference.manipulators.Add(playgroundParticlesScriptReference.manipulators[i].Clone());
							manipulatorListFoldout.Add(manipulatorListFoldout[i]);
						}
						if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
							
							if (EditorUtility.DisplayDialog(
								"Remove "+PlaygroundInspectorC.ManipulatorTypeName(playgroundParticlesScriptReference.manipulators[i].type)+" Manipulator "+i+"?",
								"Are you sure you want to remove the Manipulator assigned to "+mName+"? (GameObject in Scene will remain intact)", 
								"Yes", "No")) {
									manipulators.DeleteArrayElementAtIndex(i);
									manipulatorListFoldout.RemoveAt(i);
									playgroundParticles.ApplyModifiedProperties();
									return;
								}
						}
						
						EditorGUILayout.EndHorizontal();
						
						if (manipulatorListFoldout[i] && i<manipulators.arraySize) {
							PlaygroundInspectorC.RenderManipulatorSettings(playgroundParticlesScriptReference.manipulators[i], manipulators.GetArrayElementAtIndex(i), false);
						}
						GUI.enabled = true;
						EditorGUILayout.Separator();
						EditorGUILayout.EndVertical();
					}
					
				} else {
					EditorGUILayout.HelpBox("No manipulators created.", MessageType.Info);
				}
				
				if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
					if (Selection.gameObjects.Length>0 && Selection.activeGameObject.transform && Selection.activeTransform!=null)
						PlaygroundC.ManipulatorObject(Selection.activeGameObject.transform, playgroundParticlesScriptReference);
					else
						manipulators.InsertArrayElementAtIndex(manipulators.arraySize);
					manipulatorListFoldout.Add(true);
					SceneView.RepaintAll();
				}
				
				EditorGUILayout.Separator();
			}
			
			// Collision Settings
			if (GUILayout.Button("Collision", EditorStyles.toolbarDropDown)) collisionFoldout=!collisionFoldout;
			if (collisionFoldout) {
			
				EditorGUILayout.Separator();
						
				collision.boolValue = EditorGUILayout.ToggleLeft("Collision", collision.boolValue);
				EditorGUI.indentLevel++;
				GUI.enabled = collision.boolValue;
				EditorGUILayout.PropertyField(collisionMask, new GUIContent("Collision Mask"));
				affectRigidbodies.boolValue = EditorGUILayout.Toggle("Collide With Rigidbodies", affectRigidbodies.boolValue);
				mass.floatValue = EditorGUILayout.Slider("Mass", mass.floatValue, 0, playgroundScriptReference.maximumAllowedMass);
				collisionRadius.floatValue = EditorGUILayout.Slider("Collision Radius", collisionRadius.floatValue, 0, playgroundScriptReference.maximumAllowedCollisionRadius);
				playgroundParticlesScriptReference.lifetimeLoss = EditorGUILayout.Slider("Lifetime Loss", playgroundParticlesScriptReference.lifetimeLoss, 0f, 1f);
				
				EditorGUILayout.Separator();
				bounciness.floatValue = EditorGUILayout.Slider("Bounciness", bounciness.floatValue, 0, playgroundScriptReference.maximumAllowedBounciness);
				EditorGUILayout.PrefixLabel("Random Bounce");
				// X
				GUILayout.BeginHorizontal();
				GUILayout.Space(32);
				GUILayout.Label("X", GUILayout.Width(50));
				EditorGUILayout.Separator();
				float bounceRandomMinX = playgroundParticlesScriptReference.bounceRandomMin.x;
				float bounceRandomMaxX = playgroundParticlesScriptReference.bounceRandomMax.x;
				EditorGUILayout.MinMaxSlider(ref bounceRandomMinX, ref bounceRandomMaxX, -1f, 1f, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.bounceRandomMin.x = bounceRandomMinX;
				playgroundParticlesScriptReference.bounceRandomMax.x = bounceRandomMaxX;
				playgroundParticlesScriptReference.bounceRandomMin.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.x, GUILayout.Width(50));
				playgroundParticlesScriptReference.bounceRandomMax.x = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.x, GUILayout.Width(50));
				GUILayout.EndHorizontal();
				// Y
				GUILayout.BeginHorizontal();
				GUILayout.Space(32);
				GUILayout.Label("Y");
				EditorGUILayout.Separator();
				float bounceRandomMinY = playgroundParticlesScriptReference.bounceRandomMin.y;
				float bounceRandomMaxY = playgroundParticlesScriptReference.bounceRandomMax.y;
				EditorGUILayout.MinMaxSlider(ref bounceRandomMinY, ref bounceRandomMaxY, -1f, 1f, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.bounceRandomMin.y = bounceRandomMinY;
				playgroundParticlesScriptReference.bounceRandomMax.y = bounceRandomMaxY;
				playgroundParticlesScriptReference.bounceRandomMin.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.y, GUILayout.Width(50));
				playgroundParticlesScriptReference.bounceRandomMax.y = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.y, GUILayout.Width(50));
				GUILayout.EndHorizontal();
				// Z
				GUILayout.BeginHorizontal();
				GUILayout.Space(32);
				GUILayout.Label("Z");
				EditorGUILayout.Separator();
				float bounceRandomMinZ = playgroundParticlesScriptReference.bounceRandomMin.z;
				float bounceRandomMaxZ = playgroundParticlesScriptReference.bounceRandomMax.z;
				EditorGUILayout.MinMaxSlider(ref bounceRandomMinZ, ref bounceRandomMaxZ, -1f, 1f, GUILayout.Width(Mathf.FloorToInt(Screen.width/1.8f)-105));
				playgroundParticlesScriptReference.bounceRandomMin.z = bounceRandomMinZ;
				playgroundParticlesScriptReference.bounceRandomMax.z = bounceRandomMaxZ;
				playgroundParticlesScriptReference.bounceRandomMin.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMin.z, GUILayout.Width(50));
				playgroundParticlesScriptReference.bounceRandomMax.z = EditorGUILayout.FloatField(playgroundParticlesScriptReference.bounceRandomMax.z, GUILayout.Width(50));
				GUILayout.EndHorizontal();
				
				EditorGUI.indentLevel--;
				EditorGUILayout.Separator();

				// Collision planes List
				EditorGUILayout.BeginVertical(boxStyle);
				collisionPlanesFoldout = GUILayout.Toggle(collisionPlanesFoldout, "Collision Planes ("+playgroundParticlesScriptReference.colliders.Count+")", EditorStyles.foldout);
				if (collisionPlanesFoldout) {
					if (playgroundParticlesScriptReference.colliders.Count>0) {
						for (int c = 0; c<playgroundParticlesScriptReference.colliders.Count; c++) {
							EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26));
							EditorGUILayout.BeginHorizontal();
							
							playgroundParticlesScriptReference.colliders[c].enabled = EditorGUILayout.Toggle("", playgroundParticlesScriptReference.colliders[c].enabled, GUILayout.Width(16));
							GUI.enabled = (playgroundParticlesScriptReference.colliders[c].enabled&&collision.boolValue);
							playgroundParticlesScriptReference.colliders[c].transform = EditorGUILayout.ObjectField("", playgroundParticlesScriptReference.colliders[c].transform, typeof(Transform), true) as Transform;
							GUI.enabled = collision.boolValue;
							
							EditorGUILayout.Separator();
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								playgroundParticlesScriptReference.colliders.RemoveAt(c);
							}
							
							EditorGUILayout.EndHorizontal();
							EditorGUILayout.EndVertical();
						}
					} else {
						EditorGUILayout.HelpBox("No collision planes created.", MessageType.Info);
					}
					
					if(GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))){
						playgroundParticlesScriptReference.colliders.Add(new PlaygroundColliderC());
					}
					
					EditorGUILayout.Separator();
					playgroundScriptReference.collisionPlaneScale = EditorGUILayout.Slider("Gizmo Scale", playgroundScriptReference.collisionPlaneScale, 0, 1);
					EditorGUILayout.Separator();
				}
				EditorGUILayout.EndVertical();
				
				GUI.enabled = true;
				
				EditorGUILayout.Separator();
			}
			
			// Render Settings
			if (GUILayout.Button("Rendering", EditorStyles.toolbarDropDown)) renderingFoldout=!renderingFoldout;
			if (renderingFoldout) {
				
				EditorGUILayout.Separator();
				
				GUILayout.BeginHorizontal();
				EditorGUILayout.PrefixLabel("Material");
				Material currentMat = particleMaterial as Material;
				particleMaterial = EditorGUILayout.ObjectField(particleMaterial, typeof(Material), false);
				if (currentMat!=particleMaterial) 
					PlaygroundParticlesC.SetMaterial(playgroundParticlesScriptReference, particleMaterial as Material);
				GUILayout.EndHorizontal();
				
				EditorGUILayout.PropertyField(lifetimeColor, new GUIContent("Lifetime Color"));
				
				EditorGUILayout.PropertyField(colorSource, new GUIContent("Color Source"));
				
				playgroundParticlesScriptReference.sourceUsesLifetimeAlpha = EditorGUILayout.Toggle("Source Uses Lifetime Alpha", playgroundParticlesScriptReference.sourceUsesLifetimeAlpha);
				
				EditorGUILayout.Separator();
				
				GUILayout.BeginVertical(boxStyle);
				
				// Render mode
				shurikenRenderer.renderMode = (ParticleSystemRenderMode)EditorGUILayout.EnumPopup("Render Mode", shurikenRenderer.renderMode);
				switch (shurikenRenderer.renderMode) {
					case ParticleSystemRenderMode.Stretch:
						EditorGUI.indentLevel++;
						shurikenRenderer.cameraVelocityScale = EditorGUILayout.Slider("Camera Scale", shurikenRenderer.cameraVelocityScale, -playgroundScriptReference.maximumRenderSliders, playgroundScriptReference.maximumRenderSliders);
						shurikenRenderer.velocityScale = EditorGUILayout.Slider("Speed Scale", shurikenRenderer.velocityScale, -playgroundScriptReference.maximumRenderSliders, playgroundScriptReference.maximumRenderSliders);
						shurikenRenderer.lengthScale = EditorGUILayout.Slider("Length Scale", shurikenRenderer.lengthScale, -playgroundScriptReference.maximumRenderSliders, playgroundScriptReference.maximumRenderSliders);	
						EditorGUI.indentLevel--;
					break;
					case ParticleSystemRenderMode.Mesh:
						shurikenRenderer.mesh = EditorGUILayout.ObjectField(shurikenRenderer.mesh, typeof(Mesh), false) as Mesh;
						GUI.enabled = false;
					break;
				}
				shurikenRenderer.maxParticleSize = EditorGUILayout.Slider("Max Particle Size", shurikenRenderer.maxParticleSize, 0f, 1f);
				GUI.enabled = true;
				
				GUILayout.EndVertical();
				
				// Sort order/layer
				/*
				GUILayout.BeginVertical(boxStyle);
				playgroundParticlesScriptReference.particleSystemRenderer.sortingOrder = EditorGUILayout.IntField("Sorting Order", playgroundParticlesScriptReference.particleSystemRenderer.sortingOrder);
				playgroundParticlesScriptReference.particleSystemRenderer.sortingLayerName = EditorGUILayout.TextField("Sorting Layer Name", playgroundParticlesScriptReference.particleSystemRenderer.sortingLayerName);
				GUILayout.EndVertical();
				*/
				EditorGUILayout.Separator();
			}
			
			// Advanced Settings
			if (GUILayout.Button("Advanced", EditorStyles.toolbarDropDown)) advancedFoldout=!advancedFoldout;
			if (advancedFoldout) {
				
				EditorGUILayout.Separator();
				
				// Update rate
				updateRate.intValue = EditorGUILayout.IntSlider("Update Rate (Frames)", updateRate.intValue, playgroundScriptReference.minimumAllowedUpdateRate, 1);
				
				EditorGUILayout.Separator();
				
				playgroundParticlesScriptReference.particleSystem.simulationSpace = (ParticleSystemSimulationSpace)EditorGUILayout.EnumPopup("Simulation Space", playgroundParticlesScriptReference.particleSystem.simulationSpace);
				/*if (playgroundParticlesScriptReference.particleSystem.simulationSpace==ParticleSystemSimulationSpace.Local) {
					EditorGUI.indentLevel++;
					playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation = EditorGUILayout.Toggle ("Movement Compensation", playgroundParticlesScriptReference.applyLocalSpaceMovementCompensation);
					EditorGUI.indentLevel--;
				}*/

				EditorGUILayout.Separator();
				GUILayout.BeginVertical(boxStyle);
				EditorGUILayout.LabelField("Rebirth Options");
				playgroundParticlesScriptReference.applyRandomSizeOnRebirth = EditorGUILayout.Toggle ("Random Size", playgroundParticlesScriptReference.applyRandomSizeOnRebirth);
				playgroundParticlesScriptReference.applyRandomRotationOnRebirth = EditorGUILayout.Toggle ("Random Rotation", playgroundParticlesScriptReference.applyRandomRotationOnRebirth);
				playgroundParticlesScriptReference.applyRandomScatterOnRebirth = EditorGUILayout.Toggle ("Random Scatter", playgroundParticlesScriptReference.applyRandomScatterOnRebirth);
				GUILayout.EndVertical();
				EditorGUILayout.Separator();

				GUILayout.BeginHorizontal();
				EditorGUILayout.PrefixLabel("Particle Pool");
				
				// Clear
				if(GUILayout.Button("Clear", EditorStyles.toolbarButton, GUILayout.Width(50))){
					PlaygroundParticlesC.Clear(playgroundParticlesScriptReference);
				}
				
				// Rebuild
				if(GUILayout.Button("Rebuild", EditorStyles.toolbarButton, GUILayout.Width(50))){
					PlaygroundParticlesC.SetParticleCount(playgroundParticlesScriptReference, playgroundParticlesScriptReference.particleCount);
					LifetimeSorting();
				}
				GUILayout.EndHorizontal();
				
				EditorGUILayout.Separator();
				
			}

			EditorGUILayout.EndVertical();
			
			if (playgroundParticlesScriptReference.shurikenParticleSystem.isPaused || playgroundParticlesScriptReference.shurikenParticleSystem.isStopped)
				playgroundParticlesScriptReference.shurikenParticleSystem.Play();
			
			previousSource = playgroundParticlesScriptReference.source;
			playgroundParticles.ApplyModifiedProperties();
			
		}
		
		EditorGUILayout.EndVertical();
		
		// Playground Manager - Particle Systems, Manipulators
		PlaygroundInspectorC.RenderPlaygroundSettings();
		
	}