private static void Add(Type type)
        {
            string path = PopupMenuUtility.GetFullLabel(type, GlobalNameSpacePrefix);

            if (string.IsNullOrEmpty(path))
            {
                RegisterComponentHiddenInMenu(type);
                return;
            }

            if (path.StartsWith("UnityEngine/", StringComparison.Ordinal))
            {
                if (path.EndsWith("Effect", StringComparison.Ordinal))
                {
                    path = "Effects" + path.Substring(path.LastIndexOf('/'));
                }
                else if (path.EndsWith("Renderer", StringComparison.Ordinal))
                {
                    path = "Rendering" + path.Substring(path.LastIndexOf('/'));
                }
                else
                {
                    path = "Miscellaneous" + path.Substring(path.LastIndexOf('/'));
                }
            }

            path = StringUtils.SplitPascalCaseToWords(path);
            Add(type, path);
        }
Beispiel #2
0
        private static void Add(Type type)
        {
            string path = PopupMenuUtility.GetFullLabel(type, GlobalNameSpacePrefix);

            if (string.IsNullOrEmpty(path))
            {
                RegisterComponentHiddenInMenu(type);
                return;
            }
            path = StringUtils.SplitPascalCaseToWords(path);
            Add(type, path);
        }
        private void OnCreateInstanceButtonClicked()
        {
            DrawGUI.Use(Event.current);

            var nonUnityObjectTypes = NonUnityObjectTypes;
            int count = nonUnityObjectTypes.Length;

            if (count <= 1)
            {
                if (count == 1)
                {
                    SetValueFromType(nonUnityObjectTypes[0]);
                }
                return;
            }

            if (!menuItemsGenerated || menuItemsGeneratedForType != Type)
            {
                generatedMenuItems.Clear();
                generatedGroupsByLabel.Clear();
                generatedItemsByLabel.Clear();
                for (int n = 0; n < count; n++)
                {
                    PopupMenuUtility.BuildPopupMenuItemForType(ref generatedMenuItems, ref generatedGroupsByLabel, ref generatedItemsByLabel, nonUnityObjectTypes[n]);
                }
                menuItemsGenerated        = true;
                menuItemsGeneratedForType = Type;
            }

            var inspector = InspectorUtility.ActiveInspector;

            PopupMenuManager.Open(inspector, generatedMenuItems, generatedGroupsByLabel, generatedItemsByLabel, ControlPosition, OnPopupMenuItemClicked, OnPopupMenuClosed, GUIContentPool.Create("Type"), this);

            if (!IsNull)
            {
                var selectItemOfType = Value.GetType();
                if (selectItemOfType != null)
                {
                    PopupMenuManager.SelectItem(PopupMenuUtility.GetFullLabel(selectItemOfType));
                }
            }
        }
Beispiel #4
0
 /// <inheritdoc />
 protected override string GetPopupItemLabel(Type value)
 {
     return(PopupMenuUtility.GetFullLabel(value));
 }