public static bool OnOpen(int instanceID, int line) { Siccity.XNode.NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as Siccity.XNode.NodeGraph; if (nodeGraph != null) { NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow; w.wantsMouseMove = true; w.graph = nodeGraph; return(true); } return(false); }
private static void OnReloadEditor() { // Find all NodeGraph assets string[] guids = AssetDatabase.FindAssets("t:" + typeof(Siccity.XNode.NodeGraph)); for (int i = 0; i < guids.Length; i++) { string assetpath = AssetDatabase.GUIDToAssetPath(guids[i]); Siccity.XNode.NodeGraph graph = AssetDatabase.LoadAssetAtPath(assetpath, typeof(Siccity.XNode.NodeGraph)) as Siccity.XNode.NodeGraph; graph.nodes.RemoveAll(x => x == null); //Remove null items Object[] objs = AssetDatabase.LoadAllAssetRepresentationsAtPath(assetpath); // Ensure that all sub node assets are present in the graph node list for (int u = 0; u < objs.Length; u++) { if (!graph.nodes.Contains(objs[u] as Siccity.XNode.Node)) { graph.nodes.Add(objs[u] as Siccity.XNode.Node); } } } }
public void SaveAs() { string path = EditorUtility.SaveFilePanelInProject("Save NodeGraph", "NewNodeGraph", "asset", ""); if (string.IsNullOrEmpty(path)) { return; } else { Siccity.XNode.NodeGraph existingGraph = AssetDatabase.LoadAssetAtPath <Siccity.XNode.NodeGraph>(path); if (existingGraph != null) { AssetDatabase.DeleteAsset(path); } AssetDatabase.CreateAsset(graph, path); EditorUtility.SetDirty(graph); AssetDatabase.SaveAssets(); } }