0
Answered

Is it possible to have multiple arguments in custom units?

Skypatcher 2 years ago updated 2 years ago 9

I really enjoy using Bolt. Some units in Bolt has variable number of arguments; they are really user-friendly. Other units can also benefit from the same design; eg. Bolt has multiple versions of string concatenation units.

Unless there is significant extra overhead, I like to use variable arguments in my custom units. Is it possible to do it now? If not, can I do it using scripts? or is there a plan for it in the near future?


Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
GOOD, I'M SATISFIED
Satisfaction mark by Skypatcher 2 years ago

Sorry about the mistake in the question. I mean variable number of arguments, not multiple arguments. Unfortunately, I can't edit my own question.

You should be able to edit your own question from the menu on the far left.

Hi William, I don't see any intractable UI elements in the menu on the far left. It seems strange because I can edit my own response to a thread, but not my original thread.

+1

It was there. There may be a time limit or it may disappear when you leave that page. Take a look next time you create a post. Trust me, your not the 1st to get confused by it myself included, ha. Oh, forgot, that would be if you are on a Pc, if a phone or tablet then the options will be different. 

Ok, thanks for the info. I am on a PC. Looks like I am stuck with the misleading question!

+1

Trust me, Lazlo or whoever answers will know what you meant and read it all.  To be clear, what do you mean when you are saying variable units? Since you said you did not mean multiple, i.e.: more than 1 argument with an output port, are you referring to using actual variables?

Glad you asked, should have provided an example in the original post. The number of inputs in the Formula unit can be changed any time after the unit is lay down on the graph area. That is super convenient!

Right now Bolt has 1 unit for concatenating exactly 2 string arguments, another one for exactly 3 arguments, and still another one for exactly 4 arguments, but not for 5 or more arguments (it does have one for array). It seems it would be much more flexible if it has a single unit that can be set to concatenate any number (say between 1 and 9) of string arguments.

Right now, I am designing several units that all have variable number of arguments. I really want to avoid creating multiple versions of essentially the same units again and again. It is hard to maintain and inconvenient to use because my user case require flexible number of connections between units.

+1
Answered

Hi Skypatcher, welcome to the community! :)

It is possible to create custom units with variable number of inputs, but it requires scripting. Super units / macros do not have variadic input options or configurable unit settings.

The documentation for extending the Unit class is not yet written, but it is planned on the roadmap. In the mean time, if you want pointers, you can join us on #scripting-api on Discord.

For your specific example, a user has already created a string format node that takes a variable number of arguments, and allows for much more than concatenation. (It's actually so good that I might include it in the main source!). Users have access to all the same scripting API as the built-in units you see, so nothing is off limits.

Hi Lazlo, thanks! I'll join you guys on #scripting-api