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

Prefab inner reference breaking down...

Discussion in 'Editor & General Support' started by LightStriker, Jun 11, 2015.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    I just spent a whole day tracking down an issue that on a context reload - such as when pressing "Play" - prefabs would lose all their references. The example I was working on was simply a Canvas with a Scrollbar in it.

    If I do this;

    Code (CSharp):
    1.     [InitializeOnLoad]
    2.     public class ViewCreator
    3.     {
    4.         static ViewCreator()
    5.         {
    6.             EditorApplication.SaveAssets();
    7.         }
    8.     }
    There's a high chance that any already-loaded prefab - like being inspected - will lose all their references.

    In short, SavingAssets on a InitializeOnLoad is a recipe for disaster, which is annoying since I'm auto-generating assets on a reload of code.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    Did you report this as a bug ?
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Not yet... I should. :p

    BTW, reproduced on 4.6.1, 4.6.5 and 4.6.6.