mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Automatically resize nodes to match contents
This commit is contained in:
parent
372099b03d
commit
72cd983f7b
@ -137,10 +137,9 @@ public partial class NodeEditorWindow {
|
|||||||
//Get node position
|
//Get node position
|
||||||
Vector2 nodePos = GridToWindowPositionNoClipped(node.position.position);
|
Vector2 nodePos = GridToWindowPositionNoClipped(node.position.position);
|
||||||
|
|
||||||
Rect windowRect = new Rect(nodePos, node.position.size);
|
|
||||||
|
|
||||||
GUIStyle style = (node == selectedNode) ? (GUIStyle)"flow node 0 on" : (GUIStyle)"flow node 0";
|
GUIStyle style = (node == selectedNode) ? (GUIStyle)"flow node 0 on" : (GUIStyle)"flow node 0";
|
||||||
GUILayout.BeginArea(windowRect, node.ToString(), style);
|
GUILayout.BeginArea(new Rect(nodePos,new Vector2(200,4000)));
|
||||||
|
GUILayout.BeginVertical(node.ToString(), style);
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
|
|
||||||
//Inputs
|
//Inputs
|
||||||
@ -170,7 +169,9 @@ public partial class NodeEditorWindow {
|
|||||||
NodeEditor nodeEditor = GetNodeEditor(node.GetType());
|
NodeEditor nodeEditor = GetNodeEditor(node.GetType());
|
||||||
nodeEditor.target = node;
|
nodeEditor.target = node;
|
||||||
nodeEditor.OnNodeGUI();
|
nodeEditor.OnNodeGUI();
|
||||||
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
|
if (e.type == EventType.Repaint) node.position.size = GUILayoutUtility.GetLastRect().size;
|
||||||
GUILayout.EndArea();
|
GUILayout.EndArea();
|
||||||
}
|
}
|
||||||
EndZoomed(position, zoom);
|
EndZoomed(position, zoom);
|
||||||
|
|||||||
@ -31,11 +31,9 @@ public partial class NodeEditorWindow : EditorWindow {
|
|||||||
|
|
||||||
public void Save() {
|
public void Save() {
|
||||||
saved = graph.Serialize();
|
saved = graph.Serialize();
|
||||||
Debug.Log(saved);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load() {
|
public void Load() {
|
||||||
Debug.Log(saved);
|
|
||||||
_graph = NodeGraph.Deserialize(saved);
|
_graph = NodeGraph.Deserialize(saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +46,6 @@ public partial class NodeEditorWindow : EditorWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 GridToWindowPosition(Vector2 gridPosition) {
|
public Vector2 GridToWindowPosition(Vector2 gridPosition) {
|
||||||
//Vector2 center = position.size * 0.5f;
|
|
||||||
return (position.size * 0.5f) + (panOffset / zoom) + (gridPosition/zoom);
|
return (position.size * 0.5f) + (panOffset / zoom) + (gridPosition/zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user