GetRoot() public static method

public static GetRoot ( ParticleSystem ps ) : ParticleSystem
ps UnityEngine.ParticleSystem
return UnityEngine.ParticleSystem
示例#1
0
        private void MultiParticleSystemGUI(bool verticalLayout)
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem);

            GUILayout.BeginVertical(ParticleSystemStyles.Get().effectBgStyle, new GUILayoutOption[0]);
            this.m_EmitterAreaScrollPos = EditorGUILayout.BeginScrollView(this.m_EmitterAreaScrollPos, new GUILayoutOption[0]);
            Rect position = EditorGUILayout.BeginVertical(new GUILayoutOption[0]);

            this.m_EmitterAreaScrollPos -= EditorGUI.MouseDeltaReader(position, Event.current.alt);
            GUILayout.Space(3f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(3f);
            Color color = GUI.color;
            bool  flag  = Event.current.type == EventType.Repaint;
            bool  flag2 = this.IsShowOnlySelectedMode();
            List <ParticleSystemUI> selectedParticleSystemUIs = this.GetSelectedParticleSystemUIs();

            for (int i = 0; i < this.m_Emitters.Length; i++)
            {
                if (i != 0)
                {
                    GUILayout.Space(ModuleUI.k_SpaceBetweenModules);
                }
                bool     flag3 = selectedParticleSystemUIs.Contains(this.m_Emitters[i]);
                ModuleUI particleSystemRendererModuleUI = this.m_Emitters[i].GetParticleSystemRendererModuleUI();
                if ((flag && (particleSystemRendererModuleUI != null)) && !particleSystemRendererModuleUI.enabled)
                {
                    GUI.color = GetDisabledColor();
                }
                if ((flag && flag2) && !flag3)
                {
                    GUI.color = GetDisabledColor();
                }
                Rect rect = EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
                if ((flag && flag3) && (this.m_Emitters.Length > 1))
                {
                    this.DrawSelectionMarker(rect);
                }
                this.m_Emitters[i].OnGUI(root, ModuleUI.k_CompactFixedModuleWidth, true);
                EditorGUILayout.EndVertical();
                GUI.color = color;
            }
            GUILayout.Space(5f);
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(20f) };
            if (GUILayout.Button(s_Texts.addParticleSystem, "OL Plus", options))
            {
                this.CreateParticleSystem(root, SubModuleUI.SubEmitterType.None);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(4f);
            this.m_EmitterAreaScrollPos -= EditorGUI.MouseDeltaReader(position, true);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
            GUILayout.EndVertical();
            this.HandleKeyboardShortcuts(root);
        }
示例#2
0
		internal static bool IsChild(ParticleSystem subEmitter, ParticleSystem root)
		{
			if (subEmitter == null || root == null)
			{
				return false;
			}
			ParticleSystem root2 = ParticleSystemEditorUtils.GetRoot(subEmitter);
			return root2 == root;
		}
示例#3
0
        internal void PlayStopGUI()
        {
            if (ParticleEffectUI.s_Texts == null)
            {
                ParticleEffectUI.s_Texts = new ParticleEffectUI.Texts();
            }
            ParticleSystem root    = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem);
            Event          current = Event.current;

            if (current.type == EventType.Layout)
            {
                this.m_TimeHelper.Update();
            }
            if (!EditorApplication.isPlaying)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                bool flag = ParticleSystemEditorUtils.editorIsPlaying && !ParticleSystemEditorUtils.editorIsPaused;
                if (GUILayout.Button((!flag) ? ParticleEffectUI.s_Texts.play : ParticleEffectUI.s_Texts.pause, "ButtonLeft", new GUILayoutOption[0]))
                {
                    if (flag)
                    {
                        this.Pause();
                    }
                    else
                    {
                        this.Play();
                    }
                }
                if (GUILayout.Button(ParticleEffectUI.s_Texts.stop, "ButtonRight", new GUILayoutOption[0]))
                {
                    this.Stop();
                }
                GUILayout.EndHorizontal();
                string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;
                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;
                this.PlayBackTimeGUI(root);
            }
            else
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                if (GUILayout.Button(ParticleEffectUI.s_Texts.play, new GUILayoutOption[0]))
                {
                    this.Stop();
                    this.Play();
                }
                if (GUILayout.Button(ParticleEffectUI.s_Texts.stop, new GUILayoutOption[0]))
                {
                    this.Stop();
                }
                GUILayout.EndHorizontal();
            }
            this.HandleKeyboardShortcuts(root);
        }
        internal void Play()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem);

            if (root != null)
            {
                root.Play();
                ParticleSystemEditorUtils.editorIsScrubbing = false;
                this.m_Owner.Repaint();
            }
        }
示例#5
0
        internal void Pause()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem);

            if (root)
            {
                root.Pause();
                ParticleSystemEditorUtils.editorIsScrubbing = true;
                this.m_Owner.Repaint();
            }
        }
        internal void Pause()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem);

            if (!(bool)((UnityEngine.Object)root))
            {
                return;
            }
            root.Pause();
            ParticleSystemEditorUtils.editorIsScrubbing = true;
            this.m_Owner.Repaint();
        }
示例#7
0
        private bool CheckIfChild(Object subEmitter)
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(m_ParticleSystemUI.m_ParticleSystems[0]);
            ParticleSystem ps   = subEmitter as ParticleSystem;

            if (IsChild(ps, root))
            {
                return(true);
            }

            if (PrefabUtility.IsPartOfAnyPrefab(ps.gameObject) && !PrefabUtility.IsAnyPrefabInstanceRoot(ps.gameObject))
            {
                string kPrefabReparentWarn = $"The assigned sub emitter is not part of the current effect because it is not a child of the current root Particle System GameObject: '{root.gameObject.name}'. The Particle System cannot be moved because it is a child of a Prefab instance.";
                EditorUtility.WarnPrefab(ps.gameObject, "Reparent GameObjects", kPrefabReparentWarn, "OK");
                return(false);
            }

            string kReparentText = string.Format("The assigned sub emitter is not a child of the current root particle system GameObject: '{0}' and is therefore NOT considered a part of the current effect. Do you want to reparent it?", root.gameObject.name);

            if (EditorUtility.DisplayDialog(
                    "Reparent GameObjects",
                    kReparentText,
                    "Yes, Reparent",
                    "No, Remove"))
            {
                if (EditorUtility.IsPersistent(subEmitter))
                {
                    var newGo = Object.Instantiate(subEmitter) as GameObject;
                    if (newGo != null)
                    {
                        newGo.transform.parent        = m_ParticleSystemUI.m_ParticleSystems[0].transform;
                        newGo.transform.localPosition = Vector3.zero;
                        newGo.transform.localRotation = Quaternion.identity;
                    }
                }
                else
                {
                    if (ps != null)
                    {
                        Undo.SetTransformParent(ps.gameObject.transform.transform, m_ParticleSystemUI.m_ParticleSystems[0].transform, "Reparent sub emitter");
                    }
                }

                return(true);
            }
            else if (ps != null)
            {
                // Clear sub-emitters that have been deselected, to avoid having their particles left paused in the Scene View (case 946999)
                ps.Clear(true);
            }

            return(false);
        }
示例#8
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 = 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]);
            }
        }
示例#9
0
        public void OnSceneViewGUI()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(m_SelectedParticleSystems[0]);

            if (root && root.gameObject.activeInHierarchy)
            {
                SceneViewOverlay.Window(ParticleSystemInspector.playBackTitle, SceneViewGUICallback, (int)SceneViewOverlay.Ordering.ParticleEffect, SceneViewOverlay.WindowDisplayOption.OneWindowPerTitle);
            }

            foreach (ParticleSystemUI e in m_Emitters)
            {
                e.OnSceneViewGUI();
            }
        }
示例#10
0
        public bool InitializeIfNeeded(ParticleSystem shuriken)
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(shuriken);

            if (root == null)
            {
                return(false);
            }
            ParticleSystem[] particleSystems = GetParticleSystems(root);
            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", k_MinEmitterAreaSize.x);
            this.m_CurveEditorAreaHeight = EditorPrefs.GetFloat("ParticleSystemCurveEditorAreaHeight", 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();
            }
            return(true);
        }
示例#11
0
        public void OnSceneViewGUI()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystems[0]);

            if (root && root.gameObject.activeInHierarchy)
            {
                SceneViewOverlay.Window(ParticleSystemInspector.playBackTitle, new SceneViewOverlay.WindowFunction(this.SceneViewGUICallback), 600, SceneViewOverlay.WindowDisplayOption.OneWindowPerTitle);
            }
            ParticleSystemUI[] emitters = this.m_Emitters;
            for (int i = 0; i < emitters.Length; i++)
            {
                ParticleSystemUI particleSystemUI = emitters[i];
                particleSystemUI.OnSceneViewGUI();
            }
        }
示例#12
0
        internal static bool IsChild(ParticleSystem subEmitter, ParticleSystem root)
        {
            bool result;

            if (subEmitter == null || root == null)
            {
                result = false;
            }
            else
            {
                ParticleSystem root2 = ParticleSystemEditorUtils.GetRoot(subEmitter);
                result = (root2 == root);
            }
            return(result);
        }
示例#13
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]);
        }
示例#14
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();
            }
        }
示例#15
0
        internal void Pause()
        {
            bool flag = false;

            foreach (ParticleSystem current in this.m_SelectedParticleSystems)
            {
                ParticleSystem root = ParticleSystemEditorUtils.GetRoot(current);
                if (root)
                {
                    root.Pause();
                    flag = true;
                }
            }
            if (flag)
            {
                ParticleSystemEditorUtils.editorIsScrubbing = true;
                this.m_Owner.Repaint();
            }
        }
示例#16
0
        public void Clear()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(m_SelectedParticleSystems[0]); // root can have been deleted

            if (ShouldManagePlaybackState(root))
            {
                // Store simulation state of current effect as Vector3 (rootInstanceID, isPlaying, playBackTime)
                if (root != null)
                {
                    PlayState playState;
                    if (IsPlaying())
                    {
                        playState = PlayState.Playing;
                    }
                    else if (IsPaused())
                    {
                        playState = PlayState.Paused;
                    }
                    else
                    {
                        playState = PlayState.Stopped;
                    }
                    int rootInstanceId = root.GetInstanceID();
                    SessionState.SetVector3(k_SimulationStateId + rootInstanceId, new Vector3(rootInstanceId, (int)playState, ParticleSystemEditorUtils.playbackTime));
                }

                // Stop the ParticleSystem here (prevents it being frozen on screen)
                //Stop();
            }

            m_ParticleSystemCurveEditor.OnDisable();
            Tools.s_Hidden = false; // The collisionmodule might have hidden the tools

            if (root != null)
            {
                SessionState.SetBool(k_ShowSelectedId + root.GetInstanceID(), m_ShowOnlySelectedMode);
            }
            SetShowOnlySelectedMode(false);

            GameView.RepaintAll();
            SceneView.RepaintAll();
        }
示例#17
0
        private bool CheckIfChild(UnityEngine.Object subEmitter)
        {
            ParticleSystem root           = ParticleSystemEditorUtils.GetRoot(this.m_ParticleSystemUI.m_ParticleSystems[0]);
            ParticleSystem particleSystem = subEmitter as ParticleSystem;
            bool           result;

            if (SubModuleUI.IsChild(particleSystem, root))
            {
                result = true;
            }
            else
            {
                string message = string.Format("The assigned sub emitter is not a child of the current root particle system GameObject: '{0}' and is therefore NOT considered a part of the current effect. Do you want to reparent it?", root.gameObject.name);
                if (EditorUtility.DisplayDialog("Reparent GameObjects", message, "Yes, Reparent", "No, Remove"))
                {
                    if (EditorUtility.IsPersistent(subEmitter))
                    {
                        GameObject gameObject = UnityEngine.Object.Instantiate(subEmitter) as GameObject;
                        if (gameObject != null)
                        {
                            gameObject.transform.parent        = this.m_ParticleSystemUI.m_ParticleSystems[0].transform;
                            gameObject.transform.localPosition = Vector3.zero;
                            gameObject.transform.localRotation = Quaternion.identity;
                        }
                    }
                    else if (particleSystem != null)
                    {
                        Undo.SetTransformParent(particleSystem.gameObject.transform.transform, this.m_ParticleSystemUI.m_ParticleSystems[0].transform, "Reparent sub emitter");
                    }
                    result = true;
                }
                else
                {
                    if (particleSystem != null)
                    {
                        particleSystem.Clear(true);
                    }
                    result = false;
                }
            }
            return(result);
        }
示例#18
0
        internal void Pause()
        {
            bool anyPaused = false;

            foreach (ParticleSystem ps in m_SelectedParticleSystems)
            {
                ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps);
                if (root)
                {
                    root.Pause();
                    anyPaused = true;
                }
            }

            if (anyPaused)
            {
                ParticleSystemEditorUtils.playbackIsScrubbing = true;
                m_Owner.Repaint();
            }
        }
示例#19
0
        private void SingleParticleSystemGUI()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem);

            GUILayout.BeginVertical(ParticleSystemStyles.Get().effectBgStyle, new GUILayoutOption[0]);
            ParticleSystemUI particleSystemUIForParticleSystem = this.GetParticleSystemUIForParticleSystem(this.m_SelectedParticleSystem);

            if (particleSystemUIForParticleSystem != null)
            {
                float width = GUIClip.visibleRect.width - 18f;
                particleSystemUIForParticleSystem.OnGUI(root, width, false);
            }
            GUILayout.EndVertical();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            ParticleSystemEditorUtils.editorResimulation = GUILayout.Toggle(ParticleSystemEditorUtils.editorResimulation, s_Texts.resimulation, EditorStyles.toggle, new GUILayoutOption[0]);
            m_ShowWireframe = GUILayout.Toggle(m_ShowWireframe, "Wireframe", EditorStyles.toggle, new GUILayoutOption[0]);
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            this.HandleKeyboardShortcuts(root);
        }
示例#20
0
 public bool ValidateParticleSystemProperty(SerializedProperty shurikenProperty)
 {
     if (shurikenProperty != null)
     {
         ParticleSystem particleSystem = shurikenProperty.objectReferenceValue as ParticleSystem;
         if (particleSystem != null && this.GetParticleSystemUIForParticleSystem(particleSystem) == null)
         {
             EditorUtility.DisplayDialog("ParticleSystem Warning", string.Concat(new string[]
             {
                 "The SubEmitter module cannot reference a ParticleSystem that is not a child of the root ParticleSystem.\n\nThe ParticleSystem '",
                 particleSystem.name,
                 "' must be a child of the ParticleSystem '",
                 ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem).name,
                 "'."
             }), "Ok");
             shurikenProperty.objectReferenceValue = null;
             return(false);
         }
     }
     return(true);
 }
        public void OnSceneViewGUI()
        {
            if (m_Modules == null)
            {
                return;
            }

            // Render bounds
            if (ParticleEffectUI.m_ShowBounds)
            {
                foreach (ParticleSystem ps in m_ParticleSystems)
                {
                    if (multiEdit)
                    {
                        ShowBounds(ParticleSystemEditorUtils.GetRoot(ps));
                    }
                    else
                    {
                        ShowBounds(ps);
                    }
                }
            }

            UpdateProperties();

            foreach (var module in m_Modules)
            {
                if (module == null || !module.visibleUI || !module.enabled)
                {
                    continue;
                }

                if (module.foldout)
                {
                    module.OnSceneViewGUI();
                }
            }
            // Apply the property, handle undo
            ApplyProperties();
        }
示例#22
0
 public void OnSceneViewGUI()
 {
     if (this.m_Modules != null)
     {
         if (ParticleEffectUI.m_ShowBounds)
         {
             ParticleSystem[] particleSystems = this.m_ParticleSystems;
             for (int i = 0; i < particleSystems.Length; i++)
             {
                 ParticleSystem ps = particleSystems[i];
                 if (this.multiEdit)
                 {
                     this.ShowBounds(ParticleSystemEditorUtils.GetRoot(ps));
                 }
                 else
                 {
                     this.ShowBounds(ps);
                 }
             }
         }
         this.UpdateProperties();
         ModuleUI[] modules = this.m_Modules;
         for (int j = 0; j < modules.Length; j++)
         {
             ModuleUI moduleUI = modules[j];
             if (moduleUI != null && moduleUI.visibleUI && moduleUI.enabled)
             {
                 if (moduleUI.foldout)
                 {
                     moduleUI.OnSceneViewGUI();
                 }
             }
         }
         this.ApplyProperties();
     }
 }
示例#23
0
 internal static bool IsChild(ParticleSystem subEmitter, ParticleSystem root)
 {
     return(((subEmitter != null) && (root != null)) && (ParticleSystemEditorUtils.GetRoot(subEmitter) == root));
 }
示例#24
0
 internal bool IsPaused()
 {
     return(!IsPlaying() && !IsStopped(ParticleSystemEditorUtils.GetRoot(m_SelectedParticleSystems[0])));
 }
示例#25
0
        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;
                }
            }
        }
示例#26
0
        private void MultiParticleSystemGUI(bool verticalLayout)
        {
            // Background
            GUILayout.BeginVertical(ParticleSystemStyles.Get().effectBgStyle);
            m_EmitterAreaScrollPos = EditorGUILayout.BeginScrollView(m_EmitterAreaScrollPos);
            {
                Rect emitterAreaRect = EditorGUILayout.BeginVertical();
                {
                    // Click-Drag with Alt pressed in entire area
                    m_EmitterAreaScrollPos -= EditorGUI.MouseDeltaReader(emitterAreaRect, Event.current.alt);
                    // Top padding
                    GUILayout.Space(3);

                    GUILayout.BeginHorizontal();
                    // Left padding
                    GUILayout.Space(3); // added because cannot use padding due to clippling

                    // Draw Emitters
                    Color orgColor           = GUI.color;
                    bool  isRepaintEvent     = Event.current.type == EventType.Repaint;
                    bool  isShowOnlySelected = IsShowOnlySelectedMode();
                    List <ParticleSystemUI> selectedSystems = GetSelectedParticleSystemUIs();

                    for (int i = 0; i < m_Emitters.Length; ++i)
                    {
                        if (i != 0)
                        {
                            GUILayout.Space(ModuleUI.k_SpaceBetweenModules);
                        }

                        bool isSelected = selectedSystems.Contains(m_Emitters[i]);

                        ModuleUI rendererModuleUI = m_Emitters[i].GetParticleSystemRendererModuleUI();
                        if (isRepaintEvent && rendererModuleUI != null && !rendererModuleUI.enabled)
                        {
                            GUI.color = GetDisabledColor();
                        }

                        if (isRepaintEvent && isShowOnlySelected && !isSelected)
                        {
                            GUI.color = GetDisabledColor();
                        }

                        Rect psRect = EditorGUILayout.BeginVertical();
                        {
                            if (isRepaintEvent && isSelected && m_Emitters.Length > 1)
                            {
                                DrawSelectionMarker(psRect);
                            }

                            m_Emitters[i].OnGUI(ModuleUI.k_CompactFixedModuleWidth, true);
                        }
                        EditorGUILayout.EndVertical();

                        GUI.color = orgColor;
                    }

                    GUILayout.Space(5);
                    if (GUILayout.Button(s_Texts.addParticleSystem, "OL Plus", GUILayout.Width(20)))
                    {
                        // Store state of inspector before creating new particle system that will reload the inspector (new selected object)
                        //SessionState.SetFloat("CurrentEmitterAreaScroll", m_EmitterAreaScrollPos.x);
                        CreateParticleSystem(ParticleSystemEditorUtils.GetRoot(m_SelectedParticleSystems[0]), SubModuleUI.SubEmitterType.None);
                    }

                    GUILayout.FlexibleSpace(); // prevent centering
                    GUILayout.EndHorizontal();
                    GUILayout.Space(4);

                    // Click-Drag in background (does not require Alt pressed)
                    m_EmitterAreaScrollPos -= EditorGUI.MouseDeltaReader(emitterAreaRect, true);

                    GUILayout.FlexibleSpace();  // Makes the emitter area background extend to bottom
                }
                EditorGUILayout.EndVertical();  // EmitterAreaRect
            }
            EditorGUILayout.EndScrollView();

            GUILayout.EndVertical();    // Background

            //GUILayout.FlexibleSpace();    // Makes the emitter area background align to bottom of highest emitter

            // Handle shortcut keys last so we do not activate them if inputfield has used the event
            HandleKeyboardShortcuts();
        }
示例#27
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);
        }
示例#28
0
 public bool ValidateParticleSystemProperty(SerializedProperty shurikenProperty)
 {
     if (shurikenProperty != null)
     {
         ParticleSystem objectReferenceValue = shurikenProperty.objectReferenceValue as ParticleSystem;
         if ((objectReferenceValue != null) && (this.GetParticleSystemUIForParticleSystem(objectReferenceValue) == null))
         {
             EditorUtility.DisplayDialog("ParticleSystem Warning", "The SubEmitter module cannot reference a ParticleSystem that is not a child of the root ParticleSystem.\n\nThe ParticleSystem '" + objectReferenceValue.name + "' must be a child of the ParticleSystem '" + ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem).name + "'.", "Ok");
             shurikenProperty.objectReferenceValue = null;
             return(false);
         }
     }
     return(true);
 }
示例#29
0
        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]);
示例#30
0
 internal ParticleSystem GetRoot()
 {
     return(ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem));
 }