public override void OnEnable() { base.OnEnable(); s_PreviewMovementSpeed = SessionState.GetFloat(k_PreviewMovementSpeed, 0.2f); s_PreviewTimeScale = SessionState.GetFloat(k_PreviewTimeScale, 1.0f); s_PreviewShape = (PreviewShape)SessionState.GetInt(k_PreviewShape, 0); s_PreviewShapeSize = SessionState.GetFloat(k_PreviewShapeSize, 5.0f); m_CurveEditor.OnEnable(serializedObject); s_Inspectors.AddLast(this); SceneView.duringSceneGui += OnSceneViewGUI; EditorApplication.update += RepaintSceneView; ShortcutIntegration.instance.contextManager.RegisterToolContext(m_ShortcutContext); s_PlayEvent = CreateCommandEvent("Play"); s_StopEvent = CreateCommandEvent("Stop"); s_RestartEvent = CreateCommandEvent("Restart"); s_ShowBoundsEvent = CreateCommandEvent("ShowBounds"); m_Time = serializedObject.FindProperty("m_Time"); m_MinVertexDistance = serializedObject.FindProperty("m_MinVertexDistance"); m_Autodestruct = serializedObject.FindProperty("m_Autodestruct"); m_Emitting = serializedObject.FindProperty("m_Emitting"); m_ApplyActiveColorSpace = serializedObject.FindProperty("m_ApplyActiveColorSpace"); m_ColorGradient = serializedObject.FindProperty("m_Parameters.colorGradient"); m_NumCornerVertices = serializedObject.FindProperty("m_Parameters.numCornerVertices"); m_NumCapVertices = serializedObject.FindProperty("m_Parameters.numCapVertices"); m_Alignment = serializedObject.FindProperty("m_Parameters.alignment"); m_TextureMode = serializedObject.FindProperty("m_Parameters.textureMode"); m_TextureScale = serializedObject.FindProperty("m_Parameters.textureScale"); m_ShadowBias = serializedObject.FindProperty("m_Parameters.shadowBias"); m_GenerateLightingData = serializedObject.FindProperty("m_Parameters.generateLightingData"); m_MaskInteraction = serializedObject.FindProperty("m_MaskInteraction"); }
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 void OnEnable() { this.m_TableHeight = SessionState.GetFloat(this.m_SerializationUID + SerializedPropertyTable.s_TableHeight, 200f); }
public void OnEnable() { m_TableHeight = SessionState.GetFloat(m_SerializationUID + s_TableHeight, 200); }
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); }
// 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); }