Loading XR Avatar with RealtimePrefabExtensions

hello I have created the prefabloaddelegate script for loading other objects besides the avatar , but when the avatar is called i get a warning that the avatar prefab doesn't exist in our list of preloaded assets, it still loads async but id like to do away with the warning , i have also added to my prefabloaddelegate list but still throws the error my delegate script is attached
3 Replies
kapa.ai
kapa.ai8mo ago
Hi @Lost Wizard Corp.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided, it seems like the avatar prefab is not being preloaded correctly, hence the warning message. Here are a few things you can check: 1. Prefab Name: Ensure that the prefab name you're using to load the avatar matches exactly with the name in the _realtimePrefabsToPreload list in your CustomPrefabLoadDelegate script. Remember that prefab names are case-sensitive. 2. RealtimeAvatar Component: All avatar prefabs that are used with RealtimeAvatarManager need to include a RealtimeAvatar component on the root of the prefab. This component is responsible for synchronizing the head and hands positions and active states. Make sure your avatar prefab has this component. 3. Preloading: In your CustomPrefabLoadDelegate script, you're preloading all the assets in the _realtimePrefabsToPreload list. Make sure that the avatar prefab is included in this list and that it's being preloaded correctly. 4. Asset Loading: If the prefab isn't preloaded, it will be loaded synchronously, similarly to how the default Resources.Load<GameObject>() implementation works. This could be the reason why you're seeing the warning message but the avatar is still loading correctly. Here's the relevant part of the CustomPrefabLoadDelegate script for reference:
public class CustomPrefabLoadDelegate : MonoBehaviour, IRealtimePrefabLoadDelegate {
[SerializeField]
private List<AssetReference> _realtimePrefabsToPreload = new List<AssetReference>();
private Dictionary<string, AsyncOperationHandle<GameObject>> _assets;

private void Start() {
// Preload all assets
_assets = new Dictionary<string, AsyncOperationHandle<GameObject>>();
foreach (AssetReference assetToLoad in _realtimePrefabsToPreload) {
if (assetToLoad.RuntimeKeyIsValid() == false)
continue;

string key = assetToLoad.RuntimeKey as string;
if (key == null)
continue;

_assets.Add(key, Addressables.LoadAssetAsync<GameObject>(key));
}
}
public class CustomPrefabLoadDelegate : MonoBehaviour, IRealtimePrefabLoadDelegate {
[SerializeField]
private List<AssetReference> _realtimePrefabsToPreload = new List<AssetReference>();
private Dictionary<string, AsyncOperationHandle<GameObject>> _assets;

private void Start() {
// Preload all assets
_assets = new Dictionary<string, AsyncOperationHandle<GameObject>>();
foreach (AssetReference assetToLoad in _realtimePrefabsToPreload) {
if (assetToLoad.RuntimeKeyIsValid() == false)
continue;

string key = assetToLoad.RuntimeKey as string;
if (key == null)
continue;

_assets.Add(key, Addressables.LoadAssetAsync<GameObject>(key));
}
}
If you've checked all of these and you're still seeing the warning, it might be a good idea to debug your CustomPrefabLoadDelegate script to see why the avatar prefab isn't being found in the _assets dictionary. For more information, you can refer to the Using Addressables (https://normcore.io/documentation/guides/recipes/using-addressables) guide and the RealtimeAvatar (https://normcore.io/documentation/realtime/xr/avatars#realtimeavatar) documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai8mo ago
<@1220362612794069042> kapa.ai is still learning and improving, please let us know how it did by reacting below
Lost Wizard Corp.
Lost Wizard Corp.OP8mo ago
@kapa.ai it seems the RealtimePrefabExtensions is loadinf the prefab and doesnt see the delegate load list perhaps