+3
Fixed

Objects set in the Inspector in Edit Mode immediately set to null on play

Robautomatic 2 years ago updated by Surrealism 11 months ago 9

Hi, I may be doing something wrong as I'm still learning Bolt's unique process to working, but I'm perplexed by an issue that seems to work against common practice even with other visual scripting kits:

Setting any variable in the inspector in Edit mode works as expected, but when playtesting, it immediately throws it null. I know variables aren't strongly typed as I've read in other question responses and that makes sense to me.


But if, for example, I'm dragging a GameObject directly in the object variables list in the graph's inspector, why doesn't it stick upon play? It will immediately go null, making any graph that is using the variable instantly useless, as seen below:




Especially if I have no need to do any object reference grabs if I'm just prototyping? It seems counterintuitive and defeats the purpose of setting your references in the Editor's Inspector.

If I'm missing the correct way I should be setting variables in the Inspector or is if this behavior is a bug, please let me know, but I assumed I could drag any object into the inspector field and they'd stick like any normal Inspector value upon play. 

Cheers!

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

Nono, you're absolutely right, that should be working.  Bugs can happen, of course, but if we know more about your setup we might be able to help. 

You might want to pop onto the discord chat for some immediate help, or if that's inconvenient can you fill us in a bit?  Is this on a prefab, do you have any custom serializers in the project (such as Odin), is InputController a scene object, etc.


What you're describing should work just fine, but since it's not, we have to figure out why.

Pending Review

Hm, that's odd, it should definitely be working and not resetting.

  • Which version of Bolt & Unity are you using?
  • Where is your graph? (macro, prefab, embed, etc.)
+1

Was there ever a resolution to this issue? I have the same problem right now that only appears to be affecting variables set as type GameObject. Happens both when setting the variable on the object (resets entering play mode) and in the graph (resets exiting play mode).

Unity 2017.3
Bolt 1.2.3

Graph is set as Embed presently.

I'm sure you're aware, but this is still a problem. Any lists found on Prefabs dragged into a scene always have their last entry set to Null upon play. Working around it by having null coalesce in any flows involving lists, but it's not ideal.

I'll look into this further for v.1.3 beta 3. Can any of you isolate reproducible steps to trigger the issue? "It sometimes happens" is actually really hard for me to debug.

Fixed in Beta

I believe this was related to issue #1304. I've fixed that and I can't reproduce the bug here.

Basically, my repro steps are:

  • Create a new variable
  • Set its type to Game Object
  • Drag in a scene game object
  • Press play

The value appears to stay in v.1.3b3, whether or not the object is a prefab instance.

If there was more detail to the reproduction steps, please let me know.

[Solved] it seems some object will still reset it even though it was dragged, so just keep dragging other objects to test out


Hi, I've just encountered this exact same error,

  • Create a new variable
  • Set its type to Game Object
  • Drag in a scene game object
  • Press play

and it went null, was trying to use foreach loop to set a nearest target as gameobject variable, but it failed and cause all the links that is trying to get info from the variable to have error