umasteeringgroup / UMA

Unity Multipurpose Avatar
MIT License
726 stars 167 forks source link

NullReferenceException in UMAExpressionPlayer #364

Closed ruben-ivre closed 3 months ago

ruben-ivre commented 3 years ago

Describe the bug When creating the DynamicCharacterAvatar component in runtime and then adding a UMAExpressionPlayer to it, it throws a NullReferenceException in the Initialize method, particularly in these two lines below.

72: avatar.CharacterBegun.AddListener(CharacterBegun);
73: avatar.CharacterUpdated.AddListener(UmaData_OnCharacterUpdated)

The thing is that those events in the avatar component are never properly initialized (apparently it relies on the UI inspector to initialize them), thus accessing them without checking if they're null first is a bad idea. For the moment, we have avoided the exception by commenting out the code that subscribes to the events in the avatar, and instead use the ones in the UMAData component, which are properly initialized.

Environment (please complete the following information):

To Reproduce Steps to reproduce the behavior: In runtime, add a DynamicCharacterAvatar script to a GameObject, and then add a UMAExpressionPlayer to it.

Expected behavior No exception thrown.

Jaimi commented 3 months ago

Replacing expression player in #423