1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

!B(NodeEditorWindow) multiple NodeEditorWindow,Target error

This commit is contained in:
Icarus 2020-01-06 22:34:54 +08:00
parent 33a516b6e2
commit daf7fb9f9f

View File

@ -33,7 +33,17 @@ namespace XNodeEditor {
foreach (var window in windows)
{
window.Close();
if (window)
{
try
{
window.Close();
}
catch (Exception e)
{
DestroyImmediate(window);
}
}
}
}
@ -103,7 +113,8 @@ namespace XNodeEditor {
public float zoom { get { return _zoom; } set { _zoom = Mathf.Clamp(value, NodeEditorPreferences.GetSettings().minZoom, NodeEditorPreferences.GetSettings().maxZoom); Repaint(); } }
private float _zoom = 1;
void OnFocus() {
void OnFocus()
{
current = this;
ValidateGraphEditor();
if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
@ -239,15 +250,26 @@ namespace XNodeEditor {
if (!w)
{
w = CreateWindow<NodeEditorWindow>("xNode");
w = EditorWindow.CreateInstance<NodeEditorWindow>();
w.titleContent = new GUIContent("xNode");
}
w.Show(true);
w.Focus();
if (w.graphEditor == null)
{
NodeGraphEditor graphEditor = NodeGraphEditor.GetEditor(graph, w);
w.graphEditor = graphEditor;
}
else
{
//refresh target
w.graphEditor.target = graph;
}
w.wantsMouseMove = true;
w.graph = graph;
NodeGraphEditor graphEditor = NodeGraphEditor.GetEditor(graph, w);
NodeEditorWindow.current.graphEditor = graphEditor;
return w;
}