예제 #1
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.activeToolChanged      += OnActiveToolChanged;
            ProBuilderEditor.selectModeChanged += OnSelectModeChanged;

            MeshSelection.objectSelectionChanged += OnObjectSelectionChanged;

            return(new ActionResult(ActionResult.Status.Success, "Create Poly Shape"));
        }
예제 #2
0
        public void CreateShapeFromPolygon_ExtrudeOrNot()
        {
            m_Poly.m_Points.Add(new Vector3(0, 0, 0));
            m_Poly.m_Points.Add(new Vector3(0, 0, 2));
            m_Poly.m_Points.Add(new Vector3(2, 0, 0));
            m_Poly.extrude     = 0.0f;
            m_Poly.flipNormals = false;
            m_pb.CreateShapeFromPolygon(m_Poly.m_Points, m_Poly.extrude, m_Poly.flipNormals);

            Assert.That(m_pb.faceCount, Is.EqualTo(1));
            m_pb.Clear();
            Assert.That(m_pb.faceCount, Is.EqualTo(0));
            m_Poly.extrude = 1.0f;
            m_pb.CreateShapeFromPolygon(m_Poly.m_Points, m_Poly.extrude, m_Poly.flipNormals);
            Assert.That(m_pb.faceCount, Is.EqualTo(5));
        }
예제 #3
0
        public bool CreateShapeFromPolygon(IList <Vector3> points, float extrude, bool flipNormals)
        {
            ActionResult result = m_pbMesh.CreateShapeFromPolygon(points, extrude, flipNormals);

            return(result.ToBool());
        }