0
Fixed

2.0.0a6 Collapse to graph bugs

Ex-Crow 10 months ago updated by Lazlo Bonin (Lead Developer) 8 months ago 4

Both collapse to Function and collapse to Macro work inconsistently. I'm able to collapse some parts of the graph but not others. And different unit selections are collapsible to Macro while not being collapsible to a function graph.

Graph: https://imgur.com/UhpKa4d

When trying to Collapse to Macro graph on these units something goes wrong:

[Exception] NullReferenceException: Object reference not set to an instance of an object
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
Ludiq.Bolt.UnitConnection`2[TSourcePort,TDestinationPort]..ctor() Assets/Ludiq/Bolt.Flow/Runtime/Connections/UnitConnection.cs:39
37: Ensure.That(nameof(destination)).IsNotNull(destination);
-->39: if (source.unit.parentGraph != destination.unit.parentGraph)
40: {
41: throw new NotSupportedException("Cannot create connections across graphs.");

Ludiq.Bolt.ValueConnection..ctor() Assets/Ludiq/Bolt.Flow/Runtime/Connections/ValueConnection.cs:15
13: public ValueConnection() : base() { }
-->15: public ValueConnection(ValueOutput source, ValueInput destination) : base(source, destination)
16: {
17: if (destination.hasValidConnection)

ValueOutput.ConnectToValid() Assets/Ludiq/Bolt.Flow/Runtime/Ports/ValueOutput.cs:124
122: destination.Disconnect();
-->124: var connection = new ValueConnection(source, destination);
125: unit.parentGraph.valueConnections.Add(connection);
126: return connection;

Ludiq.Bolt.UnitPort`5[TData,TValidOther,TInvalidOther,TExternalConnection,TDefinition].ValidlyConnectTo() Assets/Ludiq/Bolt.Flow/Runtime/Ports/UnitPort.cs:117
115: }
-->117: return ConnectToValid((TValidOther)port);
118: }

Ludiq.Bolt.FlowClassCollapseHandler`1[TFlowGraph].AddCollapsedUnit() Assets/Ludiq/Bolt.Flow/Editor/Collapsing/FlowClassCollapseHandler.cs:164
162: var ioKey = ioKeyByPort.Item2;
163: var ioPort = unit.ports[ioKey];
-->164: port.ValidlyConnectTo(ioPort);
165: }

Ludiq.Bolt.FlowClassCollapseHandler`1[TFlowGraph].Collapse() Assets/Ludiq/Bolt.Flow/Editor/Collapsing/FlowClassCollapseHandler.cs:30
28: if (parentUnit != null)
29: {
-->30: AddCollapsedUnit(request, parentUnit, ioConnections);
31: }
32: else

Ludiq.Bolt.CollapseHandler`1[TRequest].Collapse() Assets/Ludiq/Bolt.Core/Editor/Collapsing/CollapseHandler.cs:21
19: public bool Collapse(ICollapseRequest request)
20: {
-->21: return Collapse(request.CastTo());
22: }

CollapseDialog.OnGUI() Assets/Ludiq/Bolt.Core/Editor/Collapsing/CollapseDialog.cs:178
176: {
177: context.RecordUndo(handler.label);
-->178: handler.Collapse(request);
179: Close();
180: return;

MonoMethod.Invoke() <567df3e0919241ba98db88bec4c6696f>:0

MonoMethod.Invoke() <567df3e0919241ba98db88bec4c6696f>:0

MethodBase.Invoke() <567df3e0919241ba98db88bec4c6696f>:0

HostView.Invoke() C:/buildslave/unity/build/Editor/Mono/HostView.cs:359

HostView.Invoke() C:/buildslave/unity/build/Editor/Mono/HostView.cs:353

HostView.OldOnGUI() C:/buildslave/unity/build/Editor/Mono/HostView.cs:138

IMGUIContainer.DoOnGUI() C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:298

IMGUIContainer.HandleIMGUIEvent() C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:483

IMGUIContainer.HandleIMGUIEvent() C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:466

IMGUIContainer.HandleEvent() C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:447

MouseCaptureDispatchingStrategy.DispatchEvent() C:/buildslave/unity/build/Modules/UIElements/Events/MouseCaptureDispatchingStrategy.cs:93

EventDispatcher.ProcessEvent() C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:280

EventDispatcher.Dispatch() C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:156

BaseVisualElementPanel.SendEvent() C:/buildslave/unity/build/Modules/UIElements/Panel.cs:190

UIElementsUtility.DoDispatch() C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:255

UIElementsUtility.ProcessEvent() C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78

GUIUtility.ProcessEvent() C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179

When trying to collapse these units to Function graph I get the following error:




[Exception] InvalidOperationException: No sub-collection available for type 'Ludiq.Bolt.ControlInputDefinition'.
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
Ludiq.MergedKeyedCollection`2[TKey,TItem].GetCollectionForType() Assets/Ludiq/Ludiq.Core/Runtime/Collections/MergedKeyedCollection.cs:113
111: if (throwOnFail)
112: {
-->113: throw new InvalidOperationException($"No sub-collection available for type '{type}'.");
114: }
115: else

Ludiq.MergedKeyedCollection`2[TKey,TItem].GetCollectionForItem() Assets/Ludiq/Ludiq.Core/Runtime/Collections/MergedKeyedCollection.cs:89
87: Ensure.That(nameof(item)).IsNotNull(item);
-->89: return GetCollectionForType(item.GetType());
90: }

Ludiq.MergedKeyedCollection`2[TKey,TItem].Add() Assets/Ludiq/Ludiq.Core/Runtime/Collections/MergedKeyedCollection.cs:155
153: public virtual void Add(TItem item)
154: {
-->155: GetCollectionForItem(item).Add(item);
156: }

FlowGraphFactoryUtility.AddCompatibleDefinition() Assets/Ludiq/Bolt.Flow/Editor/Factories/FlowGraphFactoryUtility.cs:62
61: var reference = port.ToReference();
-->62: graph.definitions.Add(definition);
63: port = (ControlInput)reference.FindPort();

FlowGraphFactoryUtility.AddCompatibleDefinition() Assets/Ludiq/Bolt.Flow/Editor/Factories/FlowGraphFactoryUtility.cs:27
25: if (port is ControlInput controlInput)
26: {
-->27: var definition = graph.AddCompatibleDefinition(ref controlInput);
28: port = controlInput;
29: return definition;

Ludiq.Bolt.FlowClassCollapseHandler`1[TFlowGraph].CollapseToGraph() Assets/Ludiq/Bolt.Flow/Editor/Collapsing/FlowClassCollapseHandler.cs:90
88: !ioDefinitionsByPort.TryGetValue(connectedPort, out definition))
89: {
-->90: definition = graph.AddCompatibleDefinition(ref port);
91: ioDefinitionsByPort.Add(port, definition);
92: ioDefinitionsByPort.Add(connectedPort, definition);

Ludiq.Bolt.FlowClassCollapseHandler`1[TFlowGraph].Collapse() Assets/Ludiq/Bolt.Flow/Editor/Collapsing/FlowClassCollapseHandler.cs:24
22: public override bool Collapse(FlowClassCollapseRequest request)
23: {
-->24: var graph = CollapseToGraph(request, out var ioConnections);
25: request.@class.graphs.Add(graph);
26: var parentUnit = CreateCollapsedUnit(request, graph);

Ludiq.Bolt.CollapseHandler`1[TRequest].Collapse() Assets/Ludiq/Bolt.Core/Editor/Collapsing/CollapseHandler.cs:21
19: public bool Collapse(ICollapseRequest request)
20: {
-->21: return Collapse(request.CastTo());
22: }

CollapseDialog.OnGUI() Assets/Ludiq/Bolt.Core/Editor/Collapsing/CollapseDialog.cs:178
176: {
177: context.RecordUndo(handler.label);
-->178: handler.Collapse(request);
179: Close();
180: return;

MonoMethod.Invoke() <567df3e0919241ba98db88bec4c6696f>:0

MonoMethod.Invoke() <567df3e0919241ba98db88bec4c6696f>:0

MethodBase.Invoke() <567df3e0919241ba98db88bec4c6696f>:0

HostView.Invoke() C:/buildslave/unity/build/Editor/Mono/HostView.cs:359

HostView.Invoke() C:/buildslave/unity/build/Editor/Mono/HostView.cs:353

HostView.OldOnGUI() C:/buildslave/unity/build/Editor/Mono/HostView.cs:138

IMGUIContainer.DoOnGUI() C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:298

IMGUIContainer.HandleIMGUIEvent() C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:483

IMGUIContainer.HandleIMGUIEvent() C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:466

IMGUIContainer.HandleEvent() C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:447

MouseCaptureDispatchingStrategy.DispatchEvent() C:/buildslave/unity/build/Modules/UIElements/Events/MouseCaptureDispatchingStrategy.cs:93

EventDispatcher.ProcessEvent() C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:280

EventDispatcher.Dispatch() C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:156

BaseVisualElementPanel.SendEvent() C:/buildslave/unity/build/Modules/UIElements/Panel.cs:190

UIElementsUtility.DoDispatch() C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:255

UIElementsUtility.ProcessEvent() C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78

GUIUtility.ProcessEvent() C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179

Bolt Version:
2.0.0a6
Unity Version:
2019.2.15
Platform(s):
PC
Scripting Backend:
Mono
.NET Version (API Compatibility Level):
.NET 4.x
Bolt 2
Working on Fix

Hi TowerCrow,

Thanks for the report.

The fact that some collapse options are grayed out depending on the selection is by design.

For example, functions cannot contain events, so if your selection contains an event, the function button is disabled. Likewise, behaviours cannot contain inputs or outputs, so if your selection connects to other units externally, the behaviour option will be grayed out.

The two other exceptions you reported are bugs.

I just fixed the first one, I'm working on the second.

Oh, I didn't mean the greying out. I meant that it can collapse some parts to one type without errors while the other type will produce errors for the same selection and the other way around.

The second image, for example, could be collapsed to a macro but not to a function. 

+1
Fixed (Unreleased)

Hi TowerCrow,

I fixed a lot of issues related to this in the next version, I can't trigger any more bug here on the example operations you provided. Please start a new thread if ever you encounter other collapse issues then.