Object Variables - Prefab versus Instance

celsius9 3 years ago updated by karlis.stigis 2 years ago 3

Apologies if this topic's been covered before, but I'm having trouble locating a reference in the Manual, or elsewhere, to the Object Variable 'Prefab' and 'Instance' tabs? I'm following the Bolt Platformer tutorial and this tab functionality doesn't seem to have existed at the point the tut was made.

Specifically I'm creating a Macro in the MenuLevelButton Prefab that applies to 4 menu buttons in the same scene. When I create an object variable 'Scene' on the graph within the Prefab, any value I later add to my game objects seem to be shared between all 4 game objects, rather than be individual to each. The only way I've found around this seems to be to create the same variable on each game object individually in its 'Instance' tab. This seems rather counter-intuitive within a prefab. I guess what I'm saying is the prefab Object variable seems to be acting more like a Scene variable. What am I doing wrong?

Thanks! Unity 2018.2.13f1, Bolt 1.4.0f9

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Satisfaction mark by celsius9 3 years ago

Hi Celsius! D'oh, you're right, we forgot to update the manual with that update.

Basically, you'll only see the Prefab and Instance tabs when you have a prefab instance selected, e.g. an object in your scene that is linked to a prefab asset. When that happens, both tabs show up to give you quick access to both sets of variables:

  • Instance points to the Variables component on the instance in the scene
  • Prefab points to the Variables component on the prefab definition in your project folder

Basically, if you want to edit the variable for all instances, you should use Prefab. If you want to edit this specific instance only, use Instance. In this specific case, you can use Prefab to define the Scene variable, then use Instance to "override" it for each instance.

Let me know if that's clearer!

(P.S.: We're aware some parts of the variable system are confusing, and we're working on a massive overhaul for Bolt 2, stay tuned!)

Thanks Lazlo - your reply much appreciated. I look forward to seeing what you've done with the variable system, and all else, in Bolt 2!

I'm sorry, but I have the same problem. All prefabs behave the same and at the same time. Can you please make a cleaner explanation or tutorial? Can't find anything on this topic.