This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Node Inspector calls DrawNodePropertyEditor and defaults to imitating the NodeGUI - Adjusted selected objects after click to either select a node or the canvas itself
- Loading branch information
Seneral
committed
Jul 4, 2017
1 parent
58f5553
commit 79a6567
Showing
5 changed files
with
173 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace NodeEditorFramework.Standard | ||
{ | ||
[CustomEditor(typeof(NodeCanvas), true)] | ||
public class CanvasInspector : Editor | ||
{ | ||
public static GUIStyle titleStyle; | ||
public static GUIStyle subTitleStyle; | ||
public static GUIStyle boldLabelStyle; | ||
|
||
public NodeCanvas canvas; | ||
|
||
public void OnEnable() | ||
{ | ||
canvas = (NodeCanvas)target; | ||
canvas.Validate(); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
if (canvas == null) | ||
canvas = (NodeCanvas)target; | ||
if (canvas == null) | ||
return; | ||
if (titleStyle == null) | ||
{ | ||
titleStyle = new GUIStyle(GUI.skin.label); | ||
titleStyle.fontStyle = FontStyle.Bold; | ||
titleStyle.alignment = TextAnchor.MiddleCenter; | ||
titleStyle.fontSize = 16; | ||
} | ||
if (subTitleStyle == null) | ||
{ | ||
subTitleStyle = new GUIStyle(GUI.skin.label); | ||
subTitleStyle.fontStyle = FontStyle.Bold; | ||
subTitleStyle.alignment = TextAnchor.MiddleCenter; | ||
subTitleStyle.fontSize = 12; | ||
} | ||
if (boldLabelStyle == null) | ||
{ | ||
boldLabelStyle = new GUIStyle(GUI.skin.label); | ||
boldLabelStyle.fontStyle = FontStyle.Bold; | ||
} | ||
|
||
EditorGUI.BeginChangeCheck(); | ||
|
||
GUILayout.Space(10); | ||
|
||
GUILayout.Label(new GUIContent(canvas.saveName, canvas.savePath), titleStyle); | ||
GUILayout.Label(canvas.livesInScene? "Scene Save" : "Asset Save", subTitleStyle); | ||
GUILayout.Label("Type: " + canvas.canvasName, subTitleStyle); | ||
|
||
GUILayout.Space(10); | ||
|
||
if (GUILayout.Button("Open")) | ||
{ | ||
string NodeCanvasPath = AssetDatabase.GetAssetPath(canvas); | ||
NodeEditorWindow.OpenNodeEditor().canvasCache.LoadNodeCanvas(NodeCanvasPath); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
GUILayout.Label("Nodes", boldLabelStyle); | ||
foreach (Node node in canvas.nodes) | ||
{ | ||
string label = node.Title; | ||
EditorGUILayout.ObjectField(label, node, node.GetType(), true); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
using NodeEditorFramework.Utilities; | ||
|
||
namespace NodeEditorFramework.Standard | ||
{ | ||
[CustomEditor(typeof(Node), true)] | ||
public class NodeInspector : Editor | ||
{ | ||
public static GUIStyle titleStyle; | ||
public static GUIStyle boldLabelStyle; | ||
public Node node; | ||
|
||
public void OnEnable() | ||
{ | ||
node = (Node)target; | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
if (node == null) | ||
node = (Node)target; | ||
if (node == null) | ||
return; | ||
if (titleStyle == null) | ||
{ | ||
titleStyle = new GUIStyle(GUI.skin.label); | ||
titleStyle.fontStyle = FontStyle.Bold; | ||
titleStyle.alignment = TextAnchor.MiddleCenter; | ||
titleStyle.fontSize = 16; | ||
} | ||
if (boldLabelStyle == null) | ||
{ | ||
boldLabelStyle = new GUIStyle(GUI.skin.label); | ||
boldLabelStyle.fontStyle = FontStyle.Bold; | ||
} | ||
|
||
OverlayGUI.StartOverlayGUI("NodeInspector"); | ||
|
||
EditorGUI.BeginChangeCheck(); | ||
|
||
GUILayout.Space(10); | ||
|
||
GUILayout.Label(node.Title, titleStyle); | ||
|
||
GUILayout.Space(10); | ||
|
||
GUILayout.Label("Rect: " + node.rect.ToString()); | ||
node.backgroundColor = EditorGUILayout.ColorField("Color", node.backgroundColor); | ||
|
||
GUILayout.Space(10); | ||
|
||
GUILayout.Label("Connection Ports", boldLabelStyle); | ||
foreach (ConnectionPort port in node.connectionPorts) | ||
{ | ||
string labelPrefix = port.direction == Direction.In ? "Input " : (port.direction == Direction.Out ? "Output " : ""); | ||
string label = labelPrefix + port.styleID + " '" + port.name + "'"; | ||
EditorGUILayout.ObjectField(label, port, port.GetType(), true); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
GUILayout.Label("Property Editor", boldLabelStyle); | ||
node.DrawNodePropertyEditor(); | ||
|
||
if (EditorGUI.EndChangeCheck()) | ||
NodeEditor.RepaintClients(); | ||
|
||
OverlayGUI.EndOverlayGUI(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters