private static void OnReloadEditor() { // Find all NodeGraph assets string[] guids = AssetDatabase.FindAssets("t:" + typeof(XNode.NodeGraph)); for (int i = 0; i < guids.Length; i++) { string assetpath = AssetDatabase.GUIDToAssetPath(guids[i]); XNode.NodeGraph graph = AssetDatabase.LoadAssetAtPath(assetpath, typeof(XNode.NodeGraph)) as 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++) { // Ignore null sub assets if (objs[u] == null) { continue; } if (!graph.nodes.Contains(objs[u] as XNode.Node)) { graph.nodes.Add(objs[u] as XNode.Node); } } } }
/// <summary>Open the provided graph in the NodeEditor</summary> public static void Open(XNode.NodeGraph graph) { if (!graph) return; NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "EditorTreeGraph", true) as NodeEditorWindow; w.wantsMouseMove = true; w.graph = graph; }
public static void NodeGraphToolbar(XNode.NodeGraph nodeGraph) { Elements.BeginToolbarHorizontal(); if (Elements.ToolbarButton(ToolTips.runPreset)) { NodeAsset.Parse(nodeGraph); } if (Elements.ToolbarButton(ToolTips.deletePreset)) { if (EditorUtility.DisplayDialog("Delete Preset", "Are you sure you wish to delete this preset? Once deleted it can't be undone.", "Ok", "Cancel")) { XNodeEditor.NodeEditorWindow.focusedWindow.Close(); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(nodeGraph)); MapManager.RefreshPresetsList(); } } if (Elements.ToolbarButton(ToolTips.renamePreset)) { XNodeEditor.RenamePreset.Show(nodeGraph); } if (Elements.ToolbarButton(ToolTips.presetWiki)) { Application.OpenURL("https://github.com/RustMapMaking/Rust-Map-Editor-Unity/wiki/Node-System"); } Elements.EndToolbarHorizontal(); }
public static bool OnOpen(int instanceID, int line) { XNode.NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as XNode.NodeGraph; if (nodeGraph != null) { Open(nodeGraph); return true; } return false; }
/// <summary> Handle Selection Change events</summary> private static void OnSelectionChanged() { XNode.NodeGraph nodeGraph = Selection.activeObject as XNode.NodeGraph; if (nodeGraph && !AssetDatabase.Contains(nodeGraph)) { Open(nodeGraph); } }
public static void Open(XNode.NodeGraph graph) { NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow; w.wantsMouseMove = true; w.graph = graph; w.OnOpened(); }
public void SaveAs() { string path = EditorUtility.SaveFilePanelInProject("Save NodeGraph", "NewNodeGraph", "asset", ""); if (string.IsNullOrEmpty(path)) return; else { XNode.NodeGraph existingGraph = AssetDatabase.LoadAssetAtPath<XNode.NodeGraph>(path); if (existingGraph != null) AssetDatabase.DeleteAsset(path); AssetDatabase.CreateAsset(graph, path); EditorUtility.SetDirty(graph); if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); } }
public static void TryOpen(XNode.NodeGraph graph) { NodeEditorWindow w = Init(); w.wantsMouseMove = true; if (graph != null) { w.graph = graph; } }
/// <summary> Handle Selection Change events</summary> private static void OnSelectionChanged() { XNode.NodeGraph nodeGraph = Selection.activeObject as XNode.NodeGraph; if (nodeGraph && !AssetDatabase.Contains(nodeGraph)) { if (NodeEditorPreferences.GetSettings().openOnCreate) { Open(nodeGraph); } } }
public static bool OnOpen(int instanceID, int line) { XNode.NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as XNode.NodeGraph; if (nodeGraph != null) { NodeEditorWindow w = Init(); w.graph = nodeGraph; return(true); } return(false); }
public static bool OnOpen(int instanceID, int line) { XNode.NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as 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); }
/// <summary>Open the provided graph in the NodeEditor</summary> public static NodeEditorWindow Open(XNode.NodeGraph graph) { if (!graph) { return(null); } NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow; w.wantsMouseMove = true; w.graph = graph; return(w); }