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
|
||||
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";
|
||||
GUILayout.BeginArea(windowRect, node.ToString(), style);
|
||||
GUILayout.BeginArea(new Rect(nodePos,new Vector2(200,4000)));
|
||||
GUILayout.BeginVertical(node.ToString(), style);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
//Inputs
|
||||
@ -170,7 +169,9 @@ public partial class NodeEditorWindow {
|
||||
NodeEditor nodeEditor = GetNodeEditor(node.GetType());
|
||||
nodeEditor.target = node;
|
||||
nodeEditor.OnNodeGUI();
|
||||
GUILayout.EndVertical();
|
||||
|
||||
if (e.type == EventType.Repaint) node.position.size = GUILayoutUtility.GetLastRect().size;
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
EndZoomed(position, zoom);
|
||||
|
||||
@ -31,11 +31,9 @@ public partial class NodeEditorWindow : EditorWindow {
|
||||
|
||||
public void Save() {
|
||||
saved = graph.Serialize();
|
||||
Debug.Log(saved);
|
||||
}
|
||||
|
||||
public void Load() {
|
||||
Debug.Log(saved);
|
||||
_graph = NodeGraph.Deserialize(saved);
|
||||
}
|
||||
|
||||
@ -48,7 +46,6 @@ public partial class NodeEditorWindow : EditorWindow {
|
||||
}
|
||||
|
||||
public Vector2 GridToWindowPosition(Vector2 gridPosition) {
|
||||
//Vector2 center = position.size * 0.5f;
|
||||
return (position.size * 0.5f) + (panOffset / zoom) + (gridPosition/zoom);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user