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.

Bug Nested prefab references breaking when saving parent prefab

Discussion in '2023.1 Beta' started by Xelnath, Mar 15, 2023.

  1. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    400
    Steps:

    1. Setup a nested child prefab sequence like this:
    Parent [SomeMonobehaviour]
    NestedPrefabChild [More prefab and objects, edit properties of SomeMonobehaviour]
    2. Create a scriptable object with a reference to SomeMonobehaviour of the child.
    3. Open the child, make a bunch of changes. Save.
    4. Open the parent, make some changed to SomeMonobehaviour
    5. Save.
    6. ---> references to SomeMonobehaviour (child) as assigned in the scriptable object are now broken.

    Why was this being done? There is a common root monobehaviour in these prefabs which is used to instantiate the prefab with certain network sync settings when the prefab is created. Saving and tweaking these on the scriptable object was a major headache, so the scriptable object was reduced into a simple link to the prefab that could be easily scraped and cached.
     
  2. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    400
    After this reference breaks by the way, attemps to reassign the prefab to the scriptable object more than a couple times will eventually crash Unity.