McManning / BlueGraph

Visual Scripting Framework for Unity
MIT License
237 stars 30 forks source link

Add array port views #24

Open McManning opened 3 years ago

McManning commented 3 years ago

I'd like to be able to define a port type as a collection container...

class MyNode: ... {
   [Input] public SomeCollection<float> foo;
}

... and connect edges into individual slots for that collection, essentially to control the order of inputs.

This wouldn't remove the need for the Port.capacity == Multiple feature - since I'd still need singular output ports feed to multiple inputs, or single inputs come from multiple outputs without regard for order (e.g. execution flow). But this would improve usability for handling arrays of things.

The associated PortView should expand to include multiple ports, one per connected element.

I'd rather make this a custom collection type to continue supporting a single edge from an output List<T> to input List<T> and to add IConvertible support for feeding it into a T[] or other enumerable.

The other alternative - if this isn't a core feature - is to just have a custom node that accepts a dynamic list of T inputs and a single T[] output that compiles them into an array. Will probably add this as an example anyway, but it'd be nice to exist as a core feature.

McManning commented 3 years ago

I have a WIP in the samples project for this. Specifically:

https://github.com/McManning/BlueGraph-Samples/blob/experimental/Assets/Misc/Runtime/Nodes/ToFloatArray.cs https://github.com/McManning/BlueGraph-Samples/blob/experimental/Assets/Misc/Editor/ToFloatArrayView.cs