static void UpdateToolContext()
 {
     if (selectMode.IsPositionMode() && ToolManager.activeContextType != typeof(PositionToolContext))
     {
         ToolManager.SetActiveContext <PositionToolContext>();
     }
     else if (selectMode.IsTextureMode() && ToolManager.activeContextType != typeof(TextureToolContext))
     {
         ToolManager.SetActiveContext <TextureToolContext>();
     }
     else if (!selectMode.IsPositionMode())
     {
         ToolManager.SetActiveContext <GameObjectToolContext>();
     }
 }
 void OnToolChanged()
 {
     if (ToolManager.IsActiveTool(this))
     {
         UpdateTarget();
         if (polygon == null)
         {
             End();
         }
     }
     else if (polygon != null)
     {
         End();
     }
 }
Exemplo n.º 3
0
 void OnToolChanged()
 {
     if (ToolManager.IsActiveTool(this))
     {
         UpdateTarget();
         if (polygon == null)
         {
             End();
         }
     }
     else if (polygon != null)
     {
         End();
         EditorApplication.delayCall += () => CheckForSelectModeAfterToolQuit();
     }
 }
Exemplo n.º 4
0
        void OnSelectModeChanged(SelectMode selectMode)
        {
            if (!ToolManager.IsActiveTool(this))
            {
                return;
            }

            if (MeshSelection.activeMesh)
            {
                PolyShape shape = MeshSelection.activeMesh.GetComponent <PolyShape>();
                if (shape != null && shape != polygon || selectMode != SelectMode.Object)
                {
                    LeaveTool(false);
                }
            }
        }
Exemplo n.º 5
0
        protected override ActionResult PerformActionImplementation()
        {
            ProBuilderEditor.selectMode = SelectMode.Object;
            MeshSelection.SetSelection((GameObject)null);

            m_Tool = ScriptableObject.CreateInstance <DrawShapeTool>();
            ToolManager.SetActiveTool(m_Tool);

            Undo.RegisterCreatedObjectUndo(m_Tool, "Open Shape Tool");

            MenuAction.onPerformAction         += ActionPerformed;
            ToolManager.activeToolChanging     += LeaveTool;
            ProBuilderEditor.selectModeChanged += OnSelectModeChanged;

            m_revertSelectModeOnQuit = true;

            return(new ActionResult(ActionResult.Status.Success, "Draw Shape Tool Starts"));
        }
Exemplo n.º 6
0
        void OnObjectSelectionChanged()
        {
            if (!ToolManager.IsActiveTool(this) || polygon == null)
            {
                return;
            }

            if (MeshSelection.activeMesh)
            {
                PolyShape shape = MeshSelection.activeMesh.GetComponent <PolyShape>();
                if (shape == null)
                {
                    LeaveTool(true);
                }
                else if (shape != polygon)
                {
                    UpdateTarget(shape);
                }
            }
        }
        static void SetTool <T>() where T : VertexManipulationTool, new()
        {
            //If the type is already active do nothing
            if (typeof(T) == ToolManager.activeToolType)
            {
                return;
            }

            VertexManipulationTool formerTool = null;

            if (EditorToolManager.activeTool is VertexManipulationTool)
            {
                formerTool = (VertexManipulationTool)EditorToolManager.activeTool;
            }
            ToolManager.SetActiveTool(CreateInstance <T>());
            if (formerTool != null)
            {
                DestroyImmediate(formerTool);
            }
        }
 public static bool IsActiveTool(EditorTool tool)
 {
     return(ToolManager.IsActiveTool(tool));
 }
 public static void RestorePreviousPersistentTool()
 {
     ToolManager.RestorePreviousTool();
 }
 public static void SetActiveTool(EditorTool tool)
 {
     ToolManager.SetActiveTool(tool);
 }
 public static void SetActiveTool(Type type)
 {
     ToolManager.SetActiveTool(type);
 }