Exemplo n.º 1
0
        void OnEnable()
        {
            m_CurrentState = InitStateMachine();

            m_IconContent = new GUIContent()
            {
                image   = IconUtility.GetIcon("Tools/ShapeTool/Arch"),
                text    = "Shape Settings",
                tooltip = "Shape Settings"
            };

            Undo.undoRedoPerformed += HandleUndoRedoPerformed;
            MeshSelection.objectSelectionChanged += OnSelectionChanged;
            ToolManager.activeToolChanged        += OnActiveToolChanged;

            m_ShapePreviewMaterial           = new Material(BuiltinMaterials.defaultMaterial.shader);
            m_ShapePreviewMaterial.hideFlags = HideFlags.HideAndDontSave;

            if (m_ShapePreviewMaterial.HasProperty("_MainTex"))
            {
                m_ShapePreviewMaterial.mainTexture = (Texture2D)Resources.Load("Textures/GridBox_Default");
            }

            if (m_ShapePreviewMaterial.HasProperty("_Color"))
            {
                m_ShapePreviewMaterial.SetColor("_Color", k_PreviewColor);
            }
        }
Exemplo n.º 2
0
 void HandleUndoRedoPerformed()
 {
     if (ToolManager.IsActiveTool(this))
     {
         m_CurrentState = ShapeState.ResetState();
     }
 }
Exemplo n.º 3
0
 void OnDisable()
 {
     if (m_ShapeEditor != null)
     {
         DestroyImmediate(m_ShapeEditor);
     }
     if (m_ProBuilderShape != null && !(m_CurrentState is ShapeState_InitShape))
     {
         ShapeState.ResetState();
     }
 }
Exemplo n.º 4
0
 void OnSelectionChanged()
 {
     if (ToolManager.IsActiveTool(this))
     {
         if (Selection.activeGameObject != null)
         {
             m_CurrentState = ShapeState.ResetState();
             ToolManager.RestorePreviousTool();
         }
     }
 }
 void OnSelectionChanged()
 {
     if (ToolManager.IsActiveTool(this))
     {
         if (Selection.activeGameObject != null &&
             MeshSelection.activeMesh != currentShapeInOverlay.mesh)
         {
             m_CurrentState = ShapeState.ResetState();
             ToolManager.RestorePreviousTool();
         }
     }
 }
Exemplo n.º 6
0
 void OnSelectionChanged()
 {
     if (ToolManager.IsActiveTool(this))
     {
         if (Selection.activeGameObject != null &&
             (MeshSelection.activeMesh == null ||
              MeshSelection.activeMesh.GetComponent <ProBuilderShape>() == null))
         {
             m_CurrentState = ShapeState.ResetState();
             ToolManager.RestorePreviousTool();
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Init the state machine associated to the tool.
        /// All states are linked together and initialized.
        /// </summary>
        /// <returns>
        /// Returns the current state of the StateMachine,
        /// this state machine will self-handle during its lifetime.
        /// </returns>
        ShapeState InitStateMachine()
        {
            ShapeState.tool = this;
            ShapeState initState       = new ShapeState_InitShape();
            ShapeState drawBaseState   = new ShapeState_DrawBaseShape();
            ShapeState drawHeightState = new ShapeState_DrawHeightShape();

            ShapeState.s_defaultState   = initState;
            initState.m_nextState       = drawBaseState;
            drawBaseState.m_nextState   = drawHeightState;
            drawHeightState.m_nextState = initState;

            return(ShapeState.StartStateMachine());
        }
Exemplo n.º 8
0
        void OnDisable()
        {
            Undo.undoRedoPerformed        -= HandleUndoRedoPerformed;
            ToolManager.activeToolChanged -= OnActiveToolChanged;
            handleSelectionChange          = false;

            if (m_ShapeEditor != null)
            {
                DestroyImmediate(m_ShapeEditor);
            }
            if (m_ProBuilderShape != null && !(m_CurrentState is ShapeState_InitShape))
            {
                ShapeState.ResetState();
            }
        }
        public override void OnToolGUI(EditorWindow window)
        {
            SceneViewOverlay.Window(k_ShapeTitle, OnOverlayGUI, 0, SceneViewOverlay.WindowDisplayOption.OneWindowPerTitle);

            var evt = Event.current;

            if (EditorHandleUtility.SceneViewInUse(evt))
            {
                return;
            }

            m_ControlID = GUIUtility.GetControlID(FocusType.Passive);
            HandleUtility.AddDefaultControl(m_ControlID);

            m_CurrentState = m_CurrentState.DoState(evt);
        }
Exemplo n.º 10
0
        public override void OnToolGUI(EditorWindow window)
        {
            SceneViewOverlay.Window(k_ShapeTitle, OnOverlayGUI, 0, SceneViewOverlay.WindowDisplayOption.OneWindowPerTitle);

            var evt = Event.current;

            if (EditorHandleUtility.SceneViewInUse(evt))
            {
                return;
            }

            m_ControlID = GUIUtility.GetControlID(FocusType.Passive);
            HandleUtility.AddDefaultControl(m_ControlID);

            if (GUIUtility.hotControl == 0)
            {
                EditorGUIUtility.AddCursorRect(new Rect(0, 0, Screen.width, Screen.height), MouseCursor.ArrowPlus);
            }

            m_CurrentState = m_CurrentState.DoState(evt);
        }