Spawning a prefab with AssetReference.InstantiateAsync
(in Addressables 1.18.4) calls Awake
, OnEnable
, and OnDestroy
twice
In Addressables version 1.18.4 and 1.18.2, spawning a prefab with AssetReference.InstantiateAsync
calls the Awake
, OnEnable
, and OnDestroy
events multiple times per attached MonoBehaviour
. To reproduce:
- Open the attached SampleScene
- Enter play mode
- Exit play mode
- Look at the console. You will see 8 log entries which should look something like this:
SpawnedObject.Awake(<instance ID>)
SpawnedObject.OnEnable(<instance ID>)
SpawnedObject.Awake(<different instance ID>)
SpawnedObject.OnEnable(<different instance ID>)
SpawnedObject.Start(<different instance ID>)
SpawnedObject.OnDestroy(<instance ID>)
SpawnedObject.OnDisable(<different instance ID>)
SpawnedObject.OnDestroy(<different instance ID>)
The expected behavior is that there are only 5 log entries, one for each event that SpawnedObject
implements (and each entry should display the same instance ID).
Other important facts:
-
I am using Windows 10 and Unity 2021.1.6f1.
-
I have not tested this on other operating systems or Unity versions.
-
This does not occur on Addressables 1.17.17.
-
This happens on multiple build platforms.
I already reported it directly with the bug reporter, but I’ve posted it publicly to save others time in troubleshooting.
This is a pretty major bug. Come on guys, I know you’re better than this.
7138700–853709–Addressables Bug.zip (22.4 KB)