// Override open function public override void OnOpen() { // Init available nodes _availableNodes = new Dictionary <string, Type[]>(); _availableNodes["Model"] = NodeEditorWindow.GetDerivedTypes(typeof(PCGModelNode)); _availableNodes["Tileset"] = NodeEditorWindow.GetDerivedTypes(typeof(TilesetNode)); _availableNodes["Tile"] = NodeEditorWindow.GetDerivedTypes(typeof(TileNode)); _availableNodes["Noise"] = NodeEditorWindow.GetDerivedTypes(typeof(NoiseNode)); if (target != null) { _currentGraph = (PCGGraph)target; } window.titleContent = new GUIContent("PCGTool"); }
private static void CacheCustomEditors() { editors = new Dictionary <Type, T>(); //Get all classes deriving from NodeEditor via reflection Type[] nodeEditors = NodeEditorWindow.GetDerivedTypes(typeof(T)); for (int i = 0; i < nodeEditors.Length; i++) { var attribs = nodeEditors[i].GetCustomAttributes(typeof(A), false); if (attribs == null || attribs.Length == 0) { continue; } if (nodeEditors[i].IsAbstract) { continue; } A attrib = attribs[0] as A; editors.Add(attrib.GetInspectedType(), Activator.CreateInstance(nodeEditors[i]) as T); } }