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

[BUG #1127653] Prefab variant's hierarchy is in the wrong order after the base prefab is modified

Discussion in 'Prefabs' started by VincentPaquinUbiant, Feb 19, 2019.

  1. VincentPaquinUbiant

    VincentPaquinUbiant

    Joined:
    Nov 6, 2018
    Posts:
    9
    Hello !
    We have encountered an issue that breaks the sibling indices in prefab variants in very specific reproduction cases. (which is particularly affecting when using Unity's UI, since depth is defined by hierarchy by default)

    EDIT : https://issuetracker.unity3d.com/is...ab-while-prefab-variant-is-not-in-the-project issue is now tracked.

    Short version:
    1. Create a prefab BASE
    2. Create a prefab VARIANT with a child gameObject Variant's child
    3. Save
    4. Move VARIANT.prefab and VARIANT.prefab.meta out of the project
    5. Modify BASE by adding a child gameObject Base's child
    6. Put VARIANT.prefab and its meta back in the project.
    7. Variant's child's sibling index is 0 and Base's child sibling index is 1. It should be the other way around.

    Why would you do that?

    At first, taking the prefab file and moving it out of the project before modifying the parent sounds like looking for trouble. Here's our situation :

    We are working on multiple projects, all of which are following the same strict UI guidelines.
    Our UI prefabs are stored in a git submodule, and are shared between all projects.

    So, for example, we have 3 repositories :
    Project A, Project B and UI
    Project A
    and Project B both include UI as a submodule.
    1. Someone creates a variant of UI's "Popup.prefab" in Project A.
    2. Someone else creates another variant of UI's "Popup.prefab" in Project B.
    3. A new guideline for UI's "Popup.prefab" is given. "Popup.prefab" is modified from Project A, and pushed the change to UI.
    4. All the variants in Project B have a broken hierarchy, since those variants weren't accessible by Unity when Popup.prefab has been changed in Project A.
    Example

    We have reproduced the issue in a project that can be found HERE ( https://drive.google.com/file/d/1pMY5rKJIp6JstdTcwEdDdDB6JlSGQwBz/view?usp=sharing ), I have also provided an image of said project trying to illustrate the issue.​
     

    Attached Files:

    Last edited: Feb 21, 2019
    aurelien-morel-ubiant likes this.
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,195
    You should report bugs through the in-editor bug reporter, as those are more likely to be followed up than a forum post.
     
    runevision likes this.
  3. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    He did it but he forgot to mention the bug number in the title
     
  4. VincentPaquinUbiant

    VincentPaquinUbiant

    Joined:
    Nov 6, 2018
    Posts:
    9
    Right! Sorry, edited the title to reflect this, thank you.
     
  5. VincentPaquinUbiant

    VincentPaquinUbiant

    Joined:
    Nov 6, 2018
    Posts:
    9
    Edited and added related issue tracker link.
    Thanks Unity QA!
     
  6. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    259
    Sorry to necro this, but this is the only post i've found that reflects the issue i'm currently experiencing. It seems to still be present in 2019.3 (and id assume 2020 as well).

    My setup:
    1) I have prefab base, from which i create prefab variants
    2) In that prefab base, there is a TextMeshProUGUI textfield .
    > This also means that in the Prefab Variant there is 'the same albeit overridable' TextMeshProUGUI textfield.

    3) This TextMeshProUGUI textfield creates "TMP SubMeshUI" in edit mode. This seems to be TMPPro 'feature', and i can't seem to prevent it.

    There seems to be an issue in having the prefab base's "TMP SubMeshUI" in prefab variant or apply them to prefab base, as then TextMeshProUGUI seems to create additional "TMP SubMeshUI"s, resulting visually in duplicate "TMP SubMeshUI"s (this is in EditMode). So i am left with removing the "TMP SubMeshUI"s during EditMode, and let TMPPro 'recreate them' during playmode (triggering the Unity bug of child reordering the prefab variants - see step 4).

    4) The prefab variants are organized into a Layout Group, which orders by childIndex. Now whenever launched in Playmode, TextMeshProUGUI creates it's "TMP SubMeshUI" in the base prefab (or variant?), which causes the indexes to shuffle in the LayoutGroup. When i replace my variants with simple prefabs, or unpack completely, there is no issue. The issue only manifests when using Prefab Variants (in the UGUI, unsure about outside of UGUI).

    I voted on the bug tracker, let's hope this gets fixed :rolleyes:
     
    Last edited: Feb 25, 2020
  7. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72