Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Improved Canvas Inspector
Browse files Browse the repository at this point in the history
- Added canvas property editor GUI
- Removed double-click-to-open to make inspectors easier to navigate (use open button instead)
  • Loading branch information
Seneral committed Jul 10, 2017
1 parent 301ea24 commit 6333c1c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
9 changes: 9 additions & 0 deletions Editor/Node_Editor/CanvasInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ public override void OnInspectorGUI()

GUILayout.Space(10);

EditorGUI.BeginDisabledGroup(NodeEditor.curNodeCanvas != null && NodeEditor.curNodeCanvas.savePath == canvas.savePath);
if (GUILayout.Button("Open"))
{
string NodeCanvasPath = AssetDatabase.GetAssetPath(canvas);
NodeEditorWindow.OpenNodeEditor().canvasCache.LoadNodeCanvas(NodeCanvasPath);
}
EditorGUI.EndDisabledGroup();

GUILayout.Space(10);

Expand All @@ -68,6 +70,13 @@ public override void OnInspectorGUI()
string label = node.Title;
EditorGUILayout.ObjectField(label, node, node.GetType(), true);
}

GUILayout.Space(10);

canvas.DrawCanvasPropertyEditor();

if (EditorGUI.EndChangeCheck())
NodeEditor.RepaintClients();
}
}
}
2 changes: 2 additions & 0 deletions Editor/Node_Editor/NodeEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static NodeEditorWindow OpenNodeEditor ()
return _editor;
}

/*
/// <summary>
/// Assures that the canvas is opened when double-clicking a canvas asset
/// </summary>
Expand All @@ -58,6 +59,7 @@ private static bool AutoOpenCanvas(int instanceID, int line)
}
return false;
}
*/

private void OnEnable()
{
Expand Down
23 changes: 12 additions & 11 deletions Node_Editor/Framework/Core/NodeCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public static NodeCanvas CreateCanvas (Type canvasType)

#endregion

#region Callbacks
#region Extension Methods

// GENERAL

protected virtual void OnCreate () {}

Expand All @@ -72,7 +74,11 @@ public static NodeCanvas CreateCanvas (Type canvasType)

public virtual bool CanAddNode (string nodeID) { return true; }

#region Additional Serialization
// GUI

public virtual void DrawCanvasPropertyEditor () { }

// ADDITIONAL SERIALIZATION

/// <summary>
/// Should return all additional ScriptableObjects this Node references
Expand All @@ -84,11 +90,10 @@ public static NodeCanvas CreateCanvas (Type canvasType)
/// </summary>
protected internal virtual void CopyScriptableObjects (System.Func<ScriptableObject, ScriptableObject> replaceSO) {}

#endregion

#endregion

#region Traversal
#region Methods

/// <summary>
/// Trigger traversal of the whole canvas
Expand All @@ -108,10 +113,6 @@ public void OnNodeChange (Node node)
Traversal.OnChange (node);
}

#endregion

#region Methods

/// <summary>
/// Validates this canvas, checking for any broken nodes or references and cleans them.
/// </summary>
Expand Down Expand Up @@ -160,10 +161,10 @@ private void CheckNodeCanvasList<T> (ref List<T> list, string listName)
/// <summary>
/// Updates the source of this canvas to the specified path, updating saveName and savePath aswell as livesInScene when prefixed with "SCENE/"
/// </summary>
public bool UpdateSource (string path)
public void UpdateSource (string path)
{
if (path == savePath)
return false;
return;
string newName;
if (path.StartsWith ("SCENE/"))
{
Expand All @@ -180,7 +181,7 @@ public bool UpdateSource (string path)
saveName = newName;
livesInScene = path.StartsWith ("SCENE/");
}
return true;
return;
}

#endregion
Expand Down

0 comments on commit 6333c1c

Please sign in to comment.