Skip to content

Commit

Permalink
- Removed unnecessary frame delay when reloading a graph
Browse files Browse the repository at this point in the history
- Removed Unbind call when clearing a graph
- PortListView entries will now update their name, if the referenced node name is changed
  • Loading branch information
Doppelkeks committed Mar 14, 2023
1 parent 8603d30 commit 3152b33
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- fixed issue with change callback handler for property fields in settings file

## [0.2.6] - 2023-03-14
### Fixed
- Removed unnecessary frame delay when reloading a graph
- Removed Unbind call when clearing a graph
- PortListView entries will now update their name, if the referenced node name is changed

13 changes: 5 additions & 8 deletions Editor/Controllers/GraphController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class GraphController {
private bool isLoading = false;
private Dictionary<object, NodeView> dataToViewLookup = new Dictionary<object, NodeView>();
private Dictionary<Type, string> nodeTypeToCreationLabel = new Dictionary<Type, string>();

private GenericMenu dropdownMenu;
private Type dropdownMenuCurrentType;

Expand Down Expand Up @@ -288,10 +288,10 @@ private void OnDelete(object data = null) {
if (isDirty) {
// unbind and reload this graph to avoid serialization issues...
graphView.Unbind();
graphView.schedule.Execute(() => {
graphData.RemoveNodes(nodesToRemove);
Reload();
});
//graphView.schedule.Execute(() => {
graphData.RemoveNodes(nodesToRemove);
Reload();
//});
}

}
Expand Down Expand Up @@ -482,9 +482,6 @@ private void Load(GraphModel graphData) {
isLoading = true;

// clear everything up since we have changed contexts....
graphView.ForEachNodeDo((node) => {
(node as NodeView).controller.Dispose();
});
inspector.Clear();
graphView.ClearView();
dataToViewLookup.Clear();
Expand Down
4 changes: 0 additions & 4 deletions Editor/Controllers/NodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public void ForEachNode(Action<BaseNode> callback) {
graphController.ForEachNode(callback);
}

public void Dispose() {

}

public NodeController(NodeModel nodeItem, GraphController graphController) {
this.graphController = graphController;
this.nodeItem = nodeItem;
Expand Down
2 changes: 1 addition & 1 deletion Editor/Views/GraphView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void SetSelected(GraphElement graphElement, bool selected = true, bool cl
}

public void ClearView() {
this.Unbind();
//this.Unbind();

foreach (BaseNode node in ContentContainer.Nodes) {
node.RemoveFromHierarchy();
Expand Down
2 changes: 1 addition & 1 deletion Editor/Views/NodeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void CreateOuputPortUI(PortInfo info, SerializedProperty property) {
}

public PortView CreatePortUI(PortInfo info, SerializedProperty property) {
PortView port = new PortView(info, property);
PortView port = new PortView(info, property.Copy());

if (info.portDisplay.name != null) {
port.PortName = info.portDisplay.name;
Expand Down
4 changes: 2 additions & 2 deletions Editor/Views/PortListView.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
using static NewGraph.GraphSettingsSingleton;
Expand Down Expand Up @@ -215,6 +216,7 @@ void OnConnectionChanged() {
if (attachedNodeView != null) {
//...and retrieve its name, hihi
label.text = attachedNodeView.controller.nodeItem.GetName();
label.TrackPropertyValue(attachedNodeView.controller.nodeItem.GetNameSerializedProperty().Copy(), (p) => label.text = p.stringValue);
}
}
}
Expand Down Expand Up @@ -242,8 +244,6 @@ private void RedrawConnection(PortView port, SerializedProperty prop) {
}

private void ItemIndexChanged(int draggedIndex, int dropIndex) {
Debug.Log("ItemIndexChanged");

// get "real" indices
draggedIndex = viewController.GetIndexForId(draggedIndex);
dropIndex = viewController.GetIndexForId(dropIndex);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.gentlymad.newgraph",
"version": "0.2.5",
"version": "0.2.6",
"displayName": "NewGraph",
"description": "Our general node graph solution. This is build upon the idea to visualize complex data structures as graph networks without having to modify already established data classes, except adding [Node], [Port] and [SerializeReference] attributes to call classes that should show in the Graph View.",
"unity": "2022.2",
Expand Down

0 comments on commit 3152b33

Please sign in to comment.