Example #1
0
        public void OnSceneGUI()
        {
            var railManager = (RailManager)target;

            if (target == null)
            {
                return;
            }

            _rails = Utilities.GetRailsFromChildren(railManager.gameObject, true);

            var handleSize = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;
            var snapValue  = EditorPrefs.GetFloat(EditorPreferences.SnapKey, EditorPreferences.SnapValue);
            var snapSize   = new Vector3(snapValue, snapValue, snapValue);

            // Allows node removal
            var nodeRemovalActive = false;

            if (Event.current.shift)
            {
                nodeRemovalActive = true;
            }

            // Allows new nodes to be snapped to grid when added
            var snapActive = false;

            if (Event.current.control)
            {
                snapActive = true;
            }

            // Draw rails
            for (int i = 0; i < _rails.Count; i++)
            {
                var rail = _rails[i];
                if (rail.Nodes.Count < 2)
                {
                    continue;
                }
                GUIUtilities.DrawRailOnScene(rail, handleSize, snapSize, snapActive, nodeRemovalActive, true);
            }

            // Sync editor values with scene if rail is displayed in editor
            if (_currentRailIndex != -1)
            {
                Repaint();
            }
        }
Example #2
0
        public void OnSceneGUI()
        {
            var currentRail = (Rail)target;

            if (target == null)
            {
                return;
            }

            if (currentRail.Nodes.Count < 2)
            {
                return;
            }

            var handleSize = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;
            var snapValue  = EditorPrefs.GetFloat(EditorPreferences.SnapKey, EditorPreferences.SnapValue);
            var snapSize   = new Vector3(snapValue, snapValue, snapValue);

            // Draw editable rail
            if (currentRail.gameObject.transform.parent != null &&
                currentRail.gameObject.GetComponentInParent <RailManager>() != null)
            {
                // Allows node removal
                var nodeRemovalIsActive = false;
                if (Event.current.shift)
                {
                    nodeRemovalIsActive = true;
                }

                // Allows new nodes to be snapped to grid when added
                var snapActive = false;
                if (Event.current.control)
                {
                    snapActive = true;
                }

                GUIUtilities.DrawRailOnScene(currentRail, handleSize, snapSize, snapActive, nodeRemovalIsActive, true);
            }
            // Draw uneditable rail
            else
            {
                GUIUtilities.DrawRailOnScene(currentRail, handleSize, snapSize);
            }
        }
Example #3
0
        public void OnSceneGUI()
        {
            var railcam2DCore = (Railcam2DCore)target;

            if (target == null)
            {
                return;
            }

            var handleSize = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;
            var snapValue  = EditorPrefs.GetFloat(EditorPreferences.SnapKey, EditorPreferences.SnapValue);
            var snapSize   = new Vector3(snapValue, snapValue, snapValue);

            // If no Rail Manager component on game object, draw uneditable rails
            if (railcam2DCore.GetComponent <RailManager>() == null)
            {
                _rails = Utilities.GetRailsFromChildren(railcam2DCore.gameObject, true);

                for (int i = 0; i < _rails.Count; i++)
                {
                    var rail = _rails[i];
                    if (rail.Nodes.Count < 2)
                    {
                        continue;
                    }

                    GUIUtilities.DrawRailOnScene(rail, handleSize, snapSize);
                }
            }

            // If no Trigger Manager component on game object, draw uneditable triggers
            if (railcam2DCore.GetComponent <TriggerManager>() == null)
            {
                _triggers = Utilities.GetTriggersFromChildren(railcam2DCore.gameObject, true);

                for (int i = 0; i < _triggers.Count; i++)
                {
                    var currentTrigger = _triggers[i];
                    GUIUtilities.DrawTriggerOnScene(currentTrigger, handleSize, snapSize);
                }
            }
        }