private Texture2D GetCategoryIcon(string category) { category = NodeCategory.CategoryFileName(category); if (m_categoriesData.ContainsKey(category)) { return(m_categoriesData[category].icon); } //Fallback return(m_buttonIcons[ButtonAnswer.Modify]); }
static private void DrawHeader(Node node) { GUIStyle nameGUIStyle = new GUIStyle(EditorStyles.boldLabel); nameGUIStyle.alignment = TextAnchor.MiddleLeft; EditorGUI.LabelField(GetHeaderNameRect(node.rect), new GUIContent(node.name), nameGUIStyle); NodeCategory category = NodeCategory.GetNodeCategory(node.nodeMethodAttribute.category); EditorGUI.LabelField(GetHeaderIconRect(node.rect), new GUIContent((category == null) ? null : category.icon)); }
public void LoadNodeCategories() { m_categoriesData = new Dictionary <string, NodeCategory>(); NodeCategory[] nodeCategories = NodeCategory.FindAllCategories(); foreach (NodeCategory category in nodeCategories) { if (category != null) { m_categoriesData.Add(category.name, category); } } }
static public NodeCategory[] FindAllCategories() { string[] categoriesAssetPaths = AssetDatabase.FindAssets("t:NodeCategory"); NodeCategory[] result = new NodeCategory[categoriesAssetPaths.Length]; for (int i = 0; i < categoriesAssetPaths.Length; i++) { string assetPath = AssetDatabase.GUIDToAssetPath(categoriesAssetPaths[i]); result[i] = AssetDatabase.LoadAssetAtPath(assetPath, typeof(NodeCategory)) as NodeCategory; } s_categoriesData = new Dictionary <string, NodeCategory>(); foreach (NodeCategory category in result) { if (category != null) { s_categoriesData.Add(category.name, category); } } return(result); }