Revert to prefab value does not work

Issue #160 resolved
Stella Delonge created an issue

When a value on a prefab instance has been modified, the property is correctly drawn in bold, also the generic menu item "Revert to prefab value" appears but it is always disabled and always shows (Does not exist on prefab).

Comments (6)

  1. Tor Esa Vestergaard

    Thanks for reporting this issue! I've been unable to replicate this. I can make "Revert to prefab value" show up as disabled, but only in the cases where it should be disabled, namely, when the corresponding property does not exist at all on the prefab.

    For example, suppose you have a struct "Foo" with a string "Bar" in it. Say a prefab has an empty "Foo" array, and you've added a Foo element to that array in an instance of that prefab. The new "Foo" element, and the string "Bar" in that element, will be bold. However, if you were to right-click that Foo element, or if you were to right-click the string "Bar" in that element, the "Revert to prefab value" would be disabled, and would show "(Does not exist on prefab)" - because, quite rightly, that property does not exist in the prefab.

    Essentially, when you're saying, "Revert to prefab value" on, say, the "Bar" string on the 0th element in the prefab instance array, then you're telling it to adopt the value that exists in the "Bar" string on the 0th element in the prefab's array. However, that element doesn't exist on the prefab. The path "fooArray.$0.Bar" has no meaning on the prefab, no value exists to revert to. So the option is disabled. You'll need to either remove the entire "extra" collection element you want to revert, or find the collection that your property is in, and then right-click that, and click "Revert to prefab list length".

  2. Tor Esa Vestergaard
    • changed status to open

    Whoops, that was a misclick - I want to make sure it's not an error first. Please let me know whether my explanation above accounts for the issue you're having :)

  3. Stella Delonge reporter

    Thank you for your quick reply, unfortunately that does not relate to my issue, in my case "Revert to prefab value" is disabled even for a simple single int property:

    Screenshot.png

    I created a new, empty Unity Project, imported Odin from the Asset Store, created an empty game object and added the script testRevertToPrefab, which is simply

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class testRevertToPrefab : MonoBehaviour {
    
        public int i;
    }
    

    I then created a prefab from the GameObject, and edited the int in the prefab instance in the scene to 3. The property is now correctly displayed as bold and the entry "Revert to prefab value" appears but always shows up as disabled.

    I have tried this using both Unity 5.4 and 5.5 with the same result.

  4. Tor Esa Vestergaard

    Ah, thank you very much, that helped me replicate it! It only happened on non-Odin-serialized objects. I've implemented a small fix, but it required a change that I'd like to take some time to verify didn't break anything else. However, if getting the fix is urgent for you (seems rather benign, though), you can send me your invoice id at tor@sirenix.net, and I'll shoot you a build with the fix included. Otherwise, it'll be in the next patch.

  5. Log in to comment