Ejemplo n.º 1
0
        private bool ValidateSubemitter(ParticleSystem subEmitter)
        {
            if (subEmitter == null)
            {
                return(false);
            }

            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(m_ParticleSystemUI.m_ParticleSystems[0]);

            if (root.gameObject.activeInHierarchy && !subEmitter.gameObject.activeInHierarchy)
            {
                string kReparentText = "The assigned sub emitter is part of a prefab and can therefore not be assigned.";
                EditorUtility.DisplayDialog("Invalid Sub Emitter", kReparentText, "Ok");
                return(false);
            }

            if (!root.gameObject.activeInHierarchy && subEmitter.gameObject.activeInHierarchy)
            {
                string kReparentText = "The assigned sub emitter is part of a scene object and can therefore not be assigned to a prefab.";
                EditorUtility.DisplayDialog("Invalid Sub Emitter", kReparentText, "Ok");
                return(false);
            }


            return(true);
        }
Ejemplo n.º 2
0
        public void Clear()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystems[0]);

            if (this.ShouldManagePlaybackState(root))
            {
                if (root != null)
                {
                    ParticleEffectUI.PlayState playState;
                    if (this.IsPlaying())
                    {
                        playState = ParticleEffectUI.PlayState.Playing;
                    }
                    else if (this.IsPaused())
                    {
                        playState = ParticleEffectUI.PlayState.Paused;
                    }
                    else
                    {
                        playState = ParticleEffectUI.PlayState.Stopped;
                    }
                    int instanceID = root.GetInstanceID();
                    SessionState.SetVector3("SimulationState" + instanceID, new Vector3((float)instanceID, (float)playState, ParticleSystemEditorUtils.playbackTime));
                }
            }
            this.m_ParticleSystemCurveEditor.OnDisable();
            Tools.s_Hidden = false;
            if (root != null)
            {
                SessionState.SetBool("ShowSelected" + root.GetInstanceID(), this.m_ShowOnlySelectedMode);
            }
            this.SetShowOnlySelectedMode(false);
            GameView.RepaintAll();
            SceneView.RepaintAll();
        }
        internal static void StopEffect()
        {
            bool clear = true;
            bool stop  = true;

            ParticleSystemEditorUtils.StopEffect(stop, clear);
        }
Ejemplo n.º 4
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 = ParticleEffectUI.GetDisabledColor();
                }
                if (flag && flag2 && !flag3)
                {
                    GUI.color = ParticleEffectUI.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);
            if (GUILayout.Button(ParticleEffectUI.s_Texts.addParticleSystem, "OL Plus", new GUILayoutOption[]
            {
                GUILayout.Width(20f)
            }))
            {
                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);
        }
Ejemplo n.º 5
0
 internal void Stop()
 {
     ParticleSystemEditorUtils.editorIsScrubbing  = false;
     ParticleSystemEditorUtils.editorPlaybackTime = 0f;
     ParticleSystemEditorUtils.StopEffect();
     this.m_Owner.Repaint();
 }
        public void ApplyProperties()
        {
            bool hasModifiedProperties = m_ParticleSystemSerializedObject.hasModifiedProperties;

            // Check the system was not destroyed such as by an Undo operation.
            if (m_ParticleSystemSerializedObject.targetObject != null)
            {
                m_ParticleSystemSerializedObject.ApplyModifiedProperties();
            }
            if (hasModifiedProperties)
            {
                // Resimulate
                foreach (ParticleSystem ps in m_ParticleSystems)
                {
                    ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps);
                    if (!ParticleEffectUI.IsStopped(root) && ParticleSystemEditorUtils.resimulation)
                    {
                        ParticleSystemEditorUtils.PerformCompleteResimulation();
                    }
                }

                // Refresh procedural supported string
                UpdateParticleSystemInfoString();
            }
            if (m_RendererSerializedObject != null && m_RendererSerializedObject.targetObject != null)
            {
                m_RendererSerializedObject.ApplyModifiedProperties();
            }
        }
        private void ShowBounds(ParticleSystem ps)
        {
            if (ps.particleCount > 0)
            {
                ParticleSystemRenderer particleSystemRenderer = ps.GetComponent <ParticleSystemRenderer>();

                var oldCol = Handles.color;
                Handles.color = Color.yellow;
                var worldBounds = particleSystemRenderer.bounds;
                Handles.DrawWireCube(worldBounds.center, worldBounds.size);
                Handles.color = oldCol;
            }

            // In multi-edit, children are not stored, so render thir bounds manually
            if (multiEdit)
            {
                ParticleSystem[] children = ps.transform.GetComponentsInChildren <ParticleSystem>();
                foreach (ParticleSystem child in children)
                {
                    if (child != ps)
                    {
                        bool alreadySelected = m_ParticleSystems.FirstOrDefault(o => ParticleSystemEditorUtils.GetRoot(o) == child) != null;
                        if (!alreadySelected)
                        {
                            ShowBounds(child);
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public bool ValidateParticleSystemProperty(SerializedProperty shurikenProperty)
        {
            bool result;

            if (shurikenProperty != null)
            {
                ParticleSystem particleSystem = shurikenProperty.objectReferenceValue as ParticleSystem;
                if (particleSystem != null)
                {
                    if (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;
                        result = false;
                        return(result);
                    }
                }
            }
            result = true;
            return(result);
        }
Ejemplo n.º 9
0
        private bool ValidateSubemitter(ParticleSystem subEmitter)
        {
            bool result;

            if (subEmitter == null)
            {
                result = false;
            }
            else
            {
                ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_ParticleSystemUI.m_ParticleSystems[0]);
                if (root.gameObject.activeInHierarchy && !subEmitter.gameObject.activeInHierarchy)
                {
                    string message = string.Format("The assigned sub emitter is part of a prefab and can therefore not be assigned.", new object[0]);
                    EditorUtility.DisplayDialog("Invalid Sub Emitter", message, "Ok");
                    result = false;
                }
                else if (!root.gameObject.activeInHierarchy && subEmitter.gameObject.activeInHierarchy)
                {
                    string message2 = string.Format("The assigned sub emitter is part of a scene object and can therefore not be assigned to a prefab.", new object[0]);
                    EditorUtility.DisplayDialog("Invalid Sub Emitter", message2, "Ok");
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
Ejemplo n.º 10
0
        public void ApplyProperties()
        {
            bool hasModifiedProperties = this.m_ParticleSystemSerializedObject.hasModifiedProperties;

            if (this.m_ParticleSystemSerializedObject.targetObject != null)
            {
                this.m_ParticleSystemSerializedObject.ApplyModifiedProperties();
            }
            if (hasModifiedProperties)
            {
                ParticleSystem[] particleSystems = this.m_ParticleSystems;
                for (int i = 0; i < particleSystems.Length; i++)
                {
                    ParticleSystem ps   = particleSystems[i];
                    ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps);
                    if (!ParticleEffectUI.IsStopped(root) && ParticleSystemEditorUtils.editorResimulation)
                    {
                        ParticleSystemEditorUtils.PerformCompleteResimulation();
                    }
                }
                this.UpdateParticleSystemInfoString();
            }
            if (this.m_RendererSerializedObject != null && this.m_RendererSerializedObject.targetObject != null)
            {
                this.m_RendererSerializedObject.ApplyModifiedProperties();
            }
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
 internal static bool IsChild(ParticleSystem subEmitter, ParticleSystem root)
 {
     if ((Object)subEmitter == (Object)null || (Object)root == (Object)null)
     {
         return(false);
     }
     return((Object)ParticleSystemEditorUtils.GetRoot(subEmitter) == (Object)root);
 }
Ejemplo n.º 13
0
 internal static bool IsChild(ParticleSystem subEmitter, ParticleSystem root)
 {
     if ((subEmitter == null) || (root == null))
     {
         return(false);
     }
     return(ParticleSystemEditorUtils.GetRoot(subEmitter) == root);
 }
Ejemplo n.º 14
0
        public override void OnSceneGUI(ParticleSystem s, InitialModuleUI initial)
        {
            Event     current = Event.current;
            EventType rawType = current.type;

            if ((current.type == EventType.Ignore) && (current.rawType == EventType.MouseUp))
            {
                rawType = current.rawType;
            }
            Color color  = Handles.color;
            Color color2 = new Color(1f, 1f, 1f, 0.5f);

            Handles.color = color2;
            if (this.m_Type.intValue == 0)
            {
                for (int i = 0; i < this.m_ShownPlanes.Length; i++)
                {
                    UnityEngine.Object objectReferenceValue = this.m_ShownPlanes[i].objectReferenceValue;
                    if (objectReferenceValue != null)
                    {
                        Transform objB = objectReferenceValue as Transform;
                        if (objB != null)
                        {
                            Vector3    position = objB.position;
                            Quaternion rotation = objB.rotation;
                            Vector3    vector2  = (Vector3)(rotation * Vector3.right);
                            Vector3    normal   = (Vector3)(rotation * Vector3.up);
                            Vector3    vector4  = (Vector3)(rotation * Vector3.forward);
                            if (object.ReferenceEquals(s_SelectedTransform, objB))
                            {
                                Tools.s_Hidden = true;
                                EditorGUI.BeginChangeCheck();
                                if (Tools.current == UnityEditor.Tool.Move)
                                {
                                    objB.position = Handles.PositionHandle(position, rotation);
                                }
                                else if (Tools.current == UnityEditor.Tool.Rotate)
                                {
                                    objB.rotation = Handles.RotationHandle(rotation, position);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    if (this.m_PlaneVisualizationType == PlaneVizType.Solid)
                                    {
                                        GameObject plane = ParticleEffectUtils.GetPlane(i);
                                        plane.transform.position   = position;
                                        plane.transform.rotation   = rotation;
                                        plane.transform.localScale = new Vector3(this.m_ScaleGrid, this.m_ScaleGrid, this.m_ScaleGrid);
                                    }
                                    ParticleSystemEditorUtils.PerformCompleteResimulation();
                                }
                            }
                            else
                            {
                                int   keyboardControl = GUIUtility.keyboardControl;
                                float size            = HandleUtility.GetHandleSize(position) * 0.06f;
                                if (< > f__mg$cache0 == null)
                                {
Ejemplo n.º 15
0
        private void HandleKeyboardShortcuts(ParticleSystem root)
        {
            Event current = Event.current;

            if (current.type == EventType.KeyDown)
            {
                int num = 0;
                if (current.keyCode == (Event)ParticleEffectUI.kPlay.keyCode)
                {
                    if (EditorApplication.isPlaying)
                    {
                        this.Stop();
                        this.Play();
                    }
                    else if (!ParticleSystemEditorUtils.editorIsPlaying)
                    {
                        this.Play();
                    }
                    else
                    {
                        this.Pause();
                    }
                    current.Use();
                }
                else if (current.keyCode == (Event)ParticleEffectUI.kStop.keyCode)
                {
                    this.Stop();
                    current.Use();
                }
                else if (current.keyCode == (Event)ParticleEffectUI.kReverse.keyCode)
                {
                    num = -1;
                }
                else if (current.keyCode == (Event)ParticleEffectUI.kForward.keyCode)
                {
                    num = 1;
                }
                if (num != 0)
                {
                    ParticleSystemEditorUtils.editorIsScrubbing = true;
                    float editorSimulationSpeed = ParticleSystemEditorUtils.editorSimulationSpeed;
                    ParticleSystemEditorUtils.editorPlaybackTime = Mathf.Max(0.0f, ParticleSystemEditorUtils.editorPlaybackTime + (float)((!current.shift ? 1.0 : 3.0) * (double)this.m_TimeHelper.deltaTime * (num <= 0 ? -3.0 : 3.0)) * editorSimulationSpeed);
                    if (root.isStopped)
                    {
                        root.Play();
                        root.Pause();
                    }
                    ParticleSystemEditorUtils.PerformCompleteResimulation();
                    current.Use();
                }
            }
            if (current.type != EventType.KeyUp || current.keyCode != (Event)ParticleEffectUI.kReverse.keyCode && current.keyCode != (Event)ParticleEffectUI.kForward.keyCode)
            {
                return;
            }
            ParticleSystemEditorUtils.editorIsScrubbing = false;
        }
Ejemplo n.º 16
0
        private void HandleKeyboardShortcuts(ParticleSystem root)
        {
            Event current = Event.current;

            if (current.type == EventType.KeyDown)
            {
                int num = 0;
                if (current.keyCode == kPlay.keyCode)
                {
                    if (EditorApplication.isPlaying)
                    {
                        this.Stop();
                        this.Play();
                    }
                    else if (!ParticleSystemEditorUtils.editorIsPlaying)
                    {
                        this.Play();
                    }
                    else
                    {
                        this.Pause();
                    }
                    current.Use();
                }
                else if (current.keyCode == kStop.keyCode)
                {
                    this.Stop();
                    current.Use();
                }
                else if (current.keyCode == kReverse.keyCode)
                {
                    num = -1;
                }
                else if (current.keyCode == kForward.keyCode)
                {
                    num = 1;
                }
                if (num != 0)
                {
                    ParticleSystemEditorUtils.editorIsScrubbing = true;
                    float editorSimulationSpeed = ParticleSystemEditorUtils.editorSimulationSpeed;
                    float num3 = ((!current.shift ? 1f : 3f) * this.m_TimeHelper.deltaTime) * ((num <= 0) ? -3f : 3f);
                    ParticleSystemEditorUtils.editorPlaybackTime = Mathf.Max((float)0f, (float)(ParticleSystemEditorUtils.editorPlaybackTime + (num3 * editorSimulationSpeed)));
                    if (root.isStopped)
                    {
                        root.Play();
                        root.Pause();
                    }
                    ParticleSystemEditorUtils.PerformCompleteResimulation();
                    current.Use();
                }
            }
            if ((current.type == EventType.KeyUp) && ((current.keyCode == kReverse.keyCode) || (current.keyCode == kForward.keyCode)))
            {
                ParticleSystemEditorUtils.editorIsScrubbing = false;
            }
        }
Ejemplo n.º 17
0
		internal static bool IsChild(ParticleSystem subEmitter, ParticleSystem root)
		{
			if (subEmitter == null || root == null)
			{
				return false;
			}
			ParticleSystem root2 = ParticleSystemEditorUtils.GetRoot(subEmitter);
			return root2 == root;
		}
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
0
        internal void Pause()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem);

            if (root)
            {
                root.Pause();
                ParticleSystemEditorUtils.editorIsScrubbing = true;
                this.m_Owner.Repaint();
            }
        }
Ejemplo n.º 20
0
        internal void Play()
        {
            ParticleSystem root = ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystem);

            if (root != null)
            {
                root.Play();
                ParticleSystemEditorUtils.editorIsScrubbing = false;
                this.m_Owner.Repaint();
            }
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
0
        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();
        }
Ejemplo n.º 23
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]);
            }
        }
Ejemplo n.º 24
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();
            }
        }
Ejemplo n.º 25
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();
            }
        }
Ejemplo n.º 26
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);
        }
Ejemplo n.º 27
0
 private void Update()
 {
     if (this.m_CheckObjectIndex >= 0)
     {
         if (!ObjectSelector.isVisible)
         {
             SerializedProperty arrayElementAtIndex  = this.m_SubEmitters.GetArrayElementAtIndex(this.m_CheckObjectIndex);
             SerializedProperty serializedProperty   = arrayElementAtIndex.FindPropertyRelative("emitter");
             UnityEngine.Object objectReferenceValue = serializedProperty.objectReferenceValue;
             ParticleSystem     particleSystem       = objectReferenceValue as ParticleSystem;
             if (particleSystem != null)
             {
                 bool flag = true;
                 if (this.ValidateSubemitter(particleSystem))
                 {
                     string text = ParticleSystemEditorUtils.CheckCircularReferences(particleSystem);
                     if (text.Length == 0)
                     {
                         if (!this.CheckIfChild(objectReferenceValue))
                         {
                             flag = false;
                         }
                     }
                     else
                     {
                         string message = string.Format("'{0}' could not be assigned as subemitter on '{1}' due to circular referencing!\nBacktrace: {2} \n\nReference will be removed.", particleSystem.gameObject.name, this.m_ParticleSystemUI.m_ParticleSystem.gameObject.name, text);
                         EditorUtility.DisplayDialog("Circular References Detected", message, "Ok");
                         flag = false;
                     }
                 }
                 else
                 {
                     flag = false;
                 }
                 if (!flag)
                 {
                     serializedProperty.objectReferenceValue = null;
                     this.m_ParticleSystemUI.ApplyProperties();
                     this.m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.Repaint();
                 }
             }
             this.m_CheckObjectIndex  = -1;
             EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(this.Update));
         }
     }
 }
Ejemplo n.º 28
0
        private void Update()
        {
            if ((this.m_CheckObjectIndex >= 0) && !ObjectSelector.isVisible)
            {
                SerializedProperty property2            = this.m_SubEmitters.GetArrayElementAtIndex(this.m_CheckObjectIndex).FindPropertyRelative("emitter");
                UnityEngine.Object objectReferenceValue = property2.objectReferenceValue;
                ParticleSystem     subEmitter           = objectReferenceValue as ParticleSystem;
                if (subEmitter != null)
                {
                    bool flag = true;
                    if (this.ValidateSubemitter(subEmitter))
                    {
                        string str = ParticleSystemEditorUtils.CheckCircularReferences(subEmitter);
                        if (str.Length == 0)
                        {
                            if (!this.CheckIfChild(objectReferenceValue))
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            string message = $"'{subEmitter.gameObject.name}' could not be assigned as subemitter on '{base.m_ParticleSystemUI.m_ParticleSystem.gameObject.name}' due to circular referencing!
Backtrace: {str} 

Reference will be removed.";
                            EditorUtility.DisplayDialog("Circular References Detected", message, "Ok");
                            flag = false;
                        }
                    }
                    else
                    {
                        flag = false;
                    }
                    if (!flag)
                    {
                        property2.objectReferenceValue = null;
                        base.m_ParticleSystemUI.ApplyProperties();
                        base.m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.Repaint();
                    }
                }
                this.m_CheckObjectIndex  = -1;
                EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(this.Update));
            }
        }
Ejemplo n.º 29
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]);
        }
Ejemplo n.º 30
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();
            }
        }