protected virtual void SetVisibilityState(ModuleUI.VisibilityState newState) { if (newState != this.m_VisibilityState) { if (newState == ModuleUI.VisibilityState.VisibleAndFolded) { ParticleSystemCurveEditor particleSystemCurveEditor = this.m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); foreach (SerializedProperty current in this.m_ModuleCurves) { if (particleSystemCurveEditor.IsAdded(current)) { this.m_CurvesRemovedWhenFolded.Add(current); particleSystemCurveEditor.SetVisible(current, false); } } particleSystemCurveEditor.Refresh(); } else if (newState == ModuleUI.VisibilityState.VisibleAndFoldedOut) { ParticleSystemCurveEditor particleSystemCurveEditor2 = this.m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); foreach (SerializedProperty current2 in this.m_CurvesRemovedWhenFolded) { particleSystemCurveEditor2.SetVisible(current2, true); } this.m_CurvesRemovedWhenFolded.Clear(); particleSystemCurveEditor2.Refresh(); } this.m_VisibilityState = newState; SessionState.SetInt(base.GetUniqueModuleName(), (int)this.m_VisibilityState); if (newState == ModuleUI.VisibilityState.VisibleAndFoldedOut) { this.Init(); } } }
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); }
private AnimationCurveContextMenu(SerializedProperty prop1, SerializedProperty prop2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor owner) { this.m_Prop1 = prop1; this.m_Prop2 = prop2; this.m_Scalar = scalar; this.m_ParticleSystemCurveEditor = owner; this.m_CurveRanges = curveRanges; }
private AnimationCurveContextMenu(SerializedProperty prop1, SerializedProperty prop2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor owner) { m_Prop1 = prop1; m_Prop2 = prop2; m_Scalar = scalar; m_ParticleSystemCurveEditor = owner; m_CurveRanges = curveRanges; }
public void RemoveCurveFromEditor() { ParticleSystemCurveEditor sce = m_Module.GetParticleSystemCurveEditor(); if (sce.IsAdded(GetMinCurve(), maxCurve)) { sce.RemoveCurve(GetMinCurve(), maxCurve); } }
public void RemoveCurveFromEditor() { ParticleSystemCurveEditor particleSystemCurveEditor = this.m_Module.GetParticleSystemCurveEditor(); if (particleSystemCurveEditor.IsAdded(this.GetMinCurve(), this.maxCurve)) { particleSystemCurveEditor.RemoveCurve(this.GetMinCurve(), this.maxCurve); } }
public void SetMinMaxState(MinMaxCurveState newState, bool addToCurveEditor = true) { if (!this.stateHasMultipleDifferentValues) { if (newState == this.state) { return; } } MinMaxCurveState state = this.state; ParticleSystemCurveEditor particleSystemCurveEditor = this.m_Module.GetParticleSystemCurveEditor(); if (particleSystemCurveEditor.IsAdded(this.GetMinCurve(), this.maxCurve)) { particleSystemCurveEditor.RemoveCurve(this.GetMinCurve(), this.maxCurve); } switch (newState) { case MinMaxCurveState.k_Scalar: this.InitSingleScalar(state); break; case MinMaxCurveState.k_Curve: this.InitSingleCurve(state); break; case MinMaxCurveState.k_TwoCurves: this.InitDoubleCurves(state); break; case MinMaxCurveState.k_TwoScalars: this.InitDoubleScalars(state); break; } this.minMaxState.intValue = (int)newState; if (addToCurveEditor) { switch (newState) { case MinMaxCurveState.k_Scalar: case MinMaxCurveState.k_TwoScalars: break; case MinMaxCurveState.k_Curve: case MinMaxCurveState.k_TwoCurves: particleSystemCurveEditor.AddCurve(this.CreateCurveData(particleSystemCurveEditor.GetAvailableColor())); break; default: Debug.LogError("Unhandled enum value"); break; } } AnimationCurvePreviewCache.ClearCache(); }
protected virtual void OnModuleDisable() { ParticleSystemCurveEditor particleSystemCurveEditor = this.m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); foreach (SerializedProperty current in this.m_ModuleCurves) { if (particleSystemCurveEditor.IsAdded(current)) { particleSystemCurveEditor.RemoveCurve(current); } } }
public void ToggleCurveInEditor() { ParticleSystemCurveEditor sce = m_Module.GetParticleSystemCurveEditor(); if (sce.IsAdded(GetMinCurve(), maxCurve)) { sce.RemoveCurve(GetMinCurve(), maxCurve); } else { sce.AddCurve(CreateCurveData(sce.GetAvailableColor())); } }
protected virtual void OnModuleDisable() { Undo.undoRedoPerformed -= UndoRedoPerformed; ParticleSystemCurveEditor psce = m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); foreach (SerializedProperty curveProp in m_ModuleCurves) { if (psce.IsAdded(curveProp)) { psce.RemoveCurve(curveProp); } } }
public void ToggleCurveInEditor() { ParticleSystemCurveEditor particleSystemCurveEditor = this.m_Module.GetParticleSystemCurveEditor(); if (particleSystemCurveEditor.IsAdded(this.GetMinCurve(), this.maxCurve)) { particleSystemCurveEditor.RemoveCurve(this.GetMinCurve(), this.maxCurve); } else { particleSystemCurveEditor.AddCurve(this.CreateCurveData(particleSystemCurveEditor.GetAvailableColor())); } }
public void SetMinMaxState(MinMaxCurveState newState, bool addToCurveEditor) { if (newState == state) { return; } MinMaxCurveState oldState = state; ParticleSystemCurveEditor sce = m_Module.GetParticleSystemCurveEditor(); if (sce.IsAdded(GetMinCurve(), maxCurve)) { sce.RemoveCurve(GetMinCurve(), maxCurve); } switch (newState) { case MinMaxCurveState.k_Curve: SetCurveRequirements(); break; case MinMaxCurveState.k_TwoCurves: SetCurveRequirements(); break; } // Assign state AFTER matching data to new state AND removing curve from curveEditor since it uses current 'state' minMaxState.intValue = (int)newState; if (addToCurveEditor) { // Add curve to CurveEditor if needed // Keep added to the editor if it was added before switch (newState) { case MinMaxCurveState.k_TwoCurves: case MinMaxCurveState.k_Curve: sce.AddCurve(CreateCurveData(sce.GetAvailableColor())); break; case MinMaxCurveState.k_Scalar: case MinMaxCurveState.k_TwoScalars: // Scalar do not add anything to the curve editor break; default: Debug.LogError("Unhandled enum value"); break; } } // Ensure we draw new icons for properties UnityEditorInternal.AnimationCurvePreviewCache.ClearCache(); }
private void SetMinMaxState(MinMaxCurveState newState) { if (newState == this.state) { return; } MinMaxCurveState state = this.state; ParticleSystemCurveEditor systemCurveEditor = this.m_Module.GetParticleSystemCurveEditor(); if (systemCurveEditor.IsAdded(this.GetMinCurve(), this.maxCurve)) { systemCurveEditor.RemoveCurve(this.GetMinCurve(), this.maxCurve); } switch (newState) { case MinMaxCurveState.k_Scalar: this.InitSingleScalar(state); break; case MinMaxCurveState.k_Curve: this.InitSingleCurve(state); break; case MinMaxCurveState.k_TwoCurves: this.InitDoubleCurves(state); break; case MinMaxCurveState.k_TwoScalars: this.InitDoubleScalars(state); break; } this.minMaxState.intValue = (int)newState; switch (newState) { case MinMaxCurveState.k_Scalar: case MinMaxCurveState.k_TwoScalars: AnimationCurvePreviewCache.ClearCache(); break; case MinMaxCurveState.k_Curve: case MinMaxCurveState.k_TwoCurves: systemCurveEditor.AddCurve(this.CreateCurveData(systemCurveEditor.GetAvailableColor())); goto case MinMaxCurveState.k_Scalar; default: Debug.LogError((object)"Unhandled enum value"); goto case MinMaxCurveState.k_Scalar; } }
internal static void Show(Rect position, SerializedProperty property, SerializedProperty property2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor curveEditor) { GUIContent content1 = new GUIContent("Copy"); GUIContent content2 = new GUIContent("Paste"); GenericMenu genericMenu = new GenericMenu(); bool flag1 = property != null && property2 != null; bool flag2 = flag1 && ParticleSystemClipboard.HasDoubleAnimationCurve() || !flag1 && ParticleSystemClipboard.HasSingleAnimationCurve(); AnimationCurveContextMenu curveContextMenu = new AnimationCurveContextMenu(property, property2, scalar, curveRanges, curveEditor); genericMenu.AddItem(content1, false, new GenericMenu.MenuFunction(curveContextMenu.Copy)); if (flag2) genericMenu.AddItem(content2, false, new GenericMenu.MenuFunction(curveContextMenu.Paste)); else genericMenu.AddDisabledItem(content2); genericMenu.DropDown(position); }
protected virtual void OnModuleDisable() { ParticleSystemCurveEditor systemCurveEditor = this.m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); using (List <SerializedProperty> .Enumerator enumerator = this.m_ModuleCurves.GetEnumerator()) { while (enumerator.MoveNext()) { SerializedProperty current = enumerator.Current; if (systemCurveEditor.IsAdded(current)) { systemCurveEditor.RemoveCurve(current); } } } }
public void SetMinMaxState(MinMaxCurveState newState, bool addToCurveEditor) { if (this.stateHasMultipleDifferentValues) { Debug.LogError("SetMinMaxState is not allowed with multiple different values"); } else if (newState != this.state) { MinMaxCurveState state = this.state; ParticleSystemCurveEditor particleSystemCurveEditor = this.m_Module.GetParticleSystemCurveEditor(); if (particleSystemCurveEditor.IsAdded(this.GetMinCurve(), this.maxCurve)) { particleSystemCurveEditor.RemoveCurve(this.GetMinCurve(), this.maxCurve); } if (newState != MinMaxCurveState.k_Curve) { if (newState == MinMaxCurveState.k_TwoCurves) { this.SetCurveRequirements(); } } else { this.SetCurveRequirements(); } this.minMaxState.intValue = (int)newState; if (addToCurveEditor) { switch (newState) { case MinMaxCurveState.k_Scalar: case MinMaxCurveState.k_TwoScalars: break; case MinMaxCurveState.k_Curve: case MinMaxCurveState.k_TwoCurves: particleSystemCurveEditor.AddCurve(this.CreateCurveData(particleSystemCurveEditor.GetAvailableColor())); break; default: Debug.LogError("Unhandled enum value"); break; } } AnimationCurvePreviewCache.ClearCache(); } }
protected virtual void SetVisibilityState(ModuleUI.VisibilityState newState) { if (newState == this.m_VisibilityState) { return; } if (newState == ModuleUI.VisibilityState.VisibleAndFolded) { ParticleSystemCurveEditor systemCurveEditor = this.m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); using (List <SerializedProperty> .Enumerator enumerator = this.m_ModuleCurves.GetEnumerator()) { while (enumerator.MoveNext()) { SerializedProperty current = enumerator.Current; if (systemCurveEditor.IsAdded(current)) { this.m_CurvesRemovedWhenFolded.Add(current); systemCurveEditor.SetVisible(current, false); } } } systemCurveEditor.Refresh(); } else if (newState == ModuleUI.VisibilityState.VisibleAndFoldedOut) { ParticleSystemCurveEditor systemCurveEditor = this.m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); using (List <SerializedProperty> .Enumerator enumerator = this.m_CurvesRemovedWhenFolded.GetEnumerator()) { while (enumerator.MoveNext()) { SerializedProperty current = enumerator.Current; systemCurveEditor.SetVisible(current, true); } } this.m_CurvesRemovedWhenFolded.Clear(); systemCurveEditor.Refresh(); } this.m_VisibilityState = newState; SessionState.SetInt(this.GetUniqueModuleName(), (int)this.m_VisibilityState); if (newState != ModuleUI.VisibilityState.VisibleAndFoldedOut) { return; } this.Init(); }
public static void PasteAnimationCurves(SerializedProperty animCurveProperty, SerializedProperty animCurveProperty2, SerializedProperty scalarProperty, Rect curveRanges, ParticleSystemCurveEditor particleSystemCurveEditor) { if (animCurveProperty != null && ParticleSystemClipboard.m_AnimationCurve1 != null) { animCurveProperty.animationCurveValue = ParticleSystemClipboard.m_AnimationCurve1; ParticleSystemClipboard.ClampCurve(animCurveProperty, curveRanges); } if (animCurveProperty2 != null && ParticleSystemClipboard.m_AnimationCurve2 != null) { animCurveProperty2.animationCurveValue = ParticleSystemClipboard.m_AnimationCurve2; ParticleSystemClipboard.ClampCurve(animCurveProperty2, curveRanges); } if (scalarProperty != null) scalarProperty.floatValue = ParticleSystemClipboard.m_AnimationCurveScalar; if (particleSystemCurveEditor == null) return; particleSystemCurveEditor.Refresh(); }
internal static void Show(Rect position, SerializedProperty property, SerializedProperty property2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor curveEditor) { GUIContent content = new GUIContent("Copy"); GUIContent content2 = new GUIContent("Paste"); GenericMenu menu = new GenericMenu(); bool flag = (property != null) && (property2 != null); bool flag2 = (flag && ParticleSystemClipboard.HasDoubleAnimationCurve()) || (!flag && ParticleSystemClipboard.HasSingleAnimationCurve()); AnimationCurveContextMenu menu2 = new AnimationCurveContextMenu(property, property2, scalar, curveRanges, curveEditor); menu.AddItem(content, false, new GenericMenu.MenuFunction(menu2.Copy)); if (flag2) { menu.AddItem(content2, false, new GenericMenu.MenuFunction(menu2.Paste)); } else { menu.AddDisabledItem(content2); } menu.DropDown(position); }
public void AddCurveDataIfNeeded(string curveName, ParticleSystemCurveEditor.CurveData curveData) { Vector3 vector = SessionState.GetVector3(curveName, Vector3.zero); if (vector != Vector3.zero) { Color color = new Color(vector.x, vector.y, vector.z); curveData.m_Color = color; this.AddCurve(curveData); for (int i = 0; i < this.m_AvailableColors.Count; i++) { if (ParticleSystemCurveEditor.SameColor(this.m_AvailableColors[i], color)) { this.m_AvailableColors.RemoveAt(i); break; } } } }
protected virtual void SetVisibilityState(VisibilityState newState) { if (newState != m_VisibilityState) { if (newState == VisibilityState.VisibleAndFolded) { // Remove curves from the curveeditor when closing modules (and put them back when folding out again) ParticleSystemCurveEditor psce = m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); foreach (SerializedProperty curveProp in m_ModuleCurves) { if (psce.IsAdded(curveProp)) { m_CurvesRemovedWhenFolded.Add(curveProp); psce.SetVisible(curveProp, false); } } psce.Refresh(); } else if (newState == VisibilityState.VisibleAndFoldedOut) { ParticleSystemCurveEditor psce = m_ParticleSystemUI.m_ParticleEffectUI.GetParticleSystemCurveEditor(); foreach (SerializedProperty curveProp in m_CurvesRemovedWhenFolded) { psce.SetVisible(curveProp, true); } m_CurvesRemovedWhenFolded.Clear(); psce.Refresh(); } m_VisibilityState = newState; foreach (Object obj in serializedObject.targetObjects) { SessionState.SetInt(GetUniqueModuleName(obj), (int)m_VisibilityState); } if (newState == VisibilityState.VisibleAndFoldedOut) { Init(); } } }
public void AddCurveDataIfNeeded(string curveName, ParticleSystemCurveEditor.CurveData curveData) { Vector3 vector3 = SessionState.GetVector3(curveName, Vector3.zero); if (!(vector3 != Vector3.zero)) { return; } Color c2 = new Color(vector3.x, vector3.y, vector3.z); curveData.m_Color = c2; this.AddCurve(curveData); for (int index = 0; index < this.m_AvailableColors.Count; ++index) { if (ParticleSystemCurveEditor.SameColor(this.m_AvailableColors[index], c2)) { this.m_AvailableColors.RemoveAt(index); break; } } }
public static void PasteAnimationCurves(SerializedProperty animCurveProperty, SerializedProperty animCurveProperty2, SerializedProperty scalarProperty, Rect curveRanges, ParticleSystemCurveEditor particleSystemCurveEditor) { if ((animCurveProperty != null) && (m_AnimationCurve1 != null)) { animCurveProperty.animationCurveValue = m_AnimationCurve1; ClampCurve(animCurveProperty, curveRanges); } if ((animCurveProperty2 != null) && (m_AnimationCurve2 != null)) { animCurveProperty2.animationCurveValue = m_AnimationCurve2; ClampCurve(animCurveProperty2, curveRanges); } if (scalarProperty != null) { scalarProperty.floatValue = m_AnimationCurveScalar; } if (particleSystemCurveEditor != null) { particleSystemCurveEditor.Refresh(); } }
static internal void Show(Rect position, SerializedProperty property, SerializedProperty property2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor curveEditor) { // Curve context menu GUIContent copy = EditorGUIUtility.TrTextContent("Copy"); GUIContent paste = EditorGUIUtility.TrTextContent("Paste"); GenericMenu menu = new GenericMenu(); bool isRegion = property != null && property2 != null; bool validPaste = (isRegion && ParticleSystemClipboard.HasDoubleAnimationCurve()) || (!isRegion && ParticleSystemClipboard.HasSingleAnimationCurve()); AnimationCurveContextMenu obj = new AnimationCurveContextMenu(property, property2, scalar, curveRanges, curveEditor); menu.AddItem(copy, false, obj.Copy); if (validPaste) { menu.AddItem(paste, false, obj.Paste); } else { menu.AddDisabledItem(paste); } menu.DropDown(position); }
public void AddCurve(ParticleSystemCurveEditor.CurveData curveData) { this.Add(curveData); }
public void AddCurveDataIfNeeded(string curveName, ParticleSystemCurveEditor.CurveData curveData) { Vector3 vector3 = SessionState.GetVector3(curveName, Vector3.zero); if (!(vector3 != Vector3.zero)) return; Color c2 = new Color(vector3.x, vector3.y, vector3.z); curveData.m_Color = c2; this.AddCurve(curveData); for (int index = 0; index < this.m_AvailableColors.Count; ++index) { if (ParticleSystemCurveEditor.SameColor(this.m_AvailableColors[index], c2)) { this.m_AvailableColors.RemoveAt(index); break; } } }
public bool InitializeIfNeeded(ParticleSystem shuriken) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(shuriken); ParticleSystem[] particleSystems = ParticleSystem.GetParticleSystems(root); if (particleSystems == null || particleSystems.Length == 0) { return false; } if (root == this.GetRoot() && this.m_ParticleSystemCurveEditor != null && this.m_Emitters != null && particleSystems.Length == this.m_Emitters.Length) { this.m_SelectedParticleSystem = shuriken; if (this.IsShowOnlySelectedMode()) { this.RefreshShowOnlySelected(); } return false; } 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 && InspectorState.GetBool("ShowSelected" + root.GetInstanceID(), false)); if (this.IsShowOnlySelectedMode()) { this.RefreshShowOnlySelected(); } this.m_EmitterAreaScrollPos.x = InspectorState.GetFloat("CurrentEmitterAreaScroll", 0f); if (this.ShouldManagePlaybackState(root)) { Vector3 vector = InspectorState.GetVector3("SimulationState" + root.GetInstanceID(), Vector3.zero); if (root.GetInstanceID() == (int)vector.x) { float z = vector.z; if (z > 0f) { ParticleSystemEditorUtils.editorPlaybackTime = z; } } this.Play(); } return true; }
public static void PasteAnimationCurves(SerializedProperty animCurveProperty, SerializedProperty animCurveProperty2, SerializedProperty scalarProperty, Rect curveRanges, ParticleSystemCurveEditor particleSystemCurveEditor) { if (animCurveProperty != null && ParticleSystemClipboard.m_AnimationCurve1 != null) { animCurveProperty.animationCurveValue = ParticleSystemClipboard.m_AnimationCurve1; ParticleSystemClipboard.ClampCurve(animCurveProperty, curveRanges); } if (animCurveProperty2 != null && ParticleSystemClipboard.m_AnimationCurve2 != null) { animCurveProperty2.animationCurveValue = ParticleSystemClipboard.m_AnimationCurve2; ParticleSystemClipboard.ClampCurve(animCurveProperty2, curveRanges); } if (scalarProperty != null) { scalarProperty.floatValue = ParticleSystemClipboard.m_AnimationCurveScalar; } if (particleSystemCurveEditor == null) { return; } particleSystemCurveEditor.Refresh(); }
private void Add(ParticleSystemCurveEditor.CurveData cd) { this.m_CurveEditor.SelectNone(); this.m_AddedCurves.Add(cd); this.ContentChanged(); SessionState.SetVector3(cd.m_UniqueName, new Vector3(cd.m_Color.r, cd.m_Color.g, cd.m_Color.b)); this.UpdateRangeBasedOnShownCurves(); }
// 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); }
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); }
internal static void Show(Rect position, SerializedProperty property, SerializedProperty property2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor curveEditor) { GUIContent content = new GUIContent("Copy"); GUIContent content2 = new GUIContent("Paste"); GenericMenu genericMenu = new GenericMenu(); bool flag = property != null && property2 != null; bool flag2 = (flag && ParticleSystemClipboard.HasDoubleAnimationCurve()) || (!flag && ParticleSystemClipboard.HasSingleAnimationCurve()); AnimationCurveContextMenu @object = new AnimationCurveContextMenu(property, property2, scalar, curveRanges, curveEditor); genericMenu.AddItem(content, false, new GenericMenu.MenuFunction(@object.Copy)); if (flag2) { genericMenu.AddItem(content2, false, new GenericMenu.MenuFunction(@object.Paste)); } else { genericMenu.AddDisabledItem(content2); } genericMenu.DropDown(position); }
public void AddCurveDataIfNeeded(string curveName, ParticleSystemCurveEditor.CurveData curveData) { Vector3 vector = InspectorState.GetVector3(curveName, Vector3.zero); if (vector != Vector3.zero) { Color color = new Color(vector.x, vector.y, vector.z); curveData.m_Color = color; this.AddCurve(curveData); for (int i = 0; i < this.m_AvailableColors.Count; i++) { if (ParticleSystemCurveEditor.SameColor(this.m_AvailableColors[i], color)) { this.m_AvailableColors.RemoveAt(i); break; } } } }
public static void PasteAnimationCurves(SerializedProperty animCurveProperty, SerializedProperty animCurveProperty2, SerializedProperty scalarProperty, Rect curveRanges, ParticleSystemCurveEditor particleSystemCurveEditor) { if (animCurveProperty != null && m_AnimationCurve1 != null) { animCurveProperty.animationCurveValue = m_AnimationCurve1; ClampCurve(animCurveProperty, curveRanges); } if (animCurveProperty2 != null && m_AnimationCurve2 != null) { animCurveProperty2.animationCurveValue = m_AnimationCurve2; ClampCurve(animCurveProperty2, curveRanges); } if (scalarProperty != null) { scalarProperty.floatValue = m_AnimationCurveScalar; } // Ensure refresh of systems that uses curves if (particleSystemCurveEditor != null) { particleSystemCurveEditor.Refresh(); } }