Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            DrawShapeGUI();
            DrawShapeParametersGUI();

            if (ToolManager.activeToolType != typeof(DrawShapeTool) &&
                ToolManager.activeToolType != typeof(EditShapeTool))
            {
                if (GUILayout.Button("Edit Shape"))
                {
                    ProBuilderEditor.selectMode = SelectMode.Object;
                    ToolManager.SetActiveTool <EditShapeTool>();
                }
            }
        }
        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 Draw Shape Tool");

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

            return(new ActionResult(ActionResult.Status.Success, "Draw Shape Tool Starts"));
        }
Ejemplo n.º 3
0
        protected override ActionResult PerformActionImplementation()
        {
            if (!CanCreateNewPolyShape())
            {
                return(new ActionResult(ActionResult.Status.Canceled, "Canceled Create Poly Shape"));
            }

            GameObject go = new GameObject("PolyShape");

            UndoUtility.RegisterCreatedObjectUndo(go, "Create Poly Shape");
            PolyShape      poly = Undo.AddComponent <PolyShape>(go);
            ProBuilderMesh pb   = Undo.AddComponent <ProBuilderMesh>(go);

            pb.CreateShapeFromPolygon(poly.m_Points, poly.extrude, poly.flipNormals);
            EditorUtility.InitObject(pb);

            // Special case - we don't want to reset the grid pivot because we rely on it to set the active plane for
            // interaction, regardless of whether snapping is enabled or not.
            if (ProGridsInterface.SnapEnabled() || ProGridsInterface.GridVisible())
            {
                Vector3 pivot;
                if (ProGridsInterface.GetPivot(out pivot))
                {
                    go.transform.position = pivot;
                }
            }
            poly.polyEditMode = PolyShape.PolyEditMode.Path;

            ProBuilderEditor.selectMode = SelectMode.Object;

            m_Tool = EditorToolManager.GetSingleton <PolyShapeTool>();
            ((PolyShapeTool)m_Tool).UpdateTarget(poly);
            ToolManager.SetActiveTool(m_Tool);

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

            MeshSelection.objectSelectionChanged += OnObjectSelectionChanged;

            return(new ActionResult(ActionResult.Status.Success, "Create Poly Shape"));
        }
 protected override ActionResult PerformActionImplementation()
 {
     ProBuilderEditor.selectMode = SelectMode.Object;
     ToolManager.SetActiveTool <DrawShapeTool>();
     return(new ActionResult(ActionResult.Status.Success, "Open Shape Editor"));
 }
Ejemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            switch (polygon.polyEditMode)
            {
            case PolyShape.PolyEditMode.None:
            {
                if (GUILayout.Button("Edit Poly Shape"))
                {
                    ProBuilderEditor.selectMode = SelectMode.Object;
                    polygon.polyEditMode        = PolyShape.PolyEditMode.Edit;
                    PolyShapeTool tool = CreateInstance <PolyShapeTool>();
                    tool.polygon = polygon;
                    ToolManager.SetActiveTool(tool);
                    Undo.RegisterCreatedObjectUndo(tool, "Open Polyshape Tool");
                }

                EditorGUILayout.HelpBox(
                    "Editing a poly shape will erase any modifications made to the mesh!\n\nIf you accidentally enter Edit Mode you can Undo to get your changes back.",
                    MessageType.Warning);

                break;
            }

            case PolyShape.PolyEditMode.Path:
            {
                EditorGUILayout.HelpBox("\nClick To Add Points\n\nPress 'Enter' or 'Space' to Set Height\n", MessageType.Info);
                break;
            }

            case PolyShape.PolyEditMode.Height:
            {
                EditorGUILayout.HelpBox("\nMove Mouse to Set Height\n\nPress 'Enter' or 'Space' to Finalize\n", MessageType.Info);
                break;
            }

            case PolyShape.PolyEditMode.Edit:
            {
                EditorGUILayout.HelpBox("\nMove Poly Shape points to update the shape\n\nPress 'Enter' or 'Space' to Finalize\n", MessageType.Info);
                break;
            }
            }

            EditorGUI.BeginChangeCheck();

            float extrude = polygon.extrude;

            extrude = EditorGUILayout.FloatField("Extrusion", extrude);

            bool flipNormals = polygon.flipNormals;

            flipNormals = EditorGUILayout.Toggle("Flip Normals", flipNormals);

            if (EditorGUI.EndChangeCheck())
            {
                if (polygon.polyEditMode == PolyShape.PolyEditMode.None)
                {
                    if (ProBuilderEditor.instance != null)
                    {
                        ProBuilderEditor.instance.ClearElementSelection();
                    }

                    UndoUtility.RecordComponents <ProBuilderMesh, PolyShape>(polygon.GetComponents(typeof(Component)), "Edit Polygon Shape");
                }
                else
                {
                    UndoUtility.RecordObject(polygon, "Change Polygon Shape Settings");
                }

                polygon.extrude     = extrude;
                polygon.flipNormals = flipNormals;

                RebuildPolyShapeMesh(polygon);
            }
        }