Example #1
0
        public override void OnSceneGUI(ParticleSystem s, InitialModuleUI initial)
        {
            Event     current   = Event.current;
            EventType eventType = current.type;

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

            Handles.color = color2;
            if (this.m_Type.intValue == 0)
            {
                for (int i = 0; i < this.m_ShownPlanes.Length; i++)
                {
                    UnityEngine.Object objectReferenceValue = this.m_ShownPlanes[i].objectReferenceValue;
                    if (objectReferenceValue != null)
                    {
                        Transform transform = objectReferenceValue as Transform;
                        if (transform != null)
                        {
                            Vector3    position = transform.position;
                            Quaternion rotation = transform.rotation;
                            Vector3    axis     = rotation * Vector3.right;
                            Vector3    normal   = rotation * Vector3.up;
                            Vector3    axis2    = rotation * Vector3.forward;
                            if (object.ReferenceEquals(CollisionModuleUI.m_SelectedTransform, transform))
                            {
                                Tools.s_Hidden = true;
                                EditorGUI.BeginChangeCheck();
                                if (Tools.current == Tool.Move)
                                {
                                    transform.position = Handles.PositionHandle(position, rotation);
                                }
                                else if (Tools.current == Tool.Rotate)
                                {
                                    transform.rotation = Handles.RotationHandle(rotation, position);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    if (this.m_PlaneVisualizationType == CollisionModuleUI.PlaneVizType.Solid)
                                    {
                                        GameObject plane = ParticleEffectUtils.GetPlane(i);
                                        plane.transform.position   = position;
                                        plane.transform.rotation   = rotation;
                                        plane.transform.localScale = new Vector3(this.m_ScaleGrid, this.m_ScaleGrid, this.m_ScaleGrid);
                                    }
                                    ParticleSystemEditorUtils.PerformCompleteResimulation();
                                }
                            }
                            else
                            {
                                int   keyboardControl = GUIUtility.keyboardControl;
                                float size            = HandleUtility.GetHandleSize(position) * 0.06f;
                                Handles.FreeMoveHandle(position, Quaternion.identity, size, Vector3.zero, new Handles.DrawCapFunction(Handles.RectangleCap));
                                if (eventType == EventType.MouseDown && current.type == EventType.Used && keyboardControl != GUIUtility.keyboardControl)
                                {
                                    CollisionModuleUI.m_SelectedTransform = transform;
                                    eventType = EventType.Used;
                                }
                            }
                            if (this.m_PlaneVisualizationType == CollisionModuleUI.PlaneVizType.Grid)
                            {
                                Color color3 = Handles.s_ColliderHandleColor * 0.9f;
                                if (!base.enabled)
                                {
                                    color3 = new Color(0.7f, 0.7f, 0.7f, 0.7f);
                                }
                                this.DrawGrid(position, axis, axis2, normal, color3, i);
                            }
                            else
                            {
                                this.DrawSolidPlane(position, rotation, i);
                            }
                        }
                        else
                        {
                            Debug.LogError("Not a transform: " + objectReferenceValue.GetType());
                        }
                    }
                }
            }
            Handles.color = color;
        }
Example #2
0
 private void CollisionPlanesSceneGUI()
 {
     if (this.m_ScenePlanes.Count != 0)
     {
         Event     current   = Event.current;
         EventType eventType = current.type;
         if (current.type == EventType.Ignore && current.rawType == EventType.MouseUp)
         {
             eventType = current.rawType;
         }
         Color color  = Handles.color;
         Color color2 = new Color(1f, 1f, 1f, 0.5f);
         for (int i = 0; i < this.m_ScenePlanes.Count; i++)
         {
             if (!(this.m_ScenePlanes[i] == null))
             {
                 Transform  transform = this.m_ScenePlanes[i];
                 Vector3    position  = transform.position;
                 Quaternion rotation  = transform.rotation;
                 Vector3    axis      = rotation * Vector3.right;
                 Vector3    normal    = rotation * Vector3.up;
                 Vector3    axis2     = rotation * Vector3.forward;
                 bool       flag      = EditorApplication.isPlaying && transform.gameObject.isStatic;
                 if (this.editingPlanes)
                 {
                     if (object.ReferenceEquals(CollisionModuleUI.s_SelectedTransform, transform))
                     {
                         EditorGUI.BeginChangeCheck();
                         Vector3    position2 = transform.position;
                         Quaternion rotation2 = transform.rotation;
                         using (new EditorGUI.DisabledScope(flag))
                         {
                             if (flag)
                             {
                                 Handles.ShowStaticLabel(position);
                             }
                             if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesMove)
                             {
                                 position2 = Handles.PositionHandle(position, rotation);
                             }
                             else if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesRotate)
                             {
                                 rotation2 = Handles.RotationHandle(rotation, position);
                             }
                         }
                         if (EditorGUI.EndChangeCheck())
                         {
                             Undo.RecordObject(transform, "Modified Collision Plane Transform");
                             transform.position = position2;
                             transform.rotation = rotation2;
                             ParticleSystemEditorUtils.PerformCompleteResimulation();
                         }
                     }
                     else
                     {
                         int        keyboardControl = GUIUtility.keyboardControl;
                         float      num             = HandleUtility.GetHandleSize(position) * 0.6f;
                         Vector3    arg_1FA_0       = position;
                         Quaternion arg_1FA_1       = Quaternion.identity;
                         float      arg_1FA_2       = num;
                         Vector3    arg_1FA_3       = Vector3.zero;
                         if (CollisionModuleUI.< > f__mg$cache0 == null)
                         {
                             CollisionModuleUI.< > f__mg$cache0 = new Handles.CapFunction(Handles.RectangleHandleCap);
                         }
                         Handles.FreeMoveHandle(arg_1FA_0, arg_1FA_1, arg_1FA_2, arg_1FA_3, CollisionModuleUI.< > f__mg$cache0);
                         if (eventType == EventType.MouseDown && current.type == EventType.Used && keyboardControl != GUIUtility.keyboardControl)
                         {
                             CollisionModuleUI.s_SelectedTransform = transform;
                             eventType             = EventType.Used;
                             GUIUtility.hotControl = 0;
                         }
                     }
                 }
                 Handles.color = color2;
                 Color color3 = Handles.s_ColliderHandleColor * 0.9f;
                 if (flag)
                 {
                     color3.a *= 0.2f;
                 }
                 if (CollisionModuleUI.m_PlaneVisualizationType == CollisionModuleUI.PlaneVizType.Grid)
                 {
                     CollisionModuleUI.DrawGrid(position, axis, axis2, normal, color3);
                 }
                 else
                 {
                     CollisionModuleUI.DrawSolidPlane(position, rotation, color3, Color.yellow);
                 }
             }
         }
         Handles.color = color;
     }
 }
        private void CollisionPlanesSceneGUI()
        {
            if (m_ScenePlanes.Count == 0)
            {
                return;
            }

            Event evt = Event.current;

            Color origCol = Handles.color;
            Color col     = new Color(1, 1, 1, 0.5F);

            for (int i = 0; i < m_ScenePlanes.Count; ++i)
            {
                if (m_ScenePlanes[i] == null)
                {
                    continue;
                }

                Transform  transform          = m_ScenePlanes[i];
                Vector3    position           = transform.position;
                Quaternion rotation           = transform.rotation;
                Vector3    right              = rotation * Vector3.right;
                Vector3    up                 = rotation * Vector3.up;
                Vector3    forward            = rotation * Vector3.forward;
                bool       isPlayingAndStatic = EditorApplication.isPlaying && transform.gameObject.isStatic;
                if (editingPlanes)
                {
                    if (Object.ReferenceEquals(s_SelectedTransform, transform))
                    {
                        EditorGUI.BeginChangeCheck();
                        var newPosition = transform.position;
                        var newRotation = transform.rotation;

                        using (new EditorGUI.DisabledScope(isPlayingAndStatic))
                        {
                            if (isPlayingAndStatic)
                            {
                                Handles.ShowStaticLabel(position);
                            }
                            if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesMove)
                            {
                                newPosition = Handles.PositionHandle(position, rotation);
                            }
                            else if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesRotate)
                            {
                                newRotation = Handles.RotationHandle(rotation, position);
                            }
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(transform, "Modified Collision Plane Transform");
                            transform.position = newPosition;
                            transform.rotation = newRotation;
                            ParticleSystemEditorUtils.PerformCompleteResimulation();
                        }
                    }
                    else
                    {
                        float handleSize = HandleUtility.GetHandleSize(position) * 0.6f;

                        EventType oldEventType = evt.type;

                        // we want ignored mouse up events to check for dragging off of scene view
                        if (evt.type == EventType.Ignore && evt.rawType == EventType.MouseUp)
                        {
                            oldEventType = evt.rawType;
                        }

                        Handles.FreeMoveHandle(position, Quaternion.identity, handleSize, Vector3.zero, Handles.RectangleHandleCap);

                        // Detect selected plane (similar to TreeEditor)
                        if (oldEventType == EventType.MouseDown && evt.type == EventType.Used)
                        {
                            s_SelectedTransform   = transform;
                            oldEventType          = EventType.Used;
                            GUIUtility.hotControl = 0; // Reset hot control or the FreeMoveHandle will prevent input to the new Handles. (case 873514)
                        }
                    }
                }

                Handles.color = col;
                Color color = Handles.s_ColliderHandleColor * 0.9f;
                if (isPlayingAndStatic)
                {
                    color.a *= 0.2f;
                }

                if (m_PlaneVisualizationType == PlaneVizType.Grid)
                {
                    DrawGrid(position, right, forward, up, color);
                }
                else
                {
                    DrawSolidPlane(position, rotation, color, Color.yellow);
                }
            }

            Handles.color = origCol;
        }
Example #4
0
        public static bool MovePoints(IEditablePoint points, Transform cloudTransform, List <int> selection)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            PointEditor.\u003CMovePoints\u003Ec__AnonStorey40 pointsCAnonStorey40 = new PointEditor.\u003CMovePoints\u003Ec__AnonStorey40();
            // ISSUE: reference to a compiler-generated field
            pointsCAnonStorey40.points = points;
            if (selection.Count == 0)
            {
                return(false);
            }
            if (Event.current.type == EventType.MouseUp)
            {
                PointEditor.s_EditingScale    = Vector3.one;
                PointEditor.s_EditingRotation = Quaternion.identity;
            }
            if ((bool)((UnityEngine.Object)Camera.current))
            {
                Vector3 zero = Vector3.zero;
                // ISSUE: reference to a compiler-generated method
                // ISSUE: reference to a compiler-generated field
                Vector3 position1 = Tools.pivotMode != PivotMode.Pivot ? selection.Aggregate <int, Vector3>(zero, new Func <Vector3, int, Vector3>(pointsCAnonStorey40.\u003C\u003Em__57)) / (float)selection.Count : pointsCAnonStorey40.points.GetPosition(selection[0]);
                Vector3 position2 = cloudTransform.TransformPoint(position1);
                switch (Tools.current)
                {
                case Tool.Move:
                    Vector3 position3 = Handles.PositionHandle(position2, Tools.pivotRotation != PivotRotation.Local ? Quaternion.identity : cloudTransform.rotation);
                    if (GUI.changed)
                    {
                        Vector3 vector3 = cloudTransform.InverseTransformPoint(position3) - cloudTransform.InverseTransformPoint(position2);
                        using (List <int> .Enumerator enumerator = selection.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                int current = enumerator.Current;
                                // ISSUE: reference to a compiler-generated field
                                // ISSUE: reference to a compiler-generated field
                                pointsCAnonStorey40.points.SetPosition(current, pointsCAnonStorey40.points.GetPosition(current) + vector3);
                            }
                        }
                        return(true);
                    }
                    break;

                case Tool.Rotate:
                    Quaternion quaternion = Handles.RotationHandle(PointEditor.s_EditingRotation, position2);
                    if (GUI.changed)
                    {
                        Vector3 vector3_1 = cloudTransform.InverseTransformPoint(position2);
                        using (List <int> .Enumerator enumerator = selection.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                int current = enumerator.Current;
                                // ISSUE: reference to a compiler-generated field
                                Vector3 vector3_2 = pointsCAnonStorey40.points.GetPosition(current) - vector3_1;
                                Vector3 vector3_3 = Quaternion.Inverse(PointEditor.s_EditingRotation) * vector3_2;
                                Vector3 position4 = quaternion * vector3_3 + vector3_1;
                                // ISSUE: reference to a compiler-generated field
                                pointsCAnonStorey40.points.SetPosition(current, position4);
                            }
                        }
                        PointEditor.s_EditingRotation = quaternion;
                        return(true);
                    }
                    break;

                case Tool.Scale:
                    Vector3 vector3_4 = Handles.ScaleHandle(PointEditor.s_EditingScale, position2, Quaternion.identity, HandleUtility.GetHandleSize(position2));
                    if (GUI.changed)
                    {
                        Vector3 vector3_1 = cloudTransform.InverseTransformPoint(position2);
                        using (List <int> .Enumerator enumerator = selection.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                int current = enumerator.Current;
                                // ISSUE: reference to a compiler-generated field
                                Vector3 position4 = pointsCAnonStorey40.points.GetPosition(current) - vector3_1;
                                position4.x /= PointEditor.s_EditingScale.x;
                                position4.y /= PointEditor.s_EditingScale.y;
                                position4.z /= PointEditor.s_EditingScale.z;
                                position4.x *= vector3_4.x;
                                position4.y *= vector3_4.y;
                                position4.z *= vector3_4.z;
                                position4   += vector3_1;
                                // ISSUE: reference to a compiler-generated field
                                pointsCAnonStorey40.points.SetPosition(current, position4);
                            }
                        }
                        PointEditor.s_EditingScale = vector3_4;
                        return(true);
                    }
                    break;
                }
            }
            return(false);
        }