umasteeringgroup / UMA

Unity Multipurpose Avatar
MIT License
743 stars 169 forks source link

Loading/Saving functionality using AvatarDefinition overrides DNA values to 0.5 across the board. #456

Open darljan opened 1 month ago

darljan commented 1 month ago

Describe the bug Loading/Saving functionality using avatarDefinition and compressed strings overrides DNA values to default values of 0.5.

Environment (please complete the following information):

To Reproduce Steps to reproduce the behavior:

Expected behavior When loading the recipe using AvatarDefinition, the DNA values should be loaded correctly, not overriden to default values.

Screenshots Screenshot 2024-10-01 160600 Screenshot 2024-10-01 160640

Additional context The _avatar.LoadAvatarDefinition(adf) function does not seem to be working correctly. The flags do not seem to be affecting the result. I debugged a bit further, and the problem lies withing LoadAvatarDefinition function, not BuildCharacter, that method works as intended, in LoadAvatarDefinition(), the optional flags do not seem to do anything, and I get my DNA values overriden to default values.

The PreloadDNA() function in LoadAvatarDefinition does seem to pickup correct values for the DNA, and it is added to List PreloadValues. I just cant seem to find the moment it overrides it to default values.

The way I save my recipes is like this: myRecipe = _avatar.GetAvatarDefinition(false).ToCompressedString("|"); which deviates from documentation, if the flag in GetAvatarDefinition is set to true, the DNA values do not get picked up.

Jaimi commented 3 weeks ago

I am not seeing this. Can you test using the included testscript? Drop it on any gameobject in the scene. Set the avatar.

Then at runtime, it should put three buttons in the middle of the screen.

Change a bunch of DNA. Then choose "Save with DNA" The press "Reset DNA" (should go back to the defaults) Then choose "Restore from text".

It should set the DNA back. If it doesnt (it does for me) then there is likely some unexpected error in the setup on the character (does the base race recipe have the DNA assigned?), or maybe an event is firing off and setting up some DNA?

If it does work like you expect, then there is some coding issue going on.

TestScript.zip