Search Unity

2018.3.f2 Prefab overrides are all kinds of wrong.

Discussion in 'Editor & General Support' started by SevenPointRed, Dec 14, 2018.

  1. SevenPointRed

    SevenPointRed

    Joined:
    Feb 3, 2016
    Posts:
    218
    Prefabs keep coming up with overrides that are not overrides, for example the mask interaction on this prefab is the same, it's an enum so there is 100% no way that can be considered an override but it means if i change it in the prefab it is not detected properly as this mystery override exists.

    PrefabIssue.png

    Using revert to prefab works, but as soon as I open the orginal prefab all instances of it come up with the override again.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    You should probably submit a bug if you have a way to reproduce this. I just tried making a prefab that was a simple canvas and a sprite, and I changed an enum values (UI Scale Mode) in various ways, and never ran into the problem you're describing. For example, I had a few instances of my prefab in the scene. I then go into Prefab mode and changed the enum from "1" to "2", returned to my scene, and found all the prefabs had the correct value. I couldn't get in a state where changing the prefab caused an instance in my scene to believe it had an override.

    One case worth pointing out is the following, which probably isn't what you're describing, but which might not be obvious:
    • Prefab instances and prefab have a value of "1" in the enum field.
    • I change one of the instances to have a value of "2" in that field instead. This appropriately shows that the value is overridden.
    • Now I go into prefab mode and change the value to "2" for the whole prefab.
    • I return to my scene, and that prefab instance I originally modified has "2" as its enum values, but the field still shows as overridden, even though the value is the same as the prefab itself.
    This is really good behavior that was sorely lacking in the old prefab system. This means that prefab instance fields remember they're overridden even if they happen to have the same value as the prefab at some point in the future. This prevents really annoying problems like overriding an instance to use the value of "2", then changing the prefab from "1" to "2", then changing the prefab back to "1" again. In the old system, the prefab instance would have considered itself not to be overridden as soon as the prefab's value was set to "2", cause it to also change its value to "1" when the prefab's value was changed back to "1". Under the new system, the value stays overridden regardless of what you do to the prefab, which makes things much more stable.
     
  3. SevenPointRed

    SevenPointRed

    Joined:
    Feb 3, 2016
    Posts:
    218
    "This means that prefab instance fields remember they're overridden even if they happen to have the same value as the prefab at some point in the future"

    I think I am running into this, I agree its really good but its become an issue with my current system.
    I have a script that runs over everything and updates the state of some masking based on platforms or screensizes etc, this means every time i run that script it marks everything as an override even if the value didnt change.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Could you just add a small bit of logic to that code that leaves the field unchanged if it already has the value you're about to assign to it?
     
  5. SevenPointRed

    SevenPointRed

    Joined:
    Feb 3, 2016
    Posts:
    218
    Not really as when i do builds for each platform it will change it, so they will always be changed based on the target platform. I guess its fine, I understand why it does it. Just need to change how i work with prefabs.