Daniel Lip
Daniel Lip

Reputation: 11325

What is the difference between prefab(original) and variant prefab?

I have a door I created with some colors shader and more. When I dragged the door some time ago and it asked me what to do I selected variant. But now I decided to select to create original prefab and the door colors or maybe it's the shader become pink.

This is a screenshot of the prefabs the original and the variant in the Assets. The one in pink is the original the one in red and it should be in red is the variant.

What is the difference between prefab(original) and variant prefab and why it's changing the color to pink when making original ?

What should I choose ? Original or variant ?

Prefabs

And a screenshot of the door in the scene view window before dragging it to the Assets :

Door

Upvotes: 8

Views: 16343

Answers (5)

user25638768
user25638768

Reputation: 1

Others explained what the difference is between original and variant prefab (which is how I landed here in the first place) but, even though I have very limited unity knowledge, I might know what to do about those pink doors if anyone has an issue like that. You go into Materials and find the pink material, select it, then go to Edit -> Rendering -> Materials -> Convert Selected Build-in Materials to URP. I ran into this issue when importing 3D-Models, all of their surfaces were pink but I managed to figure out this solution, not sure if the same has happened in this case though

Upvotes: 0

LachoTomov
LachoTomov

Reputation: 3708

A prefab variant is useful when you create a prefab based on another prefab.

For ex. a prefab "Car", and you use it to create another prefab - "Electric Car". Unity will ask you whether you want to create "Electric Car" as a variant or an original prefab - and here is the difference.

If you choose prefab variant, the link between "Electric car" and "Car" will be kept, so:

  • when you edit the "Electric car" prefab, you'll also be able to open the "Car" prefab from there
  • when you change some value in "Car" prefab, "Electric car" will receive the change

If you choose original prefab, the link between "Electric car" and "Car" will be lost, so:

  • when you edit the "Electric car" prefab, you will NOT be able to open the "Car" prefab from there
  • when you change some value in "Car" prefab, "Electric car" will NOT receive the change

Upvotes: 0

Daniel Ho
Daniel Ho

Reputation: 31

It seems that your original on the right is edited and saved, such that the shader/texture on the glass area is misconfigured.

In this sense you should fix the original as it is broken, by replacing it with your variant.

Variant is meant for example, create different versions of your original doors with different colour glass, or animate animation timings via inspector values so that you can reuse the same prefab, but use it for different stages.

Upvotes: 0

ChoopTwisk
ChoopTwisk

Reputation: 1334

If you're a programmer, think of it like Polymorphism, where you have a base class with properties all children will share, but they can still override these properties (pink color became red) and they can have their own properties as well, in prefabs Original is the base class, Variant is a child, adding properties to the base class, the child inherits them.

If you're not a programmer, think of it like the Original prefab to represent any empty house(house original), the variant is a house with some furniture in it, lets say a kitchen and a sofa(house 1) And another house(variant) created from the original but with only a TV (house 2).

Now if you were to change the wall colors of (house original), then (house 1) and (house 2) will have these colors.

Summing it all up, original/variant prefabs are usefull when you want to have a prefab from which there are derivatives but they'd all share some function/some property/some position/some value, so instead of having to go and change a value on all derivatives, you simply change it on the original.

Upvotes: 7

Milos Romanic
Milos Romanic

Reputation: 457

Just like you have a regular prefab in order to have a predefined object, you have prefab variants which is just another level. It represents the need to have different predefined versions of the prefab itself. Prefab variants are usefull when you don't want to override the base prefab, but you want to use the overrided one multiple times, so you make a prefab variant.

https://www.youtube.com/watch?v=ibmdm_PoyMA

So basically when you have a prefab instance and you make changes to it, you can either override the original prefab (losing its original state), or you make a prefab variant and then you can have both of them as prefabs.

Upvotes: 10

Related Questions