Under Review

Variable ideas

Jani Schulze 4 years ago updated 4 years ago 3

After using Bolt for a while, here is my wishlist for variables in graph. Could be that some of the features are already in place, but I just haven't found the correct way. Please feel free to correct me in those cases.

Background: I find it a bit tedious to create Get / Set Object variable nodes and also refactoring object variable names in Variables inspector and keeping track which variables are actually used.

1) Make "Create variables used in Graph" button in Variables inspector. That should examine graph attached and create all object variables used and delete unused variables from the inspector. Flow Canvas / Node Canvas had this. It would help for example in the cases where you copy the graph to another gameobject. You could press the button and have needed variables created automatically (sure you can copy the variables component too, but it is a bit cumbersome). Also you could check that you don't have duplicates or something else (like both CurrentSpeed and currentSpeed variable)

2) Variable name refactoring. Currently renaming a variable don't change variable names in graph. While I can understand there are cases where this is expected functionality, for me most cases I would prefer renaming variables used in graphs also.

3) Have variable palette in the Graph editor fixed in for example in the top left. Sure you can drag & drop from Variables inspector but sometimes you just want to have Graph editor full screen, especially when working on laptop. One could pick variable get or set node from that palette. This node could even use simpler node in which variable name cannot be changed later from the drop down menu / writing it in / connecting input value (I would prefer to lock down graph to prevent accidental changes) . It would show the variable name and have a one output value but if you wanted to change that you should delete it and replace it with another or use regular Get / Set Object variables which give you more flexibility. 

4) Read only variables you can use as constants but not set any new value. I believe this was mentioned somewhere already considered.

5) Maybe connected to 3, I would like to have some scratch pad local variables. Variables would be limited to current object and only to current scope and those would not show/count as actual object variables. It would help in cases where you want something be stored in current scope but don't want to populate object variables with these temp variables.

6) Linking same GameObject Component variables to Object Variables. Similar to Flow / Node Canvas has. Public variable or getter / setter needed on the script side. Bolt would handle updating the variable behind the scenes.

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Regarding 3) where I wrote "...have a one output value..". this for Getters, Setters would obviously have Control input and output and Value input.

Under Review

Hi Jani! Thanks for taking the time to write this feedback.

I'll address each point.

  1. Create Variables used in Graph: This is interesting, but it needs to be defined better. Should it create only graph variables? Or also object, scene, application and saved variables? Should it consider the variables in the child graphs and in the parent graphs?
  2. Refactor Variable Names: Yes, that's definitely planned. See this thread for the ongoing discussion.
  3. Variable Palette: Are you aware of the Variables window? (Window > Variables) It acts as a variable palette, and you can drag / drop from it as well, not just the variable component in the inspector. If by "full screen" you mean Shift+Space on the graph window, this is something that's planned for v.1.4: having the graph inspector & variables window automatically appear on either side of that maximized viewport automatically.
  4. Read Only Variables: I am probably not going to implement this. Bolt has a "naive" approach to variable discoverability (no constant, readonly, private, internal or proptected modifiers) that is intuitive for newcomers. It is up to you to enforce design constraints of not modifying certain variables.
  5. Local Variables: Are you aware of Graph Variables? These are limited to the current graph (not the current object) and cannot be accessed outside of it (even in parent / child graphs). They are the "local" scope in Bolt.
  6. Data-Binding: (I'm assuming this is what you're referring to?) So basically having Bolt copy the contents of a MonoBehaviour property into a variable and vice versa? It's not particularly hard to implement, although I don't see the need, because you could just directly access that field via the reflected get/set nodes in Bolt.

Thanks for the reply. Here are my comments:

1) I basically only use object variables, so I am most interested in those. I know there is a lot to consider, when graphs can have child graphs also and all other variable types. Maybe there isn't a way that just works. And maybe the functionality shouldn't actually create or delete anything, but rather give some info on variable usage by comparing the variables list versus graph with child graphs. So if I accidentally have two object variables like CurrentSpeed and currentSpeed in my previous example, I could see which one is used or both. Something like "Show all references" in text based programming IDEs. 

2) Great

3) Ok, great too, 

4) I totally understand.

5) I somehow assumed that Graph variables are like static variables for given graph type. So actually graph variables are probably what I need.

6) On second thought, I don't think this is very important feature. I do use Bolt in a way that I mix code and Bolt in same gameobject but I usually use Bolt to have state flow and state data (variables) and write public methods in code that Bolt can use. And as you said there are ways to access code variable from Bolt and vice versa.

Thanks again for replies and great product.