+3
Fixed

Object variables on prefab instances reset when assigned from the variables window

Lazlo Bonin (Lead Developer) 3 years ago updated 3 years ago 10

The current workaround seems to be setting the variables directly from the variables component inspector instead of the variables window.

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

when I add a variables and Select one type  ,then  do not write anything 

Select another obj and come back 

you can see the variables resetting

That is normal, and that's not the issue related to this bug report.

In what you're talking about, only the type resets. This bug refers to the whole variable disappearing, or its value resetting.

Basically, what you're seeing is how Bolt variables handle null values. If you give a variable a type that allows null (for example GameObject), then leave that value at null (for example None), all that is saved is that this variable is Null, not that this variable is a Null GameObject, because both are equivalent.

(In programmer terms: Bolt variables are not type safe, so there is no way to serialize the type for a null value).

+2

After some quick testing on Unity 2017.2, I believe this issue is only happening on Prefab Object variables.  If you set an object variable on a prefab and don't click "Apply" on that prefab, then it resets the prefab on play and removes the variable.

+1

I can confirm that variable added from variable window on a prefab disappears on play. Clicking "apply changes" for prefab, just after adding variable, fixes that issue.

+1

It seems you're right, I've been able to reproduce and I'll investigate further.

+1

Hi, Just running through the Bolt Platformer Tutorial and hitting this bug. The speed variable disappears and hence cannot move the player on first play :(

But, I also just wanted to add that this bugs affects *removing* variables from the variables window too. I tested by creating a Boolean variable on the Variable component - all OK when enter play mode. Then, I removed the variable in the variables window, hit play, and BOINK - it's back again...

+1
Fixed in Alpha

Finally, I think I got it fixed for next version! Had to use this obscure method: 

PrefabUtility.RecordPrefabInstancePropertyModifications