mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
NodeGraphEditor work continued
This commit is contained in:
commit
e7f759497b
@ -6,9 +6,10 @@
|
||||
### 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.
|
||||
|
||||
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
|
||||
* Lightweight in runtime
|
||||
|
||||
@ -7,6 +7,7 @@ using XNode;
|
||||
|
||||
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>
|
||||
|
||||
[CustomNodeEditor(typeof(Node))]
|
||||
public class NodeEditor : XNodeInternal.NodeEditorBase<NodeEditor, NodeEditor.CustomNodeEditorAttribute> {
|
||||
|
||||
@ -48,6 +49,12 @@ namespace XNodeEditor {
|
||||
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)]
|
||||
public class CustomNodeEditorAttribute : Attribute,
|
||||
INodeEditorAttrib {
|
||||
|
||||
@ -7,10 +7,15 @@ using XNode;
|
||||
namespace XNodeEditor {
|
||||
/// <summary> Contains GUI methods </summary>
|
||||
public partial class NodeEditorWindow {
|
||||
NodeGraphEditor currentGraphEditor;
|
||||
|
||||
private void OnGUI() {
|
||||
Event e = Event.current;
|
||||
Matrix4x4 m = GUI.matrix;
|
||||
currentGraphEditor = NodeGraphEditor.GetEditor(graph.GetType());
|
||||
currentGraphEditor.target = graph;
|
||||
currentGraphEditor.serializedObject = new SerializedObject(graph);
|
||||
|
||||
Controls();
|
||||
|
||||
DrawGrid(position, zoom, panOffset);
|
||||
@ -42,12 +47,12 @@ namespace XNodeEditor {
|
||||
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;
|
||||
|
||||
Vector2 center = rect.size / 2f;
|
||||
Texture2D gridTex = NodeEditorPreferences.gridTexture;
|
||||
Texture2D gridTex = currentGraphEditor.GetGridTexture();
|
||||
Texture2D crossTex = NodeEditorPreferences.crossTexture;
|
||||
|
||||
// Offset from origin in tile units
|
||||
@ -204,7 +209,7 @@ namespace XNodeEditor {
|
||||
GUILayout.BeginArea(new Rect(nodePos, new Vector2(nodeEditor.GetWidth(), 4000)));
|
||||
|
||||
GUIStyle style = NodeEditorResources.styles.nodeBody;
|
||||
if (nodeTint.ContainsKey(nodeType)) GUI.color = nodeTint[nodeType];
|
||||
GUI.color = nodeEditor.GetTint();
|
||||
GUILayout.BeginVertical(new GUIStyle(style));
|
||||
GUI.color = guiColor;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user