Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question why prefab variant Overrides base prefab ?

Discussion in 'Prefabs' started by a33366, Aug 20, 2023.

  1. a33366

    a33366

    Joined:
    Jul 26, 2017
    Posts:
    26
    I have a prafab UIBase and prefab variant UIMainPanel
    I added a Class UIMainPanel (same name as the prefab variant) to the UIMainPanel prefab variant
    Unity Overrides display Apply All to Prefab Variant parent button When I click it,He adds class UIMainPanel
    to the Base prefab
    • I'm confused. Don't I use the prefab variant because I want it to have unique attributes?
      If I every prefab variant "Apply All to Prefab Variant parent," wouldn't it be messy?
      The blue bar next to the property also suggests that I should apply
      My English is not good, I use the translation software sorry
     

    Attached Files:

  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    If you don't want to apply changes to the base dont press the button doing exactly that. The labels says "Apply All to Prefab Variant parent". Parent of the prefab variant is the base.


    No that's not what the blue bar means. Blue bar means that you have changes either between prefab variant and prefab base if you are currently in prefab editing mode or the scene instance and prefab or variant if you are within scene.

    As you said yourself you made the the variant because you wanted to have some unique attributes so it's fine to have some differences which will be indicated by the blue line. They don't have to be applied. It is up to you to decide which changes you wanted to apply to base, which ones you meant to apply only to variant, and which ones were accidental and you want to revert.


    Your misunderstanding probably came due to working with prefab(or prefab variant) instances within scene. You usually want avoid having scene instances modified beside the position. But even that's not universally true, since when editing a level you might want to make changes to a specific instance. Like one specific enemy dropping a certain item or connecting a button to specific door. In the later case you wouldn't even be able to apply those changes since the reference to other scene objects only makes sense within scene, and prefabs can't refer to scene objects.
     
  3. a33366

    a33366

    Joined:
    Jul 26, 2017
    Posts:
    26
    Thank you for your reply.
    It's probably the mental effect of the plus sign and the blue bar always feeling like I should Apply All to Parent Prefab
    And I methinks that this feature should only allow the parent Preafb to Preafb variant and not Preafb variant to affect the parent Preafb