Exemplo n.º 1
0
        void DrawShapeGUI()
        {
            if (m_BoldCenteredStyle == null)
            {
                m_BoldCenteredStyle = new GUIStyle("BoldLabel")
                {
                    alignment = TextAnchor.MiddleCenter
                }
            }
            ;

            EditorGUILayout.LabelField(EditorShapeUtility.shapeTypes[s_ActiveShapeIndex.value], m_BoldCenteredStyle, GUILayout.ExpandWidth(true));

            if (EditorShapeUtility.s_ResetUserPrefs.value)
            {
                ResetPrefs();
            }

            var shape = currentShapeInOverlay.shape;

            int groupCount = EditorShapeUtility.shapeTypesGUI.Count;

            for (int i = 0; i < groupCount; i++)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                int index = GUILayout.Toolbar(s_ActiveShapeIndex.value - +i * EditorShapeUtility.MaxContentPerGroup, EditorShapeUtility.shapeTypesGUI[i], Styles.command);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                if (EditorGUI.EndChangeCheck())
                {
                    s_ActiveShapeIndex.value = index + i * EditorShapeUtility.MaxContentPerGroup;

                    var type = EditorShapeUtility.availableShapeTypes[s_ActiveShapeIndex];
                    if (shape.GetType() != type)
                    {
                        if (currentShapeInOverlay == m_LastShapeCreated)
                        {
                            m_LastShapeCreated = null;
                        }

                        UndoUtility.RegisterCompleteObjectUndo(currentShapeInOverlay, "Change Shape");
                        Selection.activeObject = null;
                        currentShapeInOverlay.SetShape(EditorShapeUtility.CreateShape(type), currentShapeInOverlay.pivotLocation);
                        SetBounds(currentShapeInOverlay.size);

                        ProBuilderEditor.Refresh();
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
        void ResetPrefs()
        {
            var type = EditorShapeUtility.availableShapeTypes[s_ActiveShapeIndex];

            if (currentShapeInOverlay == m_LastShapeCreated)
            {
                m_LastShapeCreated = null;
            }

            UndoUtility.RegisterCompleteObjectUndo(currentShapeInOverlay, "Change Shape");
            currentShapeInOverlay.SetShape(EditorShapeUtility.CreateShape(type), currentShapeInOverlay.pivotLocation);
            SetBounds(currentShapeInOverlay.size);

            ProBuilderEditor.Refresh();
        }
        protected void BeginEdit(string undoMessage)
        {
            if (m_IsEditing)
            {
                return;
            }

            // Disable iterative lightmapping
            Lightmapping.PushGIWorkflowMode();

            var selection = MeshSelection.topInternal.ToArray();

            UndoUtility.RegisterCompleteObjectUndo(selection, string.IsNullOrEmpty(undoMessage) ? "Modify Vertices" : undoMessage);

            if (beforeMeshModification != null)
            {
                beforeMeshModification(selection);
            }

            if (currentEvent.shift)
            {
                Extrude();
            }

            m_IsEditing = true;

            m_WorldSnapEnabled   = ProBuilderSnapSettings.snapMode == SnapMode.World;
            m_SnapAxisConstraint = ProBuilderSnapSettings.snapMethod == SnapAxis.ActiveAxis; ProGridsInterface.UseAxisConstraints();
            m_MoveSnapValue      = m_WorldSnapEnabled ? ProBuilderSnapSettings.worldSnapMoveValue : ProBuilderSnapSettings.incrementalSnapMoveValue;

            foreach (var mesh in selection)
            {
                mesh.ToMesh();
                mesh.Refresh();
            }

            OnToolEngaged();
        }
Exemplo n.º 4
0
        protected void BeginEdit(string undoMessage)
        {
            if (m_IsEditing)
            {
                return;
            }

            // Disable iterative lightmapping
            Lightmapping.PushGIWorkflowMode();

            var selection = MeshSelection.topInternal.ToArray();

            UndoUtility.RegisterCompleteObjectUndo(selection, string.IsNullOrEmpty(undoMessage) ? "Modify Vertices" : undoMessage);

            if (beforeMeshModification != null)
            {
                beforeMeshModification(selection);
            }

            if (currentEvent.shift)
            {
                Extrude();
            }

            m_IsEditing = true;

            m_SnapAxisConstraint = EditorSnapping.snapMethod == SnapAxis.ActiveAxis;

            foreach (var mesh in selection)
            {
                mesh.ToMesh();
                mesh.Refresh();
            }

            OnToolEngaged();
        }