mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Small formatting changes and comments
This commit is contained in:
parent
ea14f27a23
commit
6d0ce544c9
@ -88,6 +88,7 @@ namespace XNodeEditor {
|
|||||||
node.position.y = (Mathf.Round((node.position.y + 8) / 16) * 16) - 8;
|
node.position.y = (Mathf.Round((node.position.y + 8) / 16) * 16) - 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Offset portConnectionPoints instantly if a node is dragged so they aren't delayed by a frame.
|
||||||
Vector2 offset = node.position - initial;
|
Vector2 offset = node.position - initial;
|
||||||
if (offset.sqrMagnitude > 0){
|
if (offset.sqrMagnitude > 0){
|
||||||
foreach (XNode.NodePort output in node.Outputs){
|
foreach (XNode.NodePort output in node.Outputs){
|
||||||
@ -103,7 +104,6 @@ namespace XNodeEditor {
|
|||||||
reroutePoints[index] += offset;
|
reroutePoints[index] += offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (XNode.NodePort input in node.Inputs) {
|
foreach (XNode.NodePort input in node.Inputs) {
|
||||||
|
|||||||
@ -10,16 +10,13 @@ namespace XNodeEditor {
|
|||||||
|
|
||||||
/// <summary> Stores node positions for all nodePorts. </summary>
|
/// <summary> Stores node positions for all nodePorts. </summary>
|
||||||
public Dictionary<XNode.NodePort, Rect> portConnectionPoints { get { return _portConnectionPoints; } }
|
public Dictionary<XNode.NodePort, Rect> portConnectionPoints { get { return _portConnectionPoints; } }
|
||||||
|
|
||||||
private Dictionary<XNode.NodePort, Rect> _portConnectionPoints = new Dictionary<XNode.NodePort, Rect>();
|
private Dictionary<XNode.NodePort, Rect> _portConnectionPoints = new Dictionary<XNode.NodePort, Rect>();
|
||||||
|
[SerializeField] private NodePortReference[] _references = new NodePortReference[0];
|
||||||
|
[SerializeField] private Rect[] _rects = new Rect[0];
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable] private class NodePortReference {
|
||||||
private class NodePortReference {
|
[SerializeField] private XNode.Node _node;
|
||||||
[SerializeField]
|
[SerializeField] private string _name;
|
||||||
private XNode.Node _node;
|
|
||||||
[SerializeField]
|
|
||||||
private string _name;
|
|
||||||
|
|
||||||
|
|
||||||
public NodePortReference(XNode.NodePort nodePort) {
|
public NodePortReference(XNode.NodePort nodePort) {
|
||||||
_node = nodePort.node;
|
_node = nodePort.node;
|
||||||
@ -30,18 +27,12 @@ namespace XNodeEditor {
|
|||||||
if (_node == null) {
|
if (_node == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _node.GetPort(_name);
|
return _node.GetPort(_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private NodePortReference[] _references = new NodePortReference[0];
|
|
||||||
[SerializeField]
|
|
||||||
private Rect[] _rects = new Rect[0];
|
|
||||||
|
|
||||||
private void OnDisable() {
|
private void OnDisable() {
|
||||||
|
// Cache portConnectionPoints before serialization starts
|
||||||
int count = portConnectionPoints.Count;
|
int count = portConnectionPoints.Count;
|
||||||
_references = new NodePortReference[count];
|
_references = new NodePortReference[count];
|
||||||
_rects = new Rect[count];
|
_rects = new Rect[count];
|
||||||
@ -54,8 +45,8 @@ namespace XNodeEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable() {
|
private void OnEnable() {
|
||||||
|
// Reload portConnectionPoints if there are any
|
||||||
int length = _references.Length;
|
int length = _references.Length;
|
||||||
|
|
||||||
if (length == _rects.Length) {
|
if (length == _rects.Length) {
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
XNode.NodePort nodePort = _references[i].GetNodePort();
|
XNode.NodePort nodePort = _references[i].GetNodePort();
|
||||||
@ -79,7 +70,6 @@ namespace XNodeEditor {
|
|||||||
if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
//partial void OnEnable();
|
|
||||||
/// <summary> Create editor window </summary>
|
/// <summary> Create editor window </summary>
|
||||||
public static NodeEditorWindow Init() {
|
public static NodeEditorWindow Init() {
|
||||||
NodeEditorWindow w = CreateInstance<NodeEditorWindow>();
|
NodeEditorWindow w = CreateInstance<NodeEditorWindow>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user