Skip to content

Commit 905fb75

Browse files
committed
Minor bugfixes for GraphBehaviour and added TODOs for scene picking.
1 parent 79bf063 commit 905fb75

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

Assets/Examples/Editor/GraphBehaviourEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void OnDisable()
2121
public override VisualElement CreateInspectorGUI()
2222
{
2323
var root = new VisualElement();
24-
var graphContainer = graphEditor.CreateInspectorGUI().Q("ExposedParameters");
24+
var graphContainer = graphEditor != null ? graphEditor.CreateInspectorGUI().Q("ExposedParameters") : null;
2525

2626
root.Add(new Button(() => EditorWindow.GetWindow<AllGraphWindow>().InitializeGraph(behaviour.graph))
2727
{

Assets/com.alelievr.NodeGraphProcessor/Editor/BaseGraphWindow.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ public void InitializeGraph(BaseGraph graph)
9898
AssetDatabase.SaveAssets();
9999
// Unload the graph
100100
graphUnloaded?.Invoke(this.graph);
101-
Resources.UnloadAsset(this.graph);
101+
102+
if(this.graph.name != "") // Only if it has a file name (GraphBehaviour graphs doesn't have one). This is a temporary solution.
103+
Resources.UnloadAsset(this.graph);
102104
}
103105

104106
graphLoaded?.Invoke(graph);

Assets/com.alelievr.NodeGraphProcessor/Editor/GraphInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected virtual void OnDisable()
2828
{
2929
graph.onExposedParameterListChanged -= UpdateExposedParameters;
3030
graph.onExposedParameterModified -= UpdateExposedParameters;
31-
exposedParameterFactory.Dispose();
31+
exposedParameterFactory?.Dispose(); // Graphs that created in GraphBehaviour sometimes gives null ref.
3232
exposedParameterFactory = null;
3333
}
3434

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseGraphView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ public void UpdateComputeOrder()
11621162

11631163
public void RegisterCompleteObjectUndo(string name)
11641164
{
1165+
// TODO: GraphBehaviour graphs gives null ref when the scene is changed.
11651166
Undo.RegisterCompleteObjectUndo(graph, name);
11661167
}
11671168

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseNodeView.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,17 @@ protected VisualElement AddControlField(FieldInfo field, string label = null, bo
709709
UpdateOtherFieldValue(field, newValue);
710710
}, showInputDrawer ? "" : label);
711711

712+
/*if(owner.graph.name != "")
713+
{
714+
// TODO: Scene Graph vs Asset Graph distinction for scene picking
715+
// If this is a graph file
716+
var objectField = element.Q<ObjectField>();
717+
// Check field is an ObjectField
718+
if(objectField != null)
719+
// Disallow picking scene objects
720+
objectField.allowSceneObjects = false;
721+
}*/
722+
712723
if (!fieldControlsMap.TryGetValue(field, out var inputFieldList))
713724
inputFieldList = fieldControlsMap[field] = new List<VisualElement>();
714725
inputFieldList.Add(element);

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/ExposedParameterFieldFactory.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ public VisualElement GetParameterValueField(ExposedParameter parameter, Action<o
6767
oldParameterValues[parameter] = parameter.value;
6868
}));
6969

70+
/*if(this.graph.name != "")
71+
{
72+
// TODO: Scene Inspector vs Asset Inspector distinction for scene picking
73+
// If this is a graph file
74+
var objectField = view.Q<ObjectField>();
75+
// Check field is an ObjectField
76+
if(objectField != null)
77+
// Disallow picking scene objects
78+
objectField.allowSceneObjects = false;
79+
}*/
7080
return view;
7181
}
7282

0 commit comments

Comments
 (0)