+1
Fixed

Creating new variables on prefabs causes them to reset on play sometimes

GhostAegis 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 4 1 duplicate

I think this might be a bug, but it's very irregular and I can't quite nail it down.

I have a number of prefabs with macro flow graphs on them. All have a variety of object variables saved on them as part of the prefab. If I add a new object variable to the prefab while it's in a scene, set its type and value, and go into play, the variable type and value reset to null. 

If, however, I update the prefab with the new variable before entering play mode, then it works fine and the variable transfers into play no problem.

Note, this doesn't seem to happen every time. Sometimes it's okay and doesn't require that I update the prefab for it to transition to play mode. Also, it seems to happen more often with certain types: Audio Clip in particular.

Currently on Bolt 1.2.3 and Unity 2017.3.0f3

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

Duplicates 1

Pending Review

Hi GhostAegis,

Prefabs are tricky, so I need some precisions here.

  • After adding the variable to the prefab instance, are you applying the changes to the prefab?
  • Is it only the type / value that revert to null or does the entire variable disappear?
  • Was the value of the variable set to (None) before entering play mode?
  • What do you mean by "update the prefab with the new variable"?
  • After adding the variable to the prefab instance, are you applying the changes to the prefab?

No, not initially. Applying the changes generally stops the variables from resetting. But that's not great for testing.

  • Is it only the type / value that revert to null or does the entire variable disappear?

The variable stays on the object in play. Only the type/value revert to null on play when this happens.

  • Was the value of the variable set to (None) before entering play mode?

No, none of the variables were ever set to none. Each had a value before entering play.

  • What do you mean by "update the prefab with the new variable"?

Sorry, I should have been more clear. As I'm working in a large project with many components, I'll often test out changes to a prefab and validate it in a blank scene before propagating it through the project by applying the changes.

So the process is generally: drag a prefab into a scene, tweak the macro being used on it, then add one (or more) new variables to the prefab that's in the scene. Then, when I hit play in order to validate my changes, the new (unapplied) variables lose their values and type, but any OLD variables that are part of the prefab are fine. Only when I apply the changes with the new variables to the prefab will the new variables begin retaining their values on entering play.


Fixed in Beta

Sorry for the late reply on this. Thanks for the additional information.

I believe this was fixed in v.1.3b3 along with issue #1304. Please feel free to comment again if you have this problem again afterwards.