bool GeoLevelShortcuts(Shortcut shortcut)
        {
            switch (shortcut.action)
            {
            case "Escape":
                ClearElementSelection();
                EditorUtility.ShowNotification("Top Level");
                UpdateSelection();
                selectMode = SelectMode.Object;
                return(true);

            // Used to be (incorrectly) named handle pivot, and since shortcuts are serialized this value is still valid
            case "Toggle Handle Pivot":
            case "Toggle Handle Orientation":
                VertexManipulationTool.handleOrientation = InternalUtility.NextEnumValue(VertexManipulationTool.handleOrientation);
                return(true);

            // TODO Remove once a workaround for non-upper-case shortcut chars is found
            case "Toggle Selection Mode":
                if (s_UniqueModeShortcuts)
                {
                    return(false);
                }
                ToggleSelectionMode();
                EditorUtility.ShowNotification(selectMode.ToString());
                return(true);

            case "Delete Face":
                EditorUtility.ShowNotification(EditorToolbarLoader.GetInstance <DeleteFaces>().DoAction().notification);
                return(true);

            case "Set Pivot":

                if (selection.Count > 0)
                {
                    foreach (ProBuilderMesh pbo in selection)
                    {
                        UndoUtility.RecordObjects(new UObject[2] {
                            pbo, pbo.transform
                        }, "Set Pivot");

                        if (pbo.selectedIndexesInternal.Length > 0)
                        {
                            pbo.CenterPivot(pbo.selectedIndexesInternal);
                        }
                        else
                        {
                            pbo.CenterPivot(null);
                        }
                    }

                    EditorUtility.ShowNotification("Set Pivot");
                }

                return(true);

            default:
                return(false);
            }
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            if (pb == null)
            {
                return;
            }
            if (ent == null)
            {
                return;
            }

            EntityType et = ent.entityType;

            et = (EntityType)EditorGUILayout.EnumPopup("Entity Type", et);
            if (et != ent.entityType)
            {
                UndoUtility.RecordObjects(new Object[] { ent, ent.gameObject.GetComponent <ProBuilderMesh>() }, "Set Entity Type");
#pragma warning disable 0618
                EntityUtility.SetEntityType(et, ent.gameObject);
#pragma warning restore 0618
                pb.ToMesh();
                pb.Refresh();
                pb.Optimize();
            }

            GUILayout.Space(4);

            pb.userCollisions = EditorGUILayout.Toggle("Custom Collider", pb.userCollisions);

            // Convience
            if (pb.userCollisions)
            {
                GUI.enabled = false;
            }

            GUILayout.Label("Add Collider", EditorStyles.boldLabel);
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Mesh Collider", EditorStyles.miniButtonLeft))
            {
                EditorApplication.delayCall += AddMeshCollider;
            }

            if (GUILayout.Button("Box Collider", EditorStyles.miniButtonMid))
            {
                EditorApplication.delayCall += AddBoxCollider;
            }

            if (GUILayout.Button("Remove Collider", EditorStyles.miniButtonRight))
            {
                EditorApplication.delayCall += RemoveColliders;
            }


            GUILayout.EndHorizontal();

            GUI.enabled = true;
        }