public void ApplyProperties() { bool hasModifiedProperties = m_ParticleSystemSerializedObject.hasModifiedProperties; // Check the system was not destroyed such as by an Undo operation. if (m_ParticleSystemSerializedObject.targetObject != null) { m_ParticleSystemSerializedObject.ApplyModifiedProperties(); } if (hasModifiedProperties) { // Resimulate foreach (ParticleSystem ps in m_ParticleSystems) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps); if (!ParticleEffectUI.IsStopped(root) && ParticleSystemEditorUtils.resimulation) { ParticleSystemEditorUtils.PerformCompleteResimulation(); } } // Refresh procedural supported string UpdateParticleSystemInfoString(); } if (m_RendererSerializedObject != null && m_RendererSerializedObject.targetObject != null) { m_RendererSerializedObject.ApplyModifiedProperties(); } }
public void ApplyProperties() { bool hasModifiedProperties = this.m_ParticleSystemSerializedObject.hasModifiedProperties; if (this.m_ParticleSystemSerializedObject.targetObject != null) { this.m_ParticleSystemSerializedObject.ApplyModifiedProperties(); } if (hasModifiedProperties) { ParticleSystem[] particleSystems = this.m_ParticleSystems; for (int i = 0; i < particleSystems.Length; i++) { ParticleSystem ps = particleSystems[i]; ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps); if (!ParticleEffectUI.IsStopped(root) && ParticleSystemEditorUtils.editorResimulation) { ParticleSystemEditorUtils.PerformCompleteResimulation(); } } this.UpdateParticleSystemInfoString(); } if (this.m_RendererSerializedObject != null && this.m_RendererSerializedObject.targetObject != null) { this.m_RendererSerializedObject.ApplyModifiedProperties(); } }
public bool InitializeIfNeeded(ParticleSystem shuriken) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(shuriken); bool result; if (root == null) { result = false; } else { ParticleSystem[] particleSystems = ParticleEffectUI.GetParticleSystems(root); if (root == this.GetRoot()) { if (this.m_ParticleSystemCurveEditor != null && this.m_Emitters != null && particleSystems.Length == this.m_Emitters.Length) { this.m_SelectedParticleSystem = shuriken; if (this.IsShowOnlySelectedMode()) { this.RefreshShowOnlySelected(); } result = false; return(result); } } if (this.m_ParticleSystemCurveEditor != null) { this.Clear(); } this.m_SelectedParticleSystem = shuriken; ParticleSystemEditorUtils.PerformCompleteResimulation(); this.m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); this.m_ParticleSystemCurveEditor.Init(); this.m_EmitterAreaWidth = EditorPrefs.GetFloat("ParticleSystemEmitterAreaWidth", ParticleEffectUI.k_MinEmitterAreaSize.x); this.m_CurveEditorAreaHeight = EditorPrefs.GetFloat("ParticleSystemCurveEditorAreaHeight", ParticleEffectUI.k_MinCurveAreaSize.y); this.InitAllEmitters(particleSystems); this.m_ShowOnlySelectedMode = (this.m_Owner is ParticleSystemWindow && SessionState.GetBool("ShowSelected" + root.GetInstanceID(), false)); if (this.IsShowOnlySelectedMode()) { this.RefreshShowOnlySelected(); } this.m_EmitterAreaScrollPos.x = SessionState.GetFloat("CurrentEmitterAreaScroll", 0f); if (this.ShouldManagePlaybackState(root)) { Vector3 vector = SessionState.GetVector3("SimulationState" + root.GetInstanceID(), Vector3.zero); if (root.GetInstanceID() == (int)vector.x) { float z = vector.z; if (z > 0f) { ParticleSystemEditorUtils.editorPlaybackTime = z; } } this.Play(); } result = true; } return(result); }
public override void OnSceneGUI(ParticleSystem s, InitialModuleUI initial) { Event current = Event.current; EventType rawType = current.type; if ((current.type == EventType.Ignore) && (current.rawType == EventType.MouseUp)) { rawType = current.rawType; } Color color = Handles.color; Color color2 = new Color(1f, 1f, 1f, 0.5f); Handles.color = color2; if (this.m_Type.intValue == 0) { for (int i = 0; i < this.m_ShownPlanes.Length; i++) { UnityEngine.Object objectReferenceValue = this.m_ShownPlanes[i].objectReferenceValue; if (objectReferenceValue != null) { Transform objB = objectReferenceValue as Transform; if (objB != null) { Vector3 position = objB.position; Quaternion rotation = objB.rotation; Vector3 vector2 = (Vector3)(rotation * Vector3.right); Vector3 normal = (Vector3)(rotation * Vector3.up); Vector3 vector4 = (Vector3)(rotation * Vector3.forward); if (object.ReferenceEquals(s_SelectedTransform, objB)) { Tools.s_Hidden = true; EditorGUI.BeginChangeCheck(); if (Tools.current == UnityEditor.Tool.Move) { objB.position = Handles.PositionHandle(position, rotation); } else if (Tools.current == UnityEditor.Tool.Rotate) { objB.rotation = Handles.RotationHandle(rotation, position); } if (EditorGUI.EndChangeCheck()) { if (this.m_PlaneVisualizationType == PlaneVizType.Solid) { GameObject plane = ParticleEffectUtils.GetPlane(i); plane.transform.position = position; plane.transform.rotation = rotation; plane.transform.localScale = new Vector3(this.m_ScaleGrid, this.m_ScaleGrid, this.m_ScaleGrid); } ParticleSystemEditorUtils.PerformCompleteResimulation(); } } else { int keyboardControl = GUIUtility.keyboardControl; float size = HandleUtility.GetHandleSize(position) * 0.06f; if (< > f__mg$cache0 == null) {
private void HandleKeyboardShortcuts(ParticleSystem root) { Event current = Event.current; if (current.type == EventType.KeyDown) { int num = 0; if (current.keyCode == (Event)ParticleEffectUI.kPlay.keyCode) { if (EditorApplication.isPlaying) { this.Stop(); this.Play(); } else if (!ParticleSystemEditorUtils.editorIsPlaying) { this.Play(); } else { this.Pause(); } current.Use(); } else if (current.keyCode == (Event)ParticleEffectUI.kStop.keyCode) { this.Stop(); current.Use(); } else if (current.keyCode == (Event)ParticleEffectUI.kReverse.keyCode) { num = -1; } else if (current.keyCode == (Event)ParticleEffectUI.kForward.keyCode) { num = 1; } if (num != 0) { ParticleSystemEditorUtils.editorIsScrubbing = true; float editorSimulationSpeed = ParticleSystemEditorUtils.editorSimulationSpeed; ParticleSystemEditorUtils.editorPlaybackTime = Mathf.Max(0.0f, ParticleSystemEditorUtils.editorPlaybackTime + (float)((!current.shift ? 1.0 : 3.0) * (double)this.m_TimeHelper.deltaTime * (num <= 0 ? -3.0 : 3.0)) * editorSimulationSpeed); if (root.isStopped) { root.Play(); root.Pause(); } ParticleSystemEditorUtils.PerformCompleteResimulation(); current.Use(); } } if (current.type != EventType.KeyUp || current.keyCode != (Event)ParticleEffectUI.kReverse.keyCode && current.keyCode != (Event)ParticleEffectUI.kForward.keyCode) { return; } ParticleSystemEditorUtils.editorIsScrubbing = false; }
private void HandleKeyboardShortcuts(ParticleSystem root) { Event current = Event.current; if (current.type == EventType.KeyDown) { int num = 0; if (current.keyCode == kPlay.keyCode) { if (EditorApplication.isPlaying) { this.Stop(); this.Play(); } else if (!ParticleSystemEditorUtils.editorIsPlaying) { this.Play(); } else { this.Pause(); } current.Use(); } else if (current.keyCode == kStop.keyCode) { this.Stop(); current.Use(); } else if (current.keyCode == kReverse.keyCode) { num = -1; } else if (current.keyCode == kForward.keyCode) { num = 1; } if (num != 0) { ParticleSystemEditorUtils.editorIsScrubbing = true; float editorSimulationSpeed = ParticleSystemEditorUtils.editorSimulationSpeed; float num3 = ((!current.shift ? 1f : 3f) * this.m_TimeHelper.deltaTime) * ((num <= 0) ? -3f : 3f); ParticleSystemEditorUtils.editorPlaybackTime = Mathf.Max((float)0f, (float)(ParticleSystemEditorUtils.editorPlaybackTime + (num3 * editorSimulationSpeed))); if (root.isStopped) { root.Play(); root.Pause(); } ParticleSystemEditorUtils.PerformCompleteResimulation(); current.Use(); } } if ((current.type == EventType.KeyUp) && ((current.keyCode == kReverse.keyCode) || (current.keyCode == kForward.keyCode))) { ParticleSystemEditorUtils.editorIsScrubbing = false; } }
internal void PlayBackTimeGUI(ParticleSystem root) { if (root == null) { root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem); } EventType type = Event.current.type; int hotControl = GUIUtility.hotControl; string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString; EditorGUI.BeginChangeCheck(); EditorGUI.kFloatFieldFormatString = ParticleEffectUI.s_Texts.secondsFloatFieldFormatString; float num = EditorGUILayout.FloatField(ParticleEffectUI.s_Texts.previewTime, ParticleSystemEditorUtils.editorPlaybackTime, new GUILayoutOption[0]); EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString; if (EditorGUI.EndChangeCheck()) { if (type == EventType.MouseDrag) { ParticleSystemEditorUtils.editorIsScrubbing = true; float editorSimulationSpeed = ParticleSystemEditorUtils.editorSimulationSpeed; float editorPlaybackTime = ParticleSystemEditorUtils.editorPlaybackTime; float num2 = num - editorPlaybackTime; num = editorPlaybackTime + num2 * (0.05f * editorSimulationSpeed); } num = Mathf.Max(num, 0f); ParticleSystemEditorUtils.editorPlaybackTime = num; if (root.isStopped) { root.Play(); root.Pause(); } ParticleSystemEditorUtils.PerformCompleteResimulation(); } if (type == EventType.MouseDown && GUIUtility.hotControl != hotControl) { this.m_IsDraggingTimeHotControlID = GUIUtility.hotControl; ParticleSystemEditorUtils.editorIsScrubbing = true; } if (this.m_IsDraggingTimeHotControlID != -1 && GUIUtility.hotControl != this.m_IsDraggingTimeHotControlID) { this.m_IsDraggingTimeHotControlID = -1; ParticleSystemEditorUtils.editorIsScrubbing = false; } EditorGUILayout.FloatField(ParticleEffectUI.s_Texts.particleCount, (float)this.m_SelectedParticleSystem.particleCount, new GUILayoutOption[0]); int num3 = 0; if (this.m_SelectedParticleSystem.CountSubEmitterParticles(ref num3)) { EditorGUILayout.FloatField(ParticleEffectUI.s_Texts.subEmitterParticleCount, (float)num3, new GUILayoutOption[0]); } }
internal void PlayBackTimeGUI(ParticleSystem root) { if (root == null) { root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem); } EventType type = Event.current.type; int hotControl = GUIUtility.hotControl; string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString; EditorGUI.BeginChangeCheck(); EditorGUI.kFloatFieldFormatString = s_Texts.secondsFloatFieldFormatString; float a = EditorGUILayout.FloatField(s_Texts.previewTime, ParticleSystemEditorUtils.editorPlaybackTime, new GUILayoutOption[0]); EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString; if (EditorGUI.EndChangeCheck()) { if (type == EventType.MouseDrag) { ParticleSystemEditorUtils.editorIsScrubbing = true; float editorSimulationSpeed = ParticleSystemEditorUtils.editorSimulationSpeed; float editorPlaybackTime = ParticleSystemEditorUtils.editorPlaybackTime; float num5 = a - editorPlaybackTime; a = editorPlaybackTime + (num5 * (0.05f * editorSimulationSpeed)); } ParticleSystemEditorUtils.editorPlaybackTime = Mathf.Max(a, 0f); if (root.isStopped) { root.Play(); root.Pause(); } ParticleSystemEditorUtils.PerformCompleteResimulation(); } if ((type == EventType.MouseDown) && (GUIUtility.hotControl != hotControl)) { this.m_IsDraggingTimeHotControlID = GUIUtility.hotControl; ParticleSystemEditorUtils.editorIsScrubbing = true; } if ((this.m_IsDraggingTimeHotControlID != -1) && (GUIUtility.hotControl != this.m_IsDraggingTimeHotControlID)) { this.m_IsDraggingTimeHotControlID = -1; ParticleSystemEditorUtils.editorIsScrubbing = false; } EditorGUILayout.FloatField(s_Texts.particleCount, (float)root.particleCount, new GUILayoutOption[0]); }
public void ApplyProperties() { bool hasModifiedProperties = this.m_ParticleSystemSerializedObject.hasModifiedProperties; this.m_ParticleSystemSerializedObject.ApplyModifiedProperties(); if (hasModifiedProperties) { if (!ParticleEffectUI.IsStopped(ParticleSystemEditorUtils.GetRoot(this.m_ParticleSystem)) && ParticleSystemEditorUtils.editorResimulation) { ParticleSystemEditorUtils.PerformCompleteResimulation(); } this.UpdateParticleSystemInfoString(); } if (this.m_RendererSerializedObject != null) { this.m_RendererSerializedObject.ApplyModifiedProperties(); } }
private void CollisionPlanesSceneGUI() { if (m_ScenePlanes.Count == 0) { return; } Event evt = Event.current; Color origCol = Handles.color; Color col = new Color(1, 1, 1, 0.5F); for (int i = 0; i < m_ScenePlanes.Count; ++i) { if (m_ScenePlanes[i] == null) { continue; } Transform transform = m_ScenePlanes[i]; Vector3 position = transform.position; Quaternion rotation = transform.rotation; Vector3 right = rotation * Vector3.right; Vector3 up = rotation * Vector3.up; Vector3 forward = rotation * Vector3.forward; bool isPlayingAndStatic = EditorApplication.isPlaying && transform.gameObject.isStatic; if (editingPlanes) { if (Object.ReferenceEquals(s_SelectedTransform, transform)) { EditorGUI.BeginChangeCheck(); var newPosition = transform.position; var newRotation = transform.rotation; using (new EditorGUI.DisabledScope(isPlayingAndStatic)) { if (isPlayingAndStatic) { Handles.ShowStaticLabel(position); } if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesMove) { newPosition = Handles.PositionHandle(position, rotation); } else if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesRotate) { newRotation = Handles.RotationHandle(rotation, position); } } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(transform, s_UndoCollisionPlaneString); transform.position = newPosition; transform.rotation = newRotation; ParticleSystemEditorUtils.PerformCompleteResimulation(); } } else { float handleSize = HandleUtility.GetHandleSize(position) * 0.6f; EventType oldEventType = evt.type; // we want ignored mouse up events to check for dragging off of scene view if (evt.type == EventType.Ignore && evt.rawType == EventType.MouseUp) { oldEventType = evt.rawType; } Handles.FreeMoveHandle(position, Quaternion.identity, handleSize, Vector3.zero, Handles.RectangleHandleCap); // Detect selected plane (similar to TreeEditor) if (oldEventType == EventType.MouseDown && evt.type == EventType.Used) { s_SelectedTransform = transform; oldEventType = EventType.Used; GUIUtility.hotControl = 0; // Reset hot control or the FreeMoveHandle will prevent input to the new Handles. (case 873514) } } } Handles.color = col; Color color = Handles.s_ColliderHandleColor * 0.9f; if (isPlayingAndStatic) { color.a *= 0.2f; } if (m_PlaneVisualizationType == PlaneVizType.Grid) { DrawGrid(position, right, forward, up, color); } else { DrawSolidPlane(position, rotation, color, Color.yellow); } } Handles.color = origCol; }
private void CollisionPlanesSceneGUI() { if (this.m_ScenePlanes.Count != 0) { Event current = Event.current; Color color = Handles.color; Color color2 = new Color(1f, 1f, 1f, 0.5f); for (int i = 0; i < this.m_ScenePlanes.Count; i++) { if (!(this.m_ScenePlanes[i] == null)) { Transform transform = this.m_ScenePlanes[i]; Vector3 position = transform.position; Quaternion rotation = transform.rotation; Vector3 axis = rotation * Vector3.right; Vector3 normal = rotation * Vector3.up; Vector3 axis2 = rotation * Vector3.forward; bool flag = EditorApplication.isPlaying && transform.gameObject.isStatic; if (this.editingPlanes) { if (object.ReferenceEquals(CollisionModuleUI.s_SelectedTransform, transform)) { EditorGUI.BeginChangeCheck(); Vector3 position2 = transform.position; Quaternion rotation2 = transform.rotation; using (new EditorGUI.DisabledScope(flag)) { if (flag) { Handles.ShowStaticLabel(position); } if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesMove) { position2 = Handles.PositionHandle(position, rotation); } else if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesRotate) { rotation2 = Handles.RotationHandle(rotation, position); } } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(transform, "Modified Collision Plane Transform"); transform.position = position2; transform.rotation = rotation2; ParticleSystemEditorUtils.PerformCompleteResimulation(); } } else { float num = HandleUtility.GetHandleSize(position) * 0.6f; EventType eventType = current.type; if (current.type == EventType.Ignore && current.rawType == EventType.MouseUp) { eventType = current.rawType; } Vector3 arg_1F3_0 = position; Quaternion arg_1F3_1 = Quaternion.identity; float arg_1F3_2 = num; Vector3 arg_1F3_3 = Vector3.zero; if (CollisionModuleUI.< > f__mg$cache0 == null) { CollisionModuleUI.< > f__mg$cache0 = new Handles.CapFunction(Handles.RectangleHandleCap); } Handles.FreeMoveHandle(arg_1F3_0, arg_1F3_1, arg_1F3_2, arg_1F3_3, CollisionModuleUI.< > f__mg$cache0); if (eventType == EventType.MouseDown && current.type == EventType.Used) { CollisionModuleUI.s_SelectedTransform = transform; GUIUtility.hotControl = 0; } } } Handles.color = color2; Color color3 = Handles.s_ColliderHandleColor * 0.9f; if (flag) { color3.a *= 0.2f; } if (CollisionModuleUI.m_PlaneVisualizationType == CollisionModuleUI.PlaneVizType.Grid) { CollisionModuleUI.DrawGrid(position, axis, axis2, normal, color3); } else { CollisionModuleUI.DrawSolidPlane(position, rotation, color3, Color.yellow); } } } Handles.color = color; } }
private void HandleKeyboardShortcuts() { Event current = Event.current; if (current.type == EventType.KeyDown) { int num = 0; if (current.keyCode == ParticleEffectUI.kPlay.keyCode) { if (EditorApplication.isPlaying) { this.Stop(); this.Play(); } else if (!ParticleSystemEditorUtils.editorIsPlaying) { this.Play(); } else { this.Pause(); } current.Use(); } else if (current.keyCode == ParticleEffectUI.kStop.keyCode) { this.Stop(); current.Use(); } else if (current.keyCode == ParticleEffectUI.kReverse.keyCode) { num = -1; } else if (current.keyCode == ParticleEffectUI.kForward.keyCode) { num = 1; } if (num != 0) { ParticleSystemEditorUtils.editorIsScrubbing = true; float editorSimulationSpeed = ParticleSystemEditorUtils.editorSimulationSpeed; float num2 = ((!current.shift) ? 1f : 3f) * this.m_TimeHelper.deltaTime * ((num <= 0) ? -3f : 3f); ParticleSystemEditorUtils.editorPlaybackTime = Mathf.Max(0f, ParticleSystemEditorUtils.editorPlaybackTime + num2 * editorSimulationSpeed); foreach (ParticleSystem current2 in this.m_SelectedParticleSystems) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(current2); if (root.isStopped) { root.Play(); root.Pause(); } } ParticleSystemEditorUtils.PerformCompleteResimulation(); current.Use(); } } if (current.type == EventType.KeyUp && (current.keyCode == ParticleEffectUI.kReverse.keyCode || current.keyCode == ParticleEffectUI.kForward.keyCode)) { ParticleSystemEditorUtils.editorIsScrubbing = false; } }
internal void PlayBackInfoGUI(bool isPlayMode) { EventType oldEventType = Event.current.type; int oldHotControl = GUIUtility.hotControl; string oldFormat = EditorGUI.kFloatFieldFormatString; EditorGUIUtility.labelWidth = 110.0f; if (!isPlayMode) { EditorGUI.kFloatFieldFormatString = s_Texts.secondsFloatFieldFormatString; if (Time.timeScale == 0.0f) { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.FloatField(s_Texts.previewSpeedDisabled, 0.0f); } } else { ParticleSystemEditorUtils.simulationSpeed = Mathf.Clamp(EditorGUILayout.FloatField(s_Texts.previewSpeed, ParticleSystemEditorUtils.simulationSpeed), 0f, 10f); } EditorGUI.kFloatFieldFormatString = oldFormat; EditorGUI.BeginChangeCheck(); EditorGUI.kFloatFieldFormatString = s_Texts.secondsFloatFieldFormatString; float playbackTime = EditorGUILayout.FloatField(s_Texts.previewTime, ParticleSystemEditorUtils.playbackTime); EditorGUI.kFloatFieldFormatString = oldFormat; if (EditorGUI.EndChangeCheck()) { if (oldEventType == EventType.MouseDrag) { ParticleSystemEditorUtils.playbackIsScrubbing = true; float previewSpeed = ParticleSystemEditorUtils.simulationSpeed; float oldplaybackTime = ParticleSystemEditorUtils.playbackTime; float timeDiff = playbackTime - oldplaybackTime; playbackTime = oldplaybackTime + timeDiff * (0.05F * previewSpeed); } playbackTime = Mathf.Max(playbackTime, 0.0F); ParticleSystemEditorUtils.playbackTime = playbackTime; foreach (ParticleSystem ps in m_SelectedParticleSystems) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps); if (root.isStopped) { root.Play(); root.Pause(); } } ParticleSystemEditorUtils.PerformCompleteResimulation(); } // Detect start dragging if (oldEventType == EventType.MouseDown && GUIUtility.hotControl != oldHotControl) { m_IsDraggingTimeHotControlID = GUIUtility.hotControl; ParticleSystemEditorUtils.playbackIsScrubbing = true; } // Detect stop dragging if (m_IsDraggingTimeHotControlID != -1 && GUIUtility.hotControl != m_IsDraggingTimeHotControlID) { m_IsDraggingTimeHotControlID = -1; ParticleSystemEditorUtils.playbackIsScrubbing = false; } } int particleCount = 0; float fastestParticle = 0.0f; float slowestParticle = Mathf.Infinity; foreach (ParticleSystem ps in m_SelectedParticleSystems) { ps.CalculateEffectUIData(ref particleCount, ref fastestParticle, ref slowestParticle); } EditorGUILayout.LabelField(s_Texts.particleCount, GUIContent.Temp(particleCount.ToString())); bool hasSubEmitters = false; int subEmitterParticles = 0; foreach (ParticleSystem ps in m_SelectedParticleSystems) { int subEmitterParticlesCurrent = 0; if (ps.CalculateEffectUISubEmitterData(ref subEmitterParticlesCurrent, ref fastestParticle, ref slowestParticle)) { hasSubEmitters = true; subEmitterParticles += subEmitterParticlesCurrent; } } if (hasSubEmitters) { EditorGUILayout.LabelField(s_Texts.subEmitterParticleCount, GUIContent.Temp(subEmitterParticles.ToString())); } if (fastestParticle >= slowestParticle) { EditorGUILayout.LabelField(s_Texts.particleSpeeds, GUIContent.Temp(slowestParticle.ToString(s_Texts.speedFloatFieldFormatString) + " - " + fastestParticle.ToString(s_Texts.speedFloatFieldFormatString))); } else { EditorGUILayout.LabelField(s_Texts.particleSpeeds, GUIContent.Temp("0.0 - 0.0")); } if (!EditorApplication.isPlaying) { EditorGUILayout.LayerMaskField(ParticleSystemEditorUtils.previewLayers, s_Texts.previewLayers, SetPreviewLayersDelegate); ParticleSystemEditorUtils.resimulation = GUILayout.Toggle(ParticleSystemEditorUtils.resimulation, s_Texts.resimulation, EditorStyles.toggle); } ParticleEffectUI.m_ShowBounds = GUILayout.Toggle(ParticleEffectUI.m_ShowBounds, ParticleEffectUI.texts.showBounds, EditorStyles.toggle); EditorGUIUtility.labelWidth = 0.0f; }
public override void OnSceneGUI(ParticleSystem s, InitialModuleUI initial) { Event current = Event.current; EventType rawType = current.type; if ((current.type == EventType.Ignore) && (current.rawType == EventType.MouseUp)) { rawType = current.rawType; } Color color = Handles.color; Color color2 = new Color(1f, 1f, 1f, 0.5f); Handles.color = color2; if (this.m_Type.intValue == 0) { for (int i = 0; i < this.m_ShownPlanes.Length; i++) { Object objectReferenceValue = this.m_ShownPlanes[i].objectReferenceValue; if (objectReferenceValue != null) { Transform objB = objectReferenceValue as Transform; if (objB != null) { Vector3 position = objB.position; Quaternion rotation = objB.rotation; Vector3 vector2 = (Vector3)(rotation * Vector3.right); Vector3 normal = (Vector3)(rotation * Vector3.up); Vector3 vector4 = (Vector3)(rotation * Vector3.forward); if (object.ReferenceEquals(m_SelectedTransform, objB)) { Tools.s_Hidden = true; EditorGUI.BeginChangeCheck(); if (Tools.current == Tool.Move) { objB.position = Handles.PositionHandle(position, rotation); } else if (Tools.current == Tool.Rotate) { objB.rotation = Handles.RotationHandle(rotation, position); } if (EditorGUI.EndChangeCheck()) { if (this.m_PlaneVisualizationType == PlaneVizType.Solid) { GameObject plane = ParticleEffectUtils.GetPlane(i); plane.transform.position = position; plane.transform.rotation = rotation; plane.transform.localScale = new Vector3(this.m_ScaleGrid, this.m_ScaleGrid, this.m_ScaleGrid); } ParticleSystemEditorUtils.PerformCompleteResimulation(); } } else { int keyboardControl = GUIUtility.keyboardControl; float size = HandleUtility.GetHandleSize(position) * 0.06f; Handles.FreeMoveHandle(position, Quaternion.identity, size, Vector3.zero, new Handles.DrawCapFunction(Handles.RectangleCap)); if (((rawType == EventType.MouseDown) && (current.type == EventType.Used)) && (keyboardControl != GUIUtility.keyboardControl)) { m_SelectedTransform = objB; rawType = EventType.Used; } } if (this.m_PlaneVisualizationType == PlaneVizType.Grid) { Color color3 = (Color)(Handles.s_ColliderHandleColor * 0.9f); if (!base.enabled) { color3 = new Color(0.7f, 0.7f, 0.7f, 0.7f); } this.DrawGrid(position, vector2, vector4, normal, color3, i); } else { this.DrawSolidPlane(position, rotation, i); } } else { Debug.LogError("Not a transform: " + objectReferenceValue.GetType()); } } } } Handles.color = color; }
public override void OnSceneGUI(ParticleSystem s, InitialModuleUI initial) { Event current = Event.current; EventType eventType = current.type; if (current.type == EventType.Ignore && current.rawType == EventType.MouseUp) { eventType = current.rawType; } Color color = Handles.color; Color color2 = new Color(1f, 1f, 1f, 0.5f); Handles.color = color2; if (this.m_Type.intValue == 0) { for (int i = 0; i < this.m_ShownPlanes.Length; i++) { UnityEngine.Object objectReferenceValue = this.m_ShownPlanes[i].objectReferenceValue; if (objectReferenceValue != null) { Transform transform = objectReferenceValue as Transform; if (transform != null) { Vector3 position = transform.position; Quaternion rotation = transform.rotation; Vector3 axis = rotation * Vector3.right; Vector3 normal = rotation * Vector3.up; Vector3 axis2 = rotation * Vector3.forward; if (object.ReferenceEquals(CollisionModuleUI.s_SelectedTransform, transform)) { Tools.s_Hidden = true; EditorGUI.BeginChangeCheck(); if (Tools.current == Tool.Move) { transform.position = Handles.PositionHandle(position, rotation); } else if (Tools.current == Tool.Rotate) { transform.rotation = Handles.RotationHandle(rotation, position); } if (EditorGUI.EndChangeCheck()) { if (this.m_PlaneVisualizationType == CollisionModuleUI.PlaneVizType.Solid) { GameObject plane = ParticleEffectUtils.GetPlane(i); plane.transform.position = position; plane.transform.rotation = rotation; plane.transform.localScale = new Vector3(this.m_ScaleGrid, this.m_ScaleGrid, this.m_ScaleGrid); } ParticleSystemEditorUtils.PerformCompleteResimulation(); } } else { int keyboardControl = GUIUtility.keyboardControl; float num = HandleUtility.GetHandleSize(position) * 0.06f; Vector3 arg_1EB_0 = position; Quaternion arg_1EB_1 = Quaternion.identity; float arg_1EB_2 = num; Vector3 arg_1EB_3 = Vector3.zero; if (CollisionModuleUI.< > f__mg$cache0 == null) { CollisionModuleUI.< > f__mg$cache0 = new Handles.CapFunction(Handles.RectangleHandleCap); } Handles.FreeMoveHandle(arg_1EB_0, arg_1EB_1, arg_1EB_2, arg_1EB_3, CollisionModuleUI.< > f__mg$cache0); if (eventType == EventType.MouseDown && current.type == EventType.Used && keyboardControl != GUIUtility.keyboardControl) { CollisionModuleUI.s_SelectedTransform = transform; eventType = EventType.Used; } } if (this.m_PlaneVisualizationType == CollisionModuleUI.PlaneVizType.Grid) { Color color3 = Handles.s_ColliderHandleColor * 0.9f; if (!base.enabled) { color3 = new Color(0.7f, 0.7f, 0.7f, 0.7f); } this.DrawGrid(position, axis, axis2, normal, color3, i); } else { this.DrawSolidPlane(position, rotation, i); } } else { Debug.LogError("Not a transform: " + objectReferenceValue.GetType()); } } } } Handles.color = color; }
internal void PlayBackInfoGUI(bool isPlayMode) { EventType type = Event.current.type; int hotControl = GUIUtility.hotControl; string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString; EditorGUIUtility.labelWidth = 110f; if (!isPlayMode) { EditorGUI.kFloatFieldFormatString = ParticleEffectUI.s_Texts.secondsFloatFieldFormatString; if (Time.timeScale == 0f) { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.FloatField(ParticleEffectUI.s_Texts.previewSpeedDisabled, 0f, new GUILayoutOption[0]); } } else { ParticleSystemEditorUtils.simulationSpeed = Mathf.Clamp(EditorGUILayout.FloatField(ParticleEffectUI.s_Texts.previewSpeed, ParticleSystemEditorUtils.simulationSpeed, new GUILayoutOption[0]), 0f, 10f); } EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString; EditorGUI.BeginChangeCheck(); EditorGUI.kFloatFieldFormatString = ParticleEffectUI.s_Texts.secondsFloatFieldFormatString; float num = EditorGUILayout.FloatField(ParticleEffectUI.s_Texts.previewTime, ParticleSystemEditorUtils.playbackTime, new GUILayoutOption[0]); EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString; if (EditorGUI.EndChangeCheck()) { if (type == EventType.MouseDrag) { ParticleSystemEditorUtils.playbackIsScrubbing = true; float simulationSpeed = ParticleSystemEditorUtils.simulationSpeed; float playbackTime = ParticleSystemEditorUtils.playbackTime; float num2 = num - playbackTime; num = playbackTime + num2 * (0.05f * simulationSpeed); } num = Mathf.Max(num, 0f); ParticleSystemEditorUtils.playbackTime = num; foreach (ParticleSystem current in this.m_SelectedParticleSystems) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(current); if (root.isStopped) { root.Play(); root.Pause(); } } ParticleSystemEditorUtils.PerformCompleteResimulation(); } if (type == EventType.MouseDown && GUIUtility.hotControl != hotControl) { this.m_IsDraggingTimeHotControlID = GUIUtility.hotControl; ParticleSystemEditorUtils.playbackIsScrubbing = true; } if (this.m_IsDraggingTimeHotControlID != -1 && GUIUtility.hotControl != this.m_IsDraggingTimeHotControlID) { this.m_IsDraggingTimeHotControlID = -1; ParticleSystemEditorUtils.playbackIsScrubbing = false; } } int num3 = 0; float num4 = 0f; float num5 = float.PositiveInfinity; foreach (ParticleSystem current2 in this.m_SelectedParticleSystems) { current2.CalculateEffectUIData(ref num3, ref num4, ref num5); } EditorGUILayout.LabelField(ParticleEffectUI.s_Texts.particleCount, GUIContent.Temp(num3.ToString()), new GUILayoutOption[0]); bool flag = false; int num6 = 0; foreach (ParticleSystem current3 in this.m_SelectedParticleSystems) { int num7 = 0; if (current3.CalculateEffectUISubEmitterData(ref num7, ref num4, ref num5)) { flag = true; num6 += num7; } } if (flag) { EditorGUILayout.LabelField(ParticleEffectUI.s_Texts.subEmitterParticleCount, GUIContent.Temp(num6.ToString()), new GUILayoutOption[0]); } if (num4 >= num5) { EditorGUILayout.LabelField(ParticleEffectUI.s_Texts.particleSpeeds, GUIContent.Temp(num5.ToString(ParticleEffectUI.s_Texts.speedFloatFieldFormatString) + " - " + num4.ToString(ParticleEffectUI.s_Texts.speedFloatFieldFormatString)), new GUILayoutOption[0]); } else { EditorGUILayout.LabelField(ParticleEffectUI.s_Texts.particleSpeeds, GUIContent.Temp("0.0 - 0.0"), new GUILayoutOption[0]); } if (!EditorApplication.isPlaying) { uint arg_3C2_0 = ParticleSystemEditorUtils.previewLayers; GUIContent arg_3C2_1 = ParticleEffectUI.s_Texts.previewLayers; if (ParticleEffectUI.< > f__mg$cache0 == null) { ParticleEffectUI.< > f__mg$cache0 = new EditorUtility.SelectMenuItemFunction(ParticleEffectUI.SetPreviewLayersDelegate); } EditorGUILayout.LayerMaskField(arg_3C2_0, arg_3C2_1, ParticleEffectUI.< > f__mg$cache0, new GUILayoutOption[0]);
public bool InitializeIfNeeded(IEnumerable <ParticleSystem> systems) { bool flag = false; ParticleSystem[] array = systems.ToArray <ParticleSystem>(); bool flag2 = array.Count <ParticleSystem>() > 1; bool flag3 = false; ParticleSystem particleSystem = null; ParticleSystem[] array2 = array; int i = 0; while (i < array2.Length) { ParticleSystem particleSystem2 = array2[i]; if (flag2) { ParticleSystem[] array3 = new ParticleSystem[] { particleSystem2 }; particleSystem = particleSystem2; goto IL_11F; } ParticleSystem root = ParticleSystemEditorUtils.GetRoot(particleSystem2); if (!(root == null)) { ParticleSystem[] array3 = ParticleEffectUI.GetParticleSystems(root); particleSystem = root; if (this.m_SelectedParticleSystems != null && this.m_SelectedParticleSystems.Count > 0) { if (root == ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystems[0])) { if (this.m_ParticleSystemCurveEditor != null && this.m_Emitters != null && array3.Length == this.m_Emitters.Length && particleSystem2.gameObject.activeInHierarchy == this.m_EmittersActiveInHierarchy) { this.m_SelectedParticleSystems = new List <ParticleSystem>(); this.m_SelectedParticleSystems.Add(particleSystem2); if (this.IsShowOnlySelectedMode()) { this.RefreshShowOnlySelected(); } goto IL_1E6; } } } goto IL_11F; } IL_1E6: i++; continue; IL_11F: if (this.m_ParticleSystemCurveEditor != null) { this.Clear(); } flag3 = true; if (!flag) { this.m_SelectedParticleSystems = new List <ParticleSystem>(); flag = true; } this.m_SelectedParticleSystems.Add(particleSystem2); if (!flag2) { this.m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); this.m_ParticleSystemCurveEditor.Init(); ParticleSystem[] array3; int num = array3.Length; if (num > 0) { this.m_Emitters = new ParticleSystemUI[num]; for (int j = 0; j < num; j++) { this.m_Emitters[j] = new ParticleSystemUI(); this.m_Emitters[j].Init(this, new ParticleSystem[] { array3[j] }); } this.m_EmittersActiveInHierarchy = particleSystem2.gameObject.activeInHierarchy; } } goto IL_1E6; } if (flag3) { if (flag2) { this.m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); this.m_ParticleSystemCurveEditor.Init(); int count = this.m_SelectedParticleSystems.Count; if (count > 0) { this.m_Emitters = new ParticleSystemUI[1]; this.m_Emitters[0] = new ParticleSystemUI(); this.m_Emitters[0].Init(this, this.m_SelectedParticleSystems.ToArray()); this.m_EmittersActiveInHierarchy = this.m_SelectedParticleSystems[0].gameObject.activeInHierarchy; } } ParticleSystemUI[] emitters = this.m_Emitters; for (int k = 0; k < emitters.Length; k++) { ParticleSystemUI particleSystemUI = emitters[k]; ModuleUI[] modules = particleSystemUI.m_Modules; for (int l = 0; l < modules.Length; l++) { ModuleUI moduleUI = modules[l]; if (moduleUI != null) { moduleUI.Validate(); } } } if (ParticleEffectUI.GetAllModulesVisible()) { this.SetAllModulesVisible(true); } this.m_EmitterAreaWidth = EditorPrefs.GetFloat("ParticleSystemEmitterAreaWidth", ParticleEffectUI.k_MinEmitterAreaSize.x); this.m_CurveEditorAreaHeight = EditorPrefs.GetFloat("ParticleSystemCurveEditorAreaHeight", ParticleEffectUI.k_MinCurveAreaSize.y); this.SetShowOnlySelectedMode(this.m_Owner is ParticleSystemWindow && SessionState.GetBool("ShowSelected" + particleSystem.GetInstanceID(), false)); this.m_EmitterAreaScrollPos.x = SessionState.GetFloat("CurrentEmitterAreaScroll", 0f); if (this.ShouldManagePlaybackState(particleSystem)) { Vector3 vector = SessionState.GetVector3("SimulationState" + particleSystem.GetInstanceID(), Vector3.zero); if (particleSystem.GetInstanceID() == (int)vector.x) { float z = vector.z; if (z > 0f) { ParticleSystemEditorUtils.playbackTime = z; ParticleSystemEditorUtils.PerformCompleteResimulation(); } } if (ParticleEffectUI.m_MainPlaybackSystem != particleSystem) { this.Play(); } } } ParticleEffectUI.m_MainPlaybackSystem = particleSystem; return(flag3); }
private void HandleKeyboardShortcuts() { Event evt = Event.current; if (evt.type == EventType.KeyDown) { int changeTime = 0; if (evt.keyCode == ((Event)kPlay).keyCode) { if (EditorApplication.isPlaying) { // If world is playing Pause is not handled, just restart instead Stop(); Play(); } else { // In Edit mode we have full play/pause functionality if (!ParticleSystemEditorUtils.playbackIsPlaying) { Play(); } else { Pause(); } } evt.Use(); } else if (evt.keyCode == ((Event)kStop).keyCode) { Stop(); evt.Use(); } else if (evt.keyCode == ((Event)kReverse).keyCode) { changeTime = -1; } else if (evt.keyCode == ((Event)kForward).keyCode) { changeTime = 1; } if (changeTime != 0) { ParticleSystemEditorUtils.playbackIsScrubbing = true; float previewSpeed = ParticleSystemEditorUtils.simulationSpeed; float timeDiff = (evt.shift ? 3f : 1f) * m_TimeHelper.deltaTime * (changeTime > 0 ? 3f : -3f); ParticleSystemEditorUtils.playbackTime = Mathf.Max(0f, ParticleSystemEditorUtils.playbackTime + timeDiff * (previewSpeed)); foreach (ParticleSystem ps in m_SelectedParticleSystems) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps); if (root.isStopped) { root.Play(); root.Pause(); } } ParticleSystemEditorUtils.PerformCompleteResimulation(); evt.Use(); } } if (evt.type == EventType.KeyUp) { if (evt.keyCode == ((Event)kReverse).keyCode || evt.keyCode == ((Event)kForward).keyCode) { ParticleSystemEditorUtils.playbackIsScrubbing = false; } } }
public override void OnToolGUI(EditorWindow window) { var firstTransform = SyncScenePlanes(); if (m_ScenePlanes.Count == 0) { return; } // Clear invalid selection (ie when selecting other system) if (s_SelectedTransform != null) { if (!m_ScenePlanes.Contains(s_SelectedTransform)) { s_SelectedTransform = null; } } // Always try to select first collider if no selection exists if (s_SelectedTransform == null) { s_SelectedTransform = firstTransform; } Event evt = Event.current; Color origCol = Handles.color; Color col = new Color(1, 1, 1, 0.5F); bool isPlaying = EditorApplication.isPlaying; foreach (var transform in m_ScenePlanes) { Vector3 position = transform.position; Quaternion rotation = transform.rotation; Vector3 right = rotation * Vector3.right; Vector3 up = rotation * Vector3.up; Vector3 forward = rotation * Vector3.forward; bool isPlayingAndStatic = isPlaying && transform.gameObject.isStatic; if (ReferenceEquals(s_SelectedTransform, transform)) { EditorGUI.BeginChangeCheck(); var newPosition = transform.position; var newRotation = transform.rotation; using (new EditorGUI.DisabledScope(isPlayingAndStatic)) { if (isPlayingAndStatic) { Handles.ShowSceneViewLabel(position, Handles.s_StaticLabel); } Handles.TransformHandle(ref newPosition, ref newRotation); } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(transform, s_UndoCollisionPlaneString); transform.position = newPosition; transform.rotation = newRotation; ParticleSystemEditorUtils.PerformCompleteResimulation(); } } else { float handleSize = HandleUtility.GetHandleSize(position) * 0.6f; EventType oldEventType = evt.type; // we want ignored mouse up events to check for dragging off of scene view if (evt.type == EventType.Ignore && evt.rawType == EventType.MouseUp) { oldEventType = evt.rawType; } Handles.FreeMoveHandle(position, handleSize, Vector3.zero, Handles.RectangleHandleCap); // Detect selected plane (similar to TreeEditor) if (oldEventType == EventType.MouseDown && evt.type == EventType.Used) { s_SelectedTransform = transform; oldEventType = EventType.Used; GUIUtility.hotControl = 0; // Reset hot control or the FreeMoveHandle will prevent input to the new Handles. (case 873514) } } Handles.color = col; Color color = Handles.s_ColliderHandleColor * 0.9f; if (isPlayingAndStatic) { color.a *= 0.2f; } if (m_PlaneVisualizationType == PlaneVizType.Grid) { DrawGrid(position, right, forward, up, color); } else { DrawSolidPlane(position, rotation, color, Color.yellow); } } Handles.color = origCol; }
public override void OnSceneGUI(ParticleSystem s, InitialModuleUI initial) { Event current = Event.current; EventType eventType = current.type; if (current.type == EventType.Ignore && current.rawType == EventType.MouseUp) { eventType = current.rawType; } Color color1 = Handles.color; Handles.color = new Color(1f, 1f, 1f, 0.5f); if (this.m_Type.intValue == 0) { for (int index = 0; index < this.m_ShownPlanes.Length; ++index) { Object objectReferenceValue = this.m_ShownPlanes[index].objectReferenceValue; if (objectReferenceValue != (Object)null) { Transform transform = objectReferenceValue as Transform; if ((Object)transform != (Object)null) { Vector3 position = transform.position; Quaternion rotation = transform.rotation; Vector3 axis1 = rotation * Vector3.right; Vector3 normal = rotation * Vector3.up; Vector3 axis2 = rotation * Vector3.forward; if (object.ReferenceEquals((object)CollisionModuleUI.m_SelectedTransform, (object)transform)) { Tools.s_Hidden = true; EditorGUI.BeginChangeCheck(); if (Tools.current == Tool.Move) { transform.position = Handles.PositionHandle(position, rotation); } else if (Tools.current == Tool.Rotate) { transform.rotation = Handles.RotationHandle(rotation, position); } if (EditorGUI.EndChangeCheck()) { if (this.m_PlaneVisualizationType == CollisionModuleUI.PlaneVizType.Solid) { GameObject plane = ParticleEffectUtils.GetPlane(index); plane.transform.position = position; plane.transform.rotation = rotation; plane.transform.localScale = new Vector3(this.m_ScaleGrid, this.m_ScaleGrid, this.m_ScaleGrid); } ParticleSystemEditorUtils.PerformCompleteResimulation(); } } else { int keyboardControl = GUIUtility.keyboardControl; float size = HandleUtility.GetHandleSize(position) * 0.06f; Handles.FreeMoveHandle(position, Quaternion.identity, size, Vector3.zero, new Handles.DrawCapFunction(Handles.RectangleCap)); if (eventType == EventType.MouseDown && current.type == EventType.Used && keyboardControl != GUIUtility.keyboardControl) { CollisionModuleUI.m_SelectedTransform = transform; eventType = EventType.Used; } } if (this.m_PlaneVisualizationType == CollisionModuleUI.PlaneVizType.Grid) { Color color2 = Handles.s_ColliderHandleColor * 0.9f; if (!this.enabled) { color2 = new Color(0.7f, 0.7f, 0.7f, 0.7f); } this.DrawGrid(position, axis1, axis2, normal, color2, index); } else { this.DrawSolidPlane(position, rotation, index); } } else { Debug.LogError((object)("Not a transform: " + (object)objectReferenceValue.GetType())); } } } } Handles.color = color1; }
internal void PlayBackTimeGUI() { EventType type = Event.current.type; int hotControl = GUIUtility.hotControl; string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString; EditorGUIUtility.labelWidth = 110f; EditorGUI.kFloatFieldFormatString = ParticleEffectUI.s_Texts.secondsFloatFieldFormatString; ParticleSystemEditorUtils.editorSimulationSpeed = Mathf.Clamp(EditorGUILayout.FloatField(ParticleEffectUI.s_Texts.previewSpeed, ParticleSystemEditorUtils.editorSimulationSpeed, new GUILayoutOption[0]), 0f, 10f); EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString; EditorGUI.BeginChangeCheck(); EditorGUI.kFloatFieldFormatString = ParticleEffectUI.s_Texts.secondsFloatFieldFormatString; float num = EditorGUILayout.FloatField(ParticleEffectUI.s_Texts.previewTime, ParticleSystemEditorUtils.editorPlaybackTime, new GUILayoutOption[0]); EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString; if (EditorGUI.EndChangeCheck()) { if (type == EventType.MouseDrag) { ParticleSystemEditorUtils.editorIsScrubbing = true; float editorSimulationSpeed = ParticleSystemEditorUtils.editorSimulationSpeed; float editorPlaybackTime = ParticleSystemEditorUtils.editorPlaybackTime; float num2 = num - editorPlaybackTime; num = editorPlaybackTime + num2 * (0.05f * editorSimulationSpeed); } num = Mathf.Max(num, 0f); ParticleSystemEditorUtils.editorPlaybackTime = num; foreach (ParticleSystem current in this.m_SelectedParticleSystems) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(current); if (root.isStopped) { root.Play(); root.Pause(); } } ParticleSystemEditorUtils.PerformCompleteResimulation(); } if (type == EventType.MouseDown && GUIUtility.hotControl != hotControl) { this.m_IsDraggingTimeHotControlID = GUIUtility.hotControl; ParticleSystemEditorUtils.editorIsScrubbing = true; } if (this.m_IsDraggingTimeHotControlID != -1 && GUIUtility.hotControl != this.m_IsDraggingTimeHotControlID) { this.m_IsDraggingTimeHotControlID = -1; ParticleSystemEditorUtils.editorIsScrubbing = false; } int num3 = 0; float num4 = 0f; float num5 = float.PositiveInfinity; foreach (ParticleSystem current2 in this.m_SelectedParticleSystems) { current2.CalculateEffectUIData(ref num3, ref num4, ref num5); } EditorGUILayout.LabelField(ParticleEffectUI.s_Texts.particleCount, GUIContent.Temp(num3.ToString()), new GUILayoutOption[0]); bool flag = false; int num6 = 0; foreach (ParticleSystem current3 in this.m_SelectedParticleSystems) { int num7 = 0; if (current3.CalculateEffectUISubEmitterData(ref num7, ref num4, ref num5)) { flag = true; num6 += num7; } } if (flag) { EditorGUILayout.LabelField(ParticleEffectUI.s_Texts.subEmitterParticleCount, GUIContent.Temp(num6.ToString()), new GUILayoutOption[0]); } if (num4 >= num5) { EditorGUILayout.LabelField(ParticleEffectUI.s_Texts.particleSpeeds, GUIContent.Temp(num5.ToString(ParticleEffectUI.s_Texts.speedFloatFieldFormatString) + " - " + num4.ToString(ParticleEffectUI.s_Texts.speedFloatFieldFormatString)), new GUILayoutOption[0]); } else { EditorGUILayout.LabelField(ParticleEffectUI.s_Texts.particleSpeeds, GUIContent.Temp("0.0 - 0.0"), new GUILayoutOption[0]); } EditorGUIUtility.labelWidth = 0f; }
// Should be called often to ensure we catch if selected Particle System is dragged in/out of root hierarchy public bool InitializeIfNeeded(IEnumerable <ParticleSystem> systems) { bool anyAdded = false; ParticleSystem[] allSystems = systems.ToArray(); bool usingMultiEdit = (allSystems.Count() > 1); bool initializeRequired = false; ParticleSystem mainSystem = null; foreach (ParticleSystem shuriken in allSystems) { ParticleSystem[] shurikens; if (!usingMultiEdit) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(shuriken); if (root == null) { continue; } shurikens = GetParticleSystems(root); mainSystem = root; // Check if we need to re-initialize? if (m_SelectedParticleSystems != null && m_SelectedParticleSystems.Count > 0) { if (root == ParticleSystemEditorUtils.GetRoot(m_SelectedParticleSystems[0])) { if (m_ParticleSystemCurveEditor != null && m_Emitters != null && shurikens.Length == m_Emitters.Length && shuriken.gameObject.activeInHierarchy == m_EmittersActiveInHierarchy) { m_SelectedParticleSystems = new List <ParticleSystem>(); m_SelectedParticleSystems.Add(shuriken); if (IsShowOnlySelectedMode()) { RefreshShowOnlySelected(); // always refresh } continue; } } } } else { // in multi-edit mode, we explicitly choose the systems to edit, so don't automatically add child systems or search for the root shurikens = new ParticleSystem[] { shuriken }; mainSystem = shuriken; } // Cleanup before initializing if (m_ParticleSystemCurveEditor != null) { Clear(); } // Now initialize initializeRequired = true; if (!anyAdded) { m_SelectedParticleSystems = new List <ParticleSystem>(); anyAdded = true; } m_SelectedParticleSystems.Add(shuriken); // Single edit emitter setup if (!usingMultiEdit) { // Init CurveEditor before modules (they may add curves during construction) m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); m_ParticleSystemCurveEditor.Init(); int numEmitters = shurikens.Length; if (numEmitters > 0) { m_Emitters = new ParticleSystemUI[numEmitters]; for (int i = 0; i < numEmitters; ++i) { m_Emitters[i] = new ParticleSystemUI(); m_Emitters[i].Init(this, new ParticleSystem[] { shurikens[i] }); } m_EmittersActiveInHierarchy = shuriken.gameObject.activeInHierarchy; } } } if (initializeRequired) { // Multi-edit emitter setup if (usingMultiEdit) { // Init CurveEditor before modules (they may add curves during construction) m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); m_ParticleSystemCurveEditor.Init(); int numEmitters = m_SelectedParticleSystems.Count; if (numEmitters > 0) { m_Emitters = new ParticleSystemUI[1]; m_Emitters[0] = new ParticleSystemUI(); m_Emitters[0].Init(this, m_SelectedParticleSystems.ToArray()); m_EmittersActiveInHierarchy = m_SelectedParticleSystems[0].gameObject.activeInHierarchy; } } // Allow modules to validate their state (the user can have moved emitters around in the hierarchy) foreach (ParticleSystemUI e in m_Emitters) { foreach (ModuleUI m in e.m_Modules) { if (m != null) { m.Validate(); } } } // Sync to state if (GetAllModulesVisible()) { SetAllModulesVisible(true); } m_EmitterAreaWidth = EditorPrefs.GetFloat("ParticleSystemEmitterAreaWidth", k_MinEmitterAreaSize.x); m_CurveEditorAreaHeight = EditorPrefs.GetFloat("ParticleSystemCurveEditorAreaHeight", k_MinCurveAreaSize.y); // For now only allow ShowOnlySelectedMode for ParticleSystemWindow SetShowOnlySelectedMode((m_Owner is ParticleSystemWindow) ? SessionState.GetBool(k_ShowSelectedId + mainSystem.GetInstanceID(), false) : false); m_EmitterAreaScrollPos.x = SessionState.GetFloat("CurrentEmitterAreaScroll", 0.0f); if (ShouldManagePlaybackState(mainSystem)) { // Restore lastPlayBackTime if available in session cache Vector3 simulationState = SessionState.GetVector3(k_SimulationStateId + mainSystem.GetInstanceID(), Vector3.zero); if (mainSystem.GetInstanceID() == (int)simulationState.x) { float lastPlayBackTime = simulationState.z; if (lastPlayBackTime > 0f) { ParticleSystemEditorUtils.playbackTime = lastPlayBackTime; ParticleSystemEditorUtils.PerformCompleteResimulation(); } } // Play when selecting a new particle effect if (m_MainPlaybackSystem != mainSystem) { Play(); } } } m_MainPlaybackSystem = mainSystem; return(initializeRequired); }