Exemple #1
0
        public Color GetNodeBackgroundColorByCategory(NodeCategoryType p_category)
        {
            switch (p_category)
            {
            case NodeCategoryType.EVENT:
                return(EventNodeBackgroundColor);

            case NodeCategoryType.ANIMATION:
                return(AnimationNodeBackgroundColor);

            case NodeCategoryType.MODIFIER:
                return(ModifierNodeBackgroundColor);

            case NodeCategoryType.CREATION:
                return(CreationNodeBackgroundColor);

            case NodeCategoryType.GRAPH:
                return(GraphNodeBackgroundColor);

            case NodeCategoryType.LOGIC:
                return(LogicNodeBackgroundColor);
            }

            return(Color.white);
        }
Exemple #2
0
        public Color GetNodeTitleTextColorByCategory(NodeCategoryType p_category)
        {
            switch (p_category)
            {
            case NodeCategoryType.EVENT:
                return(EventNodeTitleTextColor);

            case NodeCategoryType.ANIMATION:
                return(AnimationNodeTitleTextColor);

            case NodeCategoryType.MODIFIER:
                return(ModifierNodeTitleTextColor);

            case NodeCategoryType.CREATION:
                return(CreationNodeTitleTextColor);

            case NodeCategoryType.GRAPH:
                return(GraphNodeTitleTextColor);

            case NodeCategoryType.LOGIC:
                return(LogicNodeTitleTextColor);
            }

            return(new Color(.9f, .9f, 1f));
        }
Exemple #3
0
        public Texture GetNodeIconByCategory(NodeCategoryType p_category)
        {
            switch (p_category)
            {
            case NodeCategoryType.EVENT:
                return(EventNodeIcon);

            case NodeCategoryType.ANIMATION:
                return(AnimationNodeIcon);

            case NodeCategoryType.MODIFIER:
                return(ModifierNodeIcon);

            case NodeCategoryType.CREATION:
                return(CreationNodeIcon);

            case NodeCategoryType.LOGIC:
                return(LogicNodeIcon);
            }

            return(null);
        }
Exemple #4
0
        static public RuntimeGenericMenu Get()
        {
            RuntimeGenericMenu menu = new RuntimeGenericMenu();

            if (DashEditorCore.EditorConfig.editingGraph != null)
            {
                Type[] nodeTypes = ReflectionUtils.GetAllTypes(typeof(NodeBase)).ToArray();
                Array.Sort(nodeTypes, CategorySort);
                foreach (Type type in nodeTypes)
                {
                    if (IsObsolete(type) && !DashEditorCore.EditorConfig.showObsolete)
                    {
                        continue;
                    }

                    if (IsExperimental(type) && !DashEditorCore.EditorConfig.showExperimental)
                    {
                        continue;
                    }

                    if (IsHidden(type))
                    {
                        continue;
                    }

                    if (CheckMultiple(type))
                    {
                        continue;
                    }

                    TooltipAttribute tooltipAttribute = type.GetCustomAttribute <TooltipAttribute>();
                    string           tooltip          = tooltipAttribute != null ? tooltipAttribute.help : "";

                    CategoryAttribute attribute      = type.GetCustomAttribute <CategoryAttribute>();
                    NodeCategoryType  category       = attribute == null ? NodeCategoryType.OTHER : attribute.type;
                    string            categoryString = category.ToString();
                    categoryString = categoryString.Substring(0, 1) + categoryString.Substring(1).ToLower();

                    string node = type.ToString().Substring(type.ToString().IndexOf(".") + 1);
                    node = node.Substring(0, node.Length - 4);

                    if (category == NodeCategoryType.GRAPH)
                    {
                        menu.AddItem(new GUIContent(node, tooltip), false, CreateNode, type);
                    }
                    else
                    {
                        menu.AddItem(new GUIContent(categoryString + "/" + node, tooltip), false, CreateNode,
                                     type);
                    }
                }

                if (SelectionManager.HasCopiedNodes())
                {
                    menu.AddItem(new GUIContent("Paste Nodes"), false, PasteNodes);
                }

                menu.AddSeparator("");
                Transform[] selectedTransforms = SelectionUtils.GetTransformsFromSelection();
                if (selectedTransforms.Length > 0)
                {
                    foreach (Type type in nodeTypes)
                    {
                        CategoryAttribute attribute = type.GetCustomAttribute <CategoryAttribute>();
                        if (attribute == null || attribute.type != NodeCategoryType.ANIMATION)
                        {
                            continue;
                        }

                        TooltipAttribute tooltipAttribute = type.GetCustomAttribute <TooltipAttribute>();
                        string           tooltip          = tooltipAttribute != null ? tooltipAttribute.help : "";

                        string node = type.ToString().Substring(type.ToString().IndexOf(".") + 1);
                        node = node.Substring(0, node.Length - 4);

                        menu.AddItem(new GUIContent("Create For Selected/" + node, tooltip), false, CreateAnimationNodesFromSelection, type);
                    }
                }
            }

            return(menu);
        }
Exemple #5
0
 public CategoryAttribute(NodeCategoryType p_type)
 {
     type = p_type;
 }
Exemple #6
0
 public static string CategoryToString(NodeCategoryType p_type)
 {
     return(p_type.ToString().Substring(0, 1) + p_type.ToString().Substring(1).ToLower());
 }