예제 #1
0
        protected override void CreateMenu(object sender, AddMenuClickedEventArgs args)
        {
            Type[]      subClasses = EditorReflector.FindSubClasses <Goal>();
            GenericMenu menu       = new GenericMenu();

            for (int i = 0; i < subClasses.Length; i++)
            {
                Type type = subClasses[i];
                if (!EditorReflector.IsDefaultConstructable(type))
                {
                    continue;
                }

                GUIContent content = new GUIContent($"Create {type.Name}");
                menu.AddItem(content, false, CreateGoal, type);
            }
            menu.ShowAsContext();
        }
예제 #2
0
        protected override void CreateMenu(object sender, AddMenuClickedEventArgs args)
        {
            Type[]      subClasses = EditorReflector.FindSubClasses <AIAction>();
            GenericMenu menu       = new GenericMenu();

            for (int i = 0; i < subClasses.Length; i++)
            {
                Type type = subClasses[i];
                if (!EditorReflector.IsDefaultConstructable(type))
                {
                    continue;
                }

                GUIContent content = new GUIContent($"Create {StringUtil.NicifyName(type.Name, "Action")}");

                menu.AddItem(content, false, () => {
                    propertyAsList.AddElement(EditorReflector.MakeInstance(type));
                });
            }
            menu.ShowAsContext();
        }