mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
NodeGraphEditor work continued
This commit is contained in:
commit
e7f759497b
@ -6,9 +6,10 @@
|
|||||||
### xNode
|
### xNode
|
||||||
Thinking of developing a node-based plugin? Then this is for you. You can download it as an archive and unpack to a new unity project, or connect it as git submodule.
|
Thinking of developing a node-based plugin? Then this is for you. You can download it as an archive and unpack to a new unity project, or connect it as git submodule.
|
||||||
|
|
||||||
With a minimal footprint, xNode is ideal as a base for custom state machines, dialogue systems, decision makers etc.
|
xNode is super userfriendly, intuitive and will help you reap the benefits of node graphs in no time.
|
||||||
|
With a minimal footprint, it is ideal as a base for custom state machines, dialogue systems, decision makers etc.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Key features
|
### Key features
|
||||||
* Lightweight in runtime
|
* Lightweight in runtime
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using XNode;
|
|||||||
|
|
||||||
namespace XNodeEditor {
|
namespace XNodeEditor {
|
||||||
/// <summary> Base class to derive custom Node editors from. Use this to create your own custom inspectors and editors for your nodes. </summary>
|
/// <summary> Base class to derive custom Node editors from. Use this to create your own custom inspectors and editors for your nodes. </summary>
|
||||||
|
|
||||||
[CustomNodeEditor(typeof(Node))]
|
[CustomNodeEditor(typeof(Node))]
|
||||||
public class NodeEditor : XNodeInternal.NodeEditorBase<NodeEditor, NodeEditor.CustomNodeEditorAttribute> {
|
public class NodeEditor : XNodeInternal.NodeEditorBase<NodeEditor, NodeEditor.CustomNodeEditorAttribute> {
|
||||||
|
|
||||||
@ -48,6 +49,12 @@ namespace XNodeEditor {
|
|||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual Color GetTint() {
|
||||||
|
Type type = GetType();
|
||||||
|
if (NodeEditorWindow.nodeTint.ContainsKey(type)) return NodeEditorWindow.nodeTint[type];
|
||||||
|
else return Color.white;
|
||||||
|
}
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
public class CustomNodeEditorAttribute : Attribute,
|
public class CustomNodeEditorAttribute : Attribute,
|
||||||
INodeEditorAttrib {
|
INodeEditorAttrib {
|
||||||
|
|||||||
@ -7,10 +7,15 @@ using XNode;
|
|||||||
namespace XNodeEditor {
|
namespace XNodeEditor {
|
||||||
/// <summary> Contains GUI methods </summary>
|
/// <summary> Contains GUI methods </summary>
|
||||||
public partial class NodeEditorWindow {
|
public partial class NodeEditorWindow {
|
||||||
|
NodeGraphEditor currentGraphEditor;
|
||||||
|
|
||||||
private void OnGUI() {
|
private void OnGUI() {
|
||||||
Event e = Event.current;
|
Event e = Event.current;
|
||||||
Matrix4x4 m = GUI.matrix;
|
Matrix4x4 m = GUI.matrix;
|
||||||
|
currentGraphEditor = NodeGraphEditor.GetEditor(graph.GetType());
|
||||||
|
currentGraphEditor.target = graph;
|
||||||
|
currentGraphEditor.serializedObject = new SerializedObject(graph);
|
||||||
|
|
||||||
Controls();
|
Controls();
|
||||||
|
|
||||||
DrawGrid(position, zoom, panOffset);
|
DrawGrid(position, zoom, panOffset);
|
||||||
@ -42,12 +47,12 @@ namespace XNodeEditor {
|
|||||||
GUI.matrix = Matrix4x4.TRS(offset, Quaternion.identity, Vector3.one);
|
GUI.matrix = Matrix4x4.TRS(offset, Quaternion.identity, Vector3.one);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawGrid(Rect rect, float zoom, Vector2 panOffset) {
|
public void DrawGrid(Rect rect, float zoom, Vector2 panOffset) {
|
||||||
|
|
||||||
rect.position = Vector2.zero;
|
rect.position = Vector2.zero;
|
||||||
|
|
||||||
Vector2 center = rect.size / 2f;
|
Vector2 center = rect.size / 2f;
|
||||||
Texture2D gridTex = NodeEditorPreferences.gridTexture;
|
Texture2D gridTex = currentGraphEditor.GetGridTexture();
|
||||||
Texture2D crossTex = NodeEditorPreferences.crossTexture;
|
Texture2D crossTex = NodeEditorPreferences.crossTexture;
|
||||||
|
|
||||||
// Offset from origin in tile units
|
// Offset from origin in tile units
|
||||||
@ -204,7 +209,7 @@ namespace XNodeEditor {
|
|||||||
GUILayout.BeginArea(new Rect(nodePos, new Vector2(nodeEditor.GetWidth(), 4000)));
|
GUILayout.BeginArea(new Rect(nodePos, new Vector2(nodeEditor.GetWidth(), 4000)));
|
||||||
|
|
||||||
GUIStyle style = NodeEditorResources.styles.nodeBody;
|
GUIStyle style = NodeEditorResources.styles.nodeBody;
|
||||||
if (nodeTint.ContainsKey(nodeType)) GUI.color = nodeTint[nodeType];
|
GUI.color = nodeEditor.GetTint();
|
||||||
GUILayout.BeginVertical(new GUIStyle(style));
|
GUILayout.BeginVertical(new GUIStyle(style));
|
||||||
GUI.color = guiColor;
|
GUI.color = guiColor;
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user