umasteeringgroup / UMA

Unity Multipurpose Avatar
MIT License
739 stars 168 forks source link

When using UMA+Addressables and instantiating DCS Avatar a MissingReferenceException can be thrown #346

Closed veriok closed 3 years ago

veriok commented 3 years ago

Describe the bug When using UMA as a character model in fairy complex nested prefab, the error is being thrown during instantating of parent prefab: MissingReferenceException: The object of type 'DynamicCharacterAvatar' has been destroyed but you are still trying to access it. This did not happend when using UMA without Addressables turned on. It also doesn't happening when spawning the same DCS Avatar in either by dragging it to scene or instantating it using simpler monobehaviours.

If we disregard the error, the model is spawned correctly after a frame or two. So it looks like an problem that is between addressable lookup and generating character.

Environment (please complete the following information):

To Reproduce Was unable to reproduce it using simpler context or empty scenes.

Expected behavior The model is generated correctly without any errors.

Additional context Error messages: message(1).txt message.txt

I spoke with Jaimi on Discord Channel, the discussion can be found in #addressables (28.01.2021). There is a dirty fix introduced which helped in my case, but may have some additional side effects:

In line 3403 of DynamicCharacterAvatar.cs: if (activeRace.racedata != null && !restoreDNA && this != null)

In line 3425 of DynamicCharacterAvatar.cs: if (this != null && this.gameObject.GetComponent<Animator>())

In line 63 of UmaAvatarBase.cs: if (umaData == null && this != null)

This prevents the scripts to execute code when the reference is broken/object is destroyed, and after a short while the character is loaded correctly without errors.

Jaimi commented 3 years ago

Fixed in 2.11.6 (pending update)