Beispiel #1
0
        static void Init()
        {
            menu = new GenericMenu();

            Assembly asm = Assembly.GetAssembly(typeof(Node));

            Type[] types = asm.GetTypes();

            List <MenuTypeDesc> menu_types = new List <MenuTypeDesc> ();

            foreach (Type t in types)
            {
                object[] attrs = t.GetCustomAttributes(false);
                if (attrs != null && attrs.Length > 0)
                {
                    MenuAttribute attr = attrs[0] as MenuAttribute;
                    if (attr != null)
                    {
                        MenuTypeDesc desc = new MenuTypeDesc();
                        desc.name  = attr.Name;
                        desc.order = attr.Order;
                        desc.type  = t;
                        menu_types.Add(desc);
                    }
                }
            }

            menu_types.Sort(MenuTypeDesc.Compare);

            foreach (MenuTypeDesc desc in menu_types)
            {
                Type t = desc.type;
                if (t.IsSubclassOf(typeof(OutputNode)))
                {
                    if (t == CameraForgeWindow.modifier.output.GetType())
                    {
                        menu.AddItem(new GUIContent("Output Type/" + desc.name), true, () => {});
                    }
                    else
                    {
                        menu.AddItem(new GUIContent("Output Type/" + desc.name), false, MenuFunc, t);
                    }
                }
                else
                {
                    menu.AddItem(new GUIContent("Add Node/" + desc.name), false, MenuFunc, t);
                }
            }

            delete_menu = new GenericMenu();
            delete_menu.AddItem(new GUIContent("Delete"), false, () => { CameraForgeWindow.modifier.DeleteNode(del_node); });

            inited = true;
        }
Beispiel #2
0
 public static int Compare(MenuTypeDesc lhs, MenuTypeDesc rhs)
 {
     return(lhs.order - rhs.order);
 }
Beispiel #3
0
        static void Init()
        {
            menu = new GenericMenu();

            Assembly asm = Assembly.GetAssembly(typeof(Node));

            Type[] types = asm.GetTypes();

            List <MenuTypeDesc> menu_types = new List <MenuTypeDesc> ();

            foreach (Type t in types)
            {
                object[] attrs = t.GetCustomAttributes(false);
                if (attrs != null && attrs.Length > 0)
                {
                    MenuAttribute attr = attrs[0] as MenuAttribute;
                    if (attr != null)
                    {
                        MenuTypeDesc desc = new MenuTypeDesc();
                        desc.name  = attr.Name;
                        desc.order = attr.Order;
                        desc.type  = t;
                        menu_types.Add(desc);
                    }
                }
            }

            menu_types.Sort(MenuTypeDesc.Compare);

            foreach (MenuTypeDesc desc in menu_types)
            {
                Type t = desc.type;
                if (!t.IsSubclassOf(typeof(OutputNode)))
                {
                    menu.AddItem(new GUIContent("Add Node/" + desc.name), false, MenuFunc, t);
                }
            }

            foreach (Type t in types)
            {
                if (t.IsAbstract)
                {
                    continue;
                }
                if (t.IsSubclassOf(typeof(MediaPoseNode)))
                {
                    menu.AddItem(new GUIContent("Add Pose Node/Variable/" + t.Name), false, MenuFunc, t);
                }
                else if (t == typeof(Modifier))
                {
                    menu.AddItem(new GUIContent("Add Modifier"), false, MenuFunc, t);
                }
                else if (t.IsSubclassOf(typeof(ScriptModifier)))
                {
                    menu.AddItem(new GUIContent("Add Script Modifier/" + t.Name), false, MenuFunc, t);
                }
                else if (t.IsSubclassOf(typeof(PoseNode)) && t != typeof(FinalPose) && t != typeof(Controller))
                {
                    menu.AddItem(new GUIContent("Add Pose Node/" + t.Name), false, MenuFunc, t);
                }
            }

            delete_menu = new GenericMenu();

            delete_menu.AddItem(new GUIContent("Delete"), false, () =>
            {
                if (del_node != null)
                {
                    CameraForgeWindow.controller.DeleteNode(del_node);
                }
                else if (del_pose_node != null)
                {
                    CameraForgeWindow.controller.DeletePoseNode(del_pose_node);
                }

                del_node      = null;
                del_pose_node = null;
            });

            inited = true;
        }