Ejemplo n.º 1
0
        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);
            }
        }
        static void MenuPerform_ProBuilderize()
        {
            var instance = EditorToolbarLoader.GetInstance <ProBuilderize>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
            }
        }
        static void MenuPerform_ConformObjectNormals()
        {
            var instance = EditorToolbarLoader.GetInstance <ConformObjectNormals>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
            }
        }
        static void MenuPerform_ToggleXRay()
        {
            var instance = EditorToolbarLoader.GetInstance <ToggleXRay>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
            }
        }
        static void MenuPerform_OffsetElements()
        {
            var instance = EditorToolbarLoader.GetInstance <OffsetElements>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
            }
        }
        static void MenuPerform_DuplicateFaces()
        {
            var instance = EditorToolbarLoader.GetInstance <DuplicateFaces>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
            }
        }
        static void MenuPerform_OpenShapeEditorMenuItem()
        {
            var instance = EditorToolbarLoader.GetInstance <OpenShapeEditorMenuItem>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
            }
        }
        static void MenuPerform_SubdivideObject()
        {
            var instance = EditorToolbarLoader.GetInstance <SubdivideObject>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
            }
        }
        static void MenuPerform_NewPolyShape()
        {
            var instance = EditorToolbarLoader.GetInstance <NewPolyShapeToggle>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 10
0
        static void MenuPerform_MirrorObjects()
        {
            var instance = EditorToolbarLoader.GetInstance <MirrorObjects>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 11
0
        static void MenuPerform_CenterPivot()
        {
            var instance = EditorToolbarLoader.GetInstance <CenterPivot>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 12
0
        static void MenuPerform_FreezeTransform()
        {
            var instance = EditorToolbarLoader.GetInstance <FreezeTransform>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 13
0
        static void MenuPerform_InsertEdgeLoop()
        {
            var instance = EditorToolbarLoader.GetInstance <InsertEdgeLoop>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 14
0
        static void MenuPerform_ToggleSelectBackFaces()
        {
            var instance = EditorToolbarLoader.GetInstance <ToggleSelectBackFaces>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 15
0
        static void MenuPerform_CollapseVertices()
        {
            var instance = EditorToolbarLoader.GetInstance <CollapseVertices>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 16
0
        static void MenuPerform_FlipFaceNormals()
        {
            var instance = EditorToolbarLoader.GetInstance <FlipFaceNormals>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 17
0
        static void MenuPerform_TriangulateObject()
        {
            var instance = EditorToolbarLoader.GetInstance <TriangulateObject>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 18
0
        static void MenuPerform_ExportStlBinary()
        {
            var instance = EditorToolbarLoader.GetInstance <ExportStlBinary>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
        static void MenuPerform_SelectSmoothingGroup()
        {
            var instance = EditorToolbarLoader.GetInstance <SelectSmoothingGroup>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
            }
        }
Ejemplo n.º 20
0
        static void MenuPerform_OpenMaterialEditor()
        {
            var instance = EditorToolbarLoader.GetInstance <OpenMaterialEditor>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 21
0
        static void MenuPerform_SelectHole()
        {
            var instance = EditorToolbarLoader.GetInstance <SelectHole>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.DoAction().notification);
            }
        }
Ejemplo n.º 22
0
        static void ToggleUseElementBounds()
        {
            s_AlwaysUseObjectBounds.SetValue(!s_AlwaysUseObjectBounds.value, true);

            if (s_Instance != null)
            {
                s_Instance.RebuildBounds();
                EditorUtility.ShowNotification("Dimensions Overlay\n" + (s_AlwaysUseObjectBounds.value ? "Object" : "Element"));
            }
        }
        static void MenuPerform_NewPolyShape()
        {
            var instance = EditorToolbarLoader.GetInstance <NewPolyShapeToggle>();

            if (instance != null && instance.enabled)
            {
                var result = ToolManager.IsActiveTool(instance.Tool) ? instance.EndActivation() : instance.StartActivation();
                EditorUtility.ShowNotification(result.notification);
            }
        }
        void DoSelectedAction()
        {
            if (m_SelectedIndex > -1 && m_SelectedIndex < m_Results.Count)
            {
                var action = m_Results[m_SelectedIndex].action;
                EditorUtility.ShowNotification(action.PerformAction().notification);
            }

            Close();
        }
        static void MenuPerform_TriangulateObject()
        {
            var instance = EditorToolbarLoader.GetInstance <TriangulateObject>();

            if (instance != null && instance.enabled)
            {
                EditorUtility.ShowNotification(instance.PerformAction().notification);
                ProBuilderAnalytics.SendActionEvent(instance, ProBuilderAnalytics.TriggerType.MenuOrShortcut);
            }
        }
        static void Extrude()
        {
            int ef = 0;

            var selection  = MeshSelection.topInternal;
            var selectMode = ProBuilderEditor.selectMode;

            foreach (var mesh in selection)
            {
                switch (selectMode)
                {
                case SelectMode.Edge:
                    if (mesh.selectedFaceCount > 0)
                    {
                        goto default;
                    }

                    Edge[] newEdges = mesh.Extrude(mesh.selectedEdges,
                                                   0.0001f,
                                                   s_ExtrudeEdgesAsGroup,
                                                   ProBuilderEditor.s_AllowNonManifoldActions);

                    if (newEdges != null)
                    {
                        ef += newEdges.Length;
                        mesh.SetSelectedEdges(newEdges);
                    }
                    break;

                default:
                    int len = mesh.selectedFacesInternal.Length;

                    if (len > 0)
                    {
                        mesh.Extrude(mesh.selectedFacesInternal, s_ExtrudeMethod, 0.0001f);
                        mesh.SetSelectedFaces(mesh.selectedFacesInternal);
                        ef += len;
                    }

                    break;
                }

                mesh.ToMesh();
                mesh.Refresh();
            }

            if (ef > 0)
            {
                EditorUtility.ShowNotification("Extrude");
                ProBuilderEditor.Refresh();
            }
        }
Ejemplo n.º 27
0
        bool AllLevelShortcuts(Shortcut shortcut)
        {
            switch (shortcut.action)
            {
            // TODO Remove once a workaround for non-upper-case shortcut chars is found
            case "Toggle Geometry Mode":

                if (selectMode == SelectMode.Object)
                {
                    selectMode = m_LastComponentMode;
                }
                else
                {
                    selectMode = SelectMode.Object;
                }
                EditorUtility.ShowNotification(selectMode.ToString() + " Editing");
                return(true);

            case "Vertex Mode":
            {
                if (!s_UniqueModeShortcuts)
                {
                    return(false);
                }
                selectMode = SelectMode.Vertex;
                return(true);
            }

            case "Edge Mode":
            {
                if (!s_UniqueModeShortcuts)
                {
                    return(false);
                }
                selectMode = SelectMode.Edge;
                return(true);
            }

            case "Face Mode":
            {
                if (!s_UniqueModeShortcuts)
                {
                    return(false);
                }
                selectMode = SelectMode.Face;
                return(true);
            }

            default:
                return(false);
            }
        }
Ejemplo n.º 28
0
        void DoubleClick(Event e)
        {
            var mesh = EditorSceneViewPicker.DoMouseClick(m_CurrentEvent, selectMode, m_ScenePickerPreferences);

            if (mesh != null)
            {
                if (selectMode.ContainsFlag(SelectMode.Edge | SelectMode.TextureEdge))
                {
                    if (e.shift)
                    {
                        EditorUtility.ShowNotification(EditorToolbarLoader.GetInstance <Actions.SelectEdgeRing>().DoAction());
                    }
                    else
                    {
                        EditorUtility.ShowNotification(EditorToolbarLoader.GetInstance <Actions.SelectEdgeLoop>().DoAction());
                    }
                }
                else if (selectMode.ContainsFlag(SelectMode.Face | SelectMode.TextureFace))
                {
                    if ((e.modifiers & (EventModifiers.Control | EventModifiers.Shift)) ==
                        (EventModifiers.Control | EventModifiers.Shift))
                    {
                        Actions.SelectFaceRing.MenuRingAndLoopFaces(MeshSelection.topInternal);
                    }
                    else if (e.control)
                    {
                        EditorUtility.ShowNotification(EditorToolbarLoader.GetInstance <Actions.SelectFaceRing>().DoAction());
                    }
                    else if (e.shift)
                    {
                        EditorUtility.ShowNotification(EditorToolbarLoader.GetInstance <Actions.SelectFaceLoop>().DoAction());
                    }
                    else
                    {
                        mesh.SetSelectedFaces(mesh.facesInternal);
                    }
                }
                else
                {
                    mesh.SetSelectedFaces(mesh.facesInternal);
                }

                UpdateSelection();
                SceneView.RepaintAll();
                m_WasDoubleClick = true;
            }
        }
        static void doit()
        {
            if (File.Exists(k_GeneratedFilePath))
            {
                File.Delete(k_GeneratedFilePath);
            }

            StringBuilder sb = new StringBuilder();

            IEnumerable <string> actions = Directory.GetFiles(k_MenuActionsFolder, "*.cs", SearchOption.AllDirectories)
                                           .Select(x => x.Replace("\\", "/"))
                                           .Where(y => !IgnoreActions.Contains(GetClassName(y)));

            sb.AppendLine(
                @"/**
 *  IMPORTANT
 *
 *  This is a generated file. Any changes will be overwritten.
 *  See Debug/GenerateMenuItems to make modifications.
 */

using UnityEngine;
using UnityEditor;
using UnityEngine.ProBuilder;
using UnityEditor.ProBuilder.Actions;
using System.Collections.Generic;

namespace UnityEditor.ProBuilder
{
    static class EditorToolbarMenuItem
    {
        const string k_MenuPrefix = ""Tools/ProBuilder/"";
");
            foreach (string action in actions)
            {
                sb.AppendLine(GenerateMenuItemFunctions(action));
            }

            sb.AppendLine("\t}");
            sb.AppendLine("}");

            File.WriteAllText(k_GeneratedFilePath, sb.ToString().Replace("\r\n", "\n"));
            EditorUtility.ShowNotification("Successfully Generated\nMenu Items");

            AssetDatabase.Refresh();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Applies the currently queued material to the selected face and eats the event.
        /// </summary>
        /// <param name="em"></param>
        /// <param name="pb"></param>
        /// <param name="quad"></param>
        /// <returns></returns>
        public bool ClickShortcutCheck(EventModifiers em, ProBuilderMesh pb, Face quad)
        {
            if (UVEditor.instance == null)
            {
                if (em == (EventModifiers.Control | EventModifiers.Shift))
                {
                    UndoUtility.RecordObject(pb, "Quick Apply");
                    quad.material = m_QueuedMaterial;
                    pb.ToMesh();
                    pb.Refresh();
                    pb.Optimize();
                    EditorUtility.ShowNotification("Quick Apply Material");
                    return(true);
                }
            }

            return(false);
        }