Unity-Technologies / guid-based-reference

A component for giving Game Objects a GUID and a class to create references to objects in any Scene by GUID
Other
625 stars 71 forks source link

GUIDs may be modified automatically without being detected by Unity #8

Open schmid opened 5 years ago

schmid commented 5 years ago

Example: when adding a GuidComponent to a prefab, prefab instances in Scenes will be modified, but the Scene will appear unmodified. Adding Undo.RecordObject before every call to CreateGuid resolves the issue for me:

In GuidComponent.cs, add the following:

    void Awake()
    {
        Undo.RecordObject(this, "Update GUIDs in Scene");
        CreateGuid();
    }

    void OnValidate()
    {
        Undo.RecordObject(this, "Update GUIDs in Scene");

#if UNITY_EDITOR