Exemplo n.º 1
0
        public static void DeactivateTool(bool selectNode = false)
        {
            if (!IsActive())
            {
                return;
            }
            // Unity has unreliable events
            ChiselGeneratorManager.GeneratorMode.OnDeactivate();
            ToolManager.RestorePreviousPersistentTool();
            if (!IsActive())
            {
                return;
            }

            if (selectNode && ChiselToolsOverlay.HaveNodesInSelection())
            {
                ChiselEditGeneratorTool.ActivateTool();
                if (!IsActive())
                {
                    return;
                }
            }

            ToolManager.RestorePreviousTool();
            if (!IsActive())
            {
                return;
            }

            Tools.current = Tool.Move;
        }
Exemplo n.º 2
0
        public override void OnToolGUI(EditorWindow window)
        {
            if (lastSelectedTool == null ||
                lastSelectedTool != this)
            {
                if (lastSelectedTool != null)
                {
                    lastSelectedTool.OnDeactivate();
                }
                lastSelectedTool = this;
                OnActivate();
            }
            var sceneView = window as SceneView;
            var dragArea  = sceneView.position;

            dragArea.position = Vector2.zero;

            ChiselOptionsOverlay.AdditionalSettings = null;
            ChiselOptionsOverlay.SetTitle(OptionsTitle);

            OnSceneGUI(sceneView, dragArea);

            ChiselOptionsOverlay.Show();
            ChiselToolsOverlay.Show();
            ChiselSnappingOptionsOverlay.Show();
        }
Exemplo n.º 3
0
 public void OnEnable()
 {
     lastSelectedTool = null;
     ChiselToolsOverlay.Register(this);
     EditorApplication.delayCall -= OnDelayedEnable;
     EditorApplication.delayCall += OnDelayedEnable;
 }
Exemplo n.º 4
0
        internal static void ActivateTool(ChiselGeneratorMode currentTool)
        {
            if (currentTool != null && Tools.hidden)
            {
                Tools.hidden = false;
            }
            if (currentTool == Instance.data.currentGenerator)
            {
                return;
            }
            if (currentTool != null && Tools.hidden)
            {
                Tools.hidden = false;
            }

            var prevTool = Instance.data.currentGenerator;

            if (prevTool != null)
            {
                prevTool.OnDeactivate();
            }
            Instance.data.currentGenerator = null;
            if (currentTool != null)
            {
                currentTool.OnActivate();
            }
            Instance.data.currentGenerator = currentTool;

            ChiselToolsOverlay.UpdateCreateToolIcon();

            GeneratorSelectionChanged?.Invoke(prevTool, currentTool);
        }
Exemplo n.º 5
0
 public void OnEnable()
 {
     lastSelectedTool = null;
     ChiselToolsOverlay.Register(this);
     ToolNotActivatingBugWorkAround();
     UpdateIcon();
     NotifyOnSelectionChanged();
 }
Exemplo n.º 6
0
        public static void ShowDefaultOverlay()
        {
            if (!haveNodeSelection)
            {
                return;
            }

            ChiselOptionsOverlay.AdditionalSettings = null;

            ChiselOptionsOverlay.Show();
            ChiselToolsOverlay.Show();
            ChiselSnappingOptionsOverlay.Show();
        }