Exemplo n.º 1
0
        static public GenericMenu Get(params h2Info[] infos)   //selected GOs
        {
            var          menu = new GenericMenu();
            const string cat1 = "Transform/";
            //var cat2 = string.Empty;// "Advanced/";
            const string cat3 = "Setting/";

            h2SceneViewHL.AttachMenu(menu, cat3);
            menu.xAdd("Ping current scene", PingCurrentScene);
            menu.xAdd("Show scene references", ShowSceneReference);
            menu.xAddSep(string.Empty);

            GotoMenu(menu, cat1).xAddSep(cat1);
            TransformMenu(menu, cat1).xAddSep(string.Empty);

#if UNITY_4_3
            Isolate43Menu(menu, "Isolate/");
#endif

            h2GameObjectHL.Menu(menu, "Highlight/");

            //AdvancedMenu(menu, cat2);

            return(menu);
        }
Exemplo n.º 2
0
        /*static GenericMenu AdvancedMenu(GenericMenu menu, string prefix = null) {
         *  bool rp = true;
         *  bool rr = true;
         *  bool rs = true;
         *
         *  if (Selection.gameObjects.Length == 0) {
         *      var t = Selection.gameObjects[0].transform;
         *      rp = t.localPosition != Vector3.zero;
         *      rr = t.localRotation != Quaternion.identity;
         *      rs = t.localScale != Vector3.one;
         *  }
         *
         *  if (prefix == null) prefix = string.Empty;
         *  return menu;
         * }*/


#if UNITY_4_3
        static GenericMenu Isolate43Menu(GenericMenu menu, string prefix = null)
        {
            if (prefix == null)
            {
                prefix = string.Empty;
            }
            var type = "UnityEditorInternal.InternalEditorUtility".xGetTypeByName("UnityEditor");

            //append layers & tags
            var layerPrefix = prefix + "Layer/";
            var layers      = (string[])(type.xGetProperty("layers"));

            for (var i = 0; i < layers.Length; i++)
            {
                var layer = layers[i];                 // prevent scope change in lambda
                menu.xAdd(layerPrefix + layers[i], () => Isolate43.Isolate_Layer(layer));
            }

            var tagPrefix = prefix + "Tag/";
            var tags      = (string[])(type.xGetProperty("tags"));

            for (var i = 0; i < tags.Length; i++)
            {
                var tag = tags[i];                  // prevent scope change in lambda
                menu.xAdd(tagPrefix + tags[i], () => Isolate43.Isolate_Tag(tag));
            }

            return(menu);
        }
Exemplo n.º 3
0
    protected override GenericMenu GetMenu(GameObject go)
    {
        var menu = new GenericMenu();

        menu.xAdd("Deep Active children", () => go.hSetActiveChildren(true, false));
        menu.xAdd("Deep Deactive children", () => go.hSetActiveChildren(false, false));
        return(menu);
    }
Exemplo n.º 4
0
        protected override GenericMenu GetMenu(GameObject go)
        {
            var menu = new GenericMenu();

            menu.xAdd("Deep Lock children", () => go.hSetLock(true, true, "Deep lock children"));
            menu.xAdd("Deep Unlock children", () => go.hSetLock(false, true, "Deep unlock children"));
            return(menu);
        }
Exemplo n.º 5
0
 internal static void ResetContext(Transform t, GenericMenu m, string path)
 {
     m.xAdd(path + "Reset Local Position", () => ResetLocalPosition(t))
     .xAdd(path + "Reset Local Rotation", () => ResetLocalRotation(t))
     .xAdd(path + "Reset Local Scale", () => ResetLocalScale(t))
     .xAdd(path + "Reset Local Transform", () => ResetLocalTransform(t));
 }
Exemplo n.º 6
0
 public static GenericMenu xAddIf(this GenericMenu menu, bool expression, string text, Action func)
 {
     if (expression)
     {
         menu.xAdd(text, func);
     }
     return(menu);
 }
Exemplo n.º 7
0
    internal static void Context_Isolate(GenericMenu menu, GameObject go, string category = "Isolate/")
    {
        //if (missingCount > 0) {
        //menu.xAdd(category + "Missing Behaviours [" + missingCount +"] &M", () => Isolate_MissingBehaviours());
        //}

        //menu.xAdd(category + "Has Behaviour &B", () => h2Api.Isolate_ObjectsHasScript());
        if (Selection.instanceIDs.Length > 1)
        {
            menu.xAdd(category + "Selected Objects &S", () => Isolate_SelectedObjects());
        }
        menu.xAddSep(category);
        menu.xAdd(category + "Locked Objects &L", () => Isolate_LockedObjects());
        menu.xAdd(category + "InActive Objects &I", () => Isolate_InActiveObjects());
        menu.xAdd(category + "Combined Objects &Y", () => Isolate_CombinedObjects());
        menu.xAddSep(category);
    }
Exemplo n.º 8
0
        static GenericMenu GotoMenu(GenericMenu menu, string prefix = null)
        {
            if (prefix == null)
            {
                prefix = string.Empty;
            }

            menu.xAdd(prefix + "✪  GO TO", null)
            .xAddSep(prefix)
            .xAdd(prefix + "Parent " + h2Shortcut.GOTO_PARENT, h2Goto.cmdPingParent)
            .xAdd(prefix + "Child " + h2Shortcut.GOTO_CHILD, h2Goto.cmdPingChild)
            .xAdd(prefix + "Next Sibling " + h2Shortcut.GOTO_SIBLING, h2Goto.cmdNextSibling);
            return(menu);
        }
Exemplo n.º 9
0
        //static Action noAction = null;

        static GenericMenu TransformMenu(GenericMenu menu, string prefix = null)
        {
            /* bool rp = true;
             * bool rr = true;
             * bool rs = true;
             *
             * if (h2Info2.SelectionCount == 0) {
             *   var t = Selection.activeGameObject.transform;
             *   rp = t.localPosition != Vector3.zero;
             *   rr = t.localRotation != Quaternion.identity;
             *   rs = t.localScale != Vector3.one;
             * }*/

            if (prefix == null)
            {
                prefix = string.Empty;
            }

            menu.xAdd(prefix + "✪  CREATE", null, true)
            .xAddSep(prefix)
            .xAdd(prefix + "Empty Child " + h2Shortcut.NEW_CHILD, h2Transform.cmdNewChild)
            .xAdd(prefix + "Empty Parent " + h2Shortcut.NEW_PARENT, h2Transform.cmdNewParent)
            .xAdd(prefix + "Empty Sibling " + h2Shortcut.NEW_SIBLING, h2Transform.cmdNewSibling)
            .xAddSep(prefix)
            .xAdd(prefix + "✪  RESET", null, true)
            .xAddSep(prefix)
            .xAdd(prefix + "Local Position " + h2Shortcut.RESET_LOCAL_POSITION, h2Transform.cmdResetPosition)
            .xAdd(prefix + "Local Rotation " + h2Shortcut.RESET_LOCAL_ROTATION, h2Transform.cmdResetRotation)
            .xAdd(prefix + "Local Scale " + h2Shortcut.RESET_LOCAL_SCALE, h2Transform.cmdResetScale)
            .xAddSep(prefix)
            .xAdd(prefix + "Transform " + h2Shortcut.RESET_LOCAL_TRANSFORM, h2Transform.cmdResetTransform)
            //.xAddSep(prefix)
            //.xAdd(prefix + "✪  RESET (FREEZE CHILDREN)", null, true)
            //.xAddSep(prefix)
            //.xAdd(prefix + "Local Position " + h2Shortcut.FREEZE_CHILDREN_RESET_LOCAL_POSITION, rp ? h2Transform.cmdResetPosition : noAction)
            //.xAdd(prefix + "Local Rotation " + h2Shortcut.FREEZE_CHILDREN_RESET_LOCAL_ROTATION, rr ? h2Transform.cmdResetRotation : noAction)
            //.xAdd(prefix + "Local Scale " + h2Shortcut.FREEZE_CHILDREN_RESET_LOCAL_SCALE, rs ? h2Transform.cmdResetScale : noAction)
            //.xAddSep(prefix)
            //.xAdd(prefix + "Local Transform " + h2Shortcut.FREEZE_CHILDREN_RESET_LOCAL_TRANSFORM, (rp || rr || rs) ? h2Transform.cmdResetTransform : noAction)
            ;
            return(menu);
        }
Exemplo n.º 10
0
        public bool Draw(Rect rect)
        {
            GUI.Label(rect, SelectedLabels[activeIdx]);
            if (rect.xLMB_isDown().noModifier)
            {
                var menu = new GenericMenu();

                for (var i = 0; i < Labels.Length; i++)
                {
                    var idx = i;

                    menu.xAdd(Labels[i], () => {
                        activeIdx = idx;
                    }, i == activeIdx);
                }

                Event.current.Use();
                menu.ShowAsContext();
            }
            return(false);
        }
Exemplo n.º 11
0
        static internal GenericMenu Menu(GenericMenu menu, string prefix = null)
        {
            if (prefix == null)
            {
                prefix = string.Empty;
            }

            menu.xAdd(prefix + "Clear " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR0, cmdClearHL)
            .xAddSep(prefix)
            .xAdd(prefix + "Color 1 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR1, cmdSetHL1)
            .xAdd(prefix + "Color 2 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR2, cmdSetHL2)
            .xAdd(prefix + "Color 3 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR3, cmdSetHL3)
            .xAdd(prefix + "Color 4 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR4, cmdSetHL4)
            .xAdd(prefix + "Color 5 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR5, cmdSetHL5)
            .xAdd(prefix + "Color 6 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR6, cmdSetHL6)
            .xAdd(prefix + "Color 7 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR7, cmdSetHL7)
            .xAdd(prefix + "Color 8 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR8, cmdSetHL8)
            .xAdd(prefix + "Color 9 " + h2Shortcut.HIGHLIGHT_GAMEOBJECT_COLOR9, cmdSetHL9);

            return(menu);
        }
Exemplo n.º 12
0
        internal void Draw(Action <string, string> onSearch)
        {
            var evt = Event.current;

            GUI.BeginGroup(rect, "", EditorStyles.toolbar);
            //GUILayout.BeginHorizontal();
            //GUILayoutUtility.GetRect(rect.width, rect.height);
            //GUILayout.EndHorizontal();

            if (TextFieldStyle == null)
            {
                TextFieldStyle  = new GUIStyle("ToolbarSeachTextFieldPopup");        // {fixedHeight = 14f};
                CloseBtnStyle   = new GUIStyle("ToolbarSeachCancelButton");
                EmptyBtnStyle   = new GUIStyle("ToolbarSeachCancelButtonEmpty");
                ToolbarBtnStyle = new GUIStyle(EditorStyles.toolbarPopup)
                {
                    fixedWidth = CatWidth                                                                /*, alignment = TextAnchor.MiddleCenter*/
                };
            }

            var r2 = rect.dw(-CatWidth - 10f);

            GUI.SetNextControlName(gID);
            if (gainFocus)
            {
                GUI.FocusControl(gID);
                EditorGUI.FocusTextInControl(gID);

                if (focus && evt.type == EventType.repaint)
                {
                    gainFocus = false;
                }
            }

            focus = GUI.GetNameOfFocusedControl() == gID;

            if (focus)
            {
                //ESC is down without any modifier
                if (evt.type == EventType.KeyDown)
                {
                    Debug.Log("--->" + evt.keyCode);
                }

                if (KeyCode.Escape.xKey_isDown().noModifier)
                {
                    StopSearch();
                }
                if (KeyCode.Return.xKey_isDown().noModifier&& !string.IsNullOrEmpty(SearchTerm))
                {
                    if (onSearch != null)
                    {
                        onSearch(SearchTerm, CategoryList[Category]);
                    }
                    else
                    {
                        Debug.Log(string.Format("Search for <{0}> has no handler", SearchTerm));
                    }

                    Event.current.Use();
                }
            }
            else
            {
                //normal click without any modifier
                if (rect.xLMB_isDown().noModifier)
                {
                    StartSearch();
                }
                //TODO : Support Validate / ExecuteCommand
                //if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "Find") {
                //	Event.current.Use();
                //	return;
                //} else if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "Find") {
                //	focusSearchBox = true;
                //}
            }

            SearchTerm = EditorGUI.TextField(r2.dw(-20f), SearchTerm ?? "", TextFieldStyle);

            if (GUI.Button(r2.xHzSubRectsRight(20f)[0], string.Empty, SearchTerm == string.Empty ? EmptyBtnStyle : CloseBtnStyle))
            {
                StopSearch();
            }

            EditorGUI.BeginChangeCheck();
            GUI.Button(r2.xSlide(1f).dy(-2).w(CatWidth), CategoryTitle ?? (CategoryTitle = CategoryList[Category].Split('&')[0]), ToolbarBtnStyle);

            if (EditorGUI.EndChangeCheck())
            {
                var cm = new GenericMenu();
                for (var i = 0; i < CategoryList.Length; i++)
                {
                    var idx = i;
                    cm.xAdd(CategoryList[i], () => SetCategory(idx));
                }
                cm.ShowAsContext();
                //EditorUtility.DisplayCustomMenu(r2, CategoryList.ToGUIContent(), Category, null, null);
            }

            GUI.EndGroup();
        }
Exemplo n.º 13
0
        internal static void AttachMenu(GenericMenu m, string prefix)
        {
            var isHL = h2Settings.useSceneViewHL;

            m.xAdd("Highlight SceneView", isHL ? StopMonitor : (Action)StartMonitor, isHL);
        }