Search Unity

Bug Resources.FindObjectsOfTypeAll has varying results

Discussion in 'Editor & General Support' started by Sundiray, Oct 24, 2020.

  1. Sundiray

    Sundiray

    Joined:
    May 6, 2019
    Posts:
    16
    I have a prefab in my project that is not in the scene hierarchy and if I haven't selected the prefab yet in the session the method is unable to find it but after I have selected it once (and even changed selection) it does include the object. Is this a confirmed bug or am I missing something?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,907
    Not a bug. FindObjectsOfType will only find objects that have been loaded into memory. In a build, the prefab won't be loaded into memory until something else that references it is loaded, or you load it in some other way such as Resources.Load.
     
    Sundiray likes this.