Closed amokto closed 6 months ago
Are you running one of our example scenes? EG AvatarCreatorWizard or AvatarCreatorElements
When I try to replicate your issue in Unity 2022.3.20 RPM Core version 6.2.1 using our AvatarCreatorWizard sample scene, everything works as expected and I don't have this issue.
If this issue is occurring on your own custom made samples it might be that there is an issue with your logic, for example not getting correct authorization before attempting to fetch the templates.
Thank you for the quick response and for checking the issue, as mentioned the issue we have on iOS is related to GetTemplates() from the AvatarTemplateFetcher class. This method does not appear to be used in the example scenes you mentioned, which might explain why the issue wasn't replicated in your tests.
Using your AvatarLoading sample and AvatarLoadingExample I made a function that hopefully can assist you on replicating the issue on your side:
private void Start()
{
ApplicationData.Log();
LoadTemplateAvatar();
}
private async Task LoadTemplateAvatar()
{
await AuthManager.LoginAsAnonymous();
Debug.Log("User Session ID : " + AuthManager.UserSession.Id);
if (!AuthManager.IsSignedInAnonymously && !AuthManager.IsSignedIn)
{
Debug.LogError("Failed to sign in.");
return;
}
using var avatarManager = new AvatarManager();
List<AvatarTemplateData> templates;
try
{
templates = await new AvatarTemplateFetcher().GetTemplates();
}
catch (Exception e)
{
Debug.LogError($"Failed to fetch templates: {e.Message}");
return;
}
var template = templates[Random.Range(0, 5)];
Debug.Log($"Selected template: {template.Id}, Gender: {template.Gender}, ImageUrl: {template.ImageUrl}");
if (string.IsNullOrEmpty(template.Id))
{
Debug.LogError("Template ID is empty.");
return;
}
var avatarCreationResponse = await avatarManager.CreateAvatarFromTemplateAsync(template.Id, BodyType.FullBody);
if (avatarCreationResponse == null)
{
Debug.LogError("Avatar creation failed.");
return;
}
avatar = avatarCreationResponse.AvatarObject;
var animatorAvatar = AvatarAnimationHelper.GetAnimationAvatar(avatarCreationResponse.Properties.Gender, avatarCreationResponse.Properties.BodyType);
if (animatorAvatar != null)
{
avatar.GetComponent<Animator>().avatar = animatorAvatar;
}
}
I believe this issue is caused the "Managed Stripping Level" setting in the Player settings. I was able to replicate your issue when this setting was set to "Low" but if I change it to "Minimal" it works as expected. In seems that Unity is mistakenly removing some API's that it thinks arent used. We will look into a fix for the future, but for the time being you should just be able to adjust this build setting.
Thanks for the workaround! I just made a build to test it and it works as expected now.
Describe the bug On iOS devices, when attempting to fetch template IDs using the GetAvatarTemplates() method, the templateId returned is consistently empty or null, despite working correctly in the Unity Editor and on Android devices.
Files None attached. Since the issue involves template fetching.
To Reproduce Steps to reproduce the behavior:
Build and run app on an iOS device. Trigger the function that calls GetAvatarTemplates(). Observe that the templateId returned is empty or null. Compare behavior with Android and Unity Editor where the templateId is correctly fetched.
Expected behavior The expected behavior is that the templateId should be correctly fetched and populated similarly across all platforms including iOS, just as it works within the Unity Editor and on Android devices.
Screenshots Not applicable.
Desktop (please complete the following information):
Additional context I have attempted to address the issue by disabling App Transport Security (ATS) on iOS, but the problem with the empty templateId persisted despite this change. I added debug logs for other template attributes such as gender and image url, and they are successfully retrieved and function as expected across all platforms including iOS.