Hard references to prefabs are converted to weak references at build time.
Copy the UnityWeakReference folder in to your project. Use WeakPrefab/WeakSprite/WeakTexture2D/WeakAudioClip in your MonoBehaviour/Array/List/Custom Class and fill out the field in the editor. All set!
public WeakPrefab MyPrefab;
void Start() { Instantiate(MyPrefab.Prefab); }
- Prefab/GameObject
- Sprite
- Texture2D
- AudioClip
- If used in a script in the project view, the referenced object will be added to the build even if the reference holder is not.
- To speed up the processing it looks MaxDepth layers down. The lower the faster, but deeper nesting needs higher. Default is 5.