using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimatingAnAvatar : MonoBehaviour {
public AvatarItem
Avatar =
null;
public RuntimeAnimatorController
Animation =
null;
void Start () {
{
LinkAnimation();
return;
}
var queryJob = Catalog.GetAvatars();
queryJob.OnJobDoneMain += (_) =>
{
var result = queryJob.GetResult();
var rand = UnityEngine.Random.Range(0,result.Count);
var catalogEntry = result[rand];
var avatarJob = Loader.LoadAvatar(catalogEntry);
avatarJob.OnJobDoneMain += (__) =>
{
Avatar = avatarJob.GetResult();
LinkAnimation();
};
};
}
void LinkAnimation()
{
Avatar.AnimationManager.GenerateHumanAvatar((
bool success) => {
if(!success)
{
return;
}
var animator =
Avatar.GetComponent<Animator>();
animator.runtimeAnimatorController =
Animation;
});
}
}
}
AvatarItem Avatar
Provide an existing AvatarItem in your scene by dragging it into this reference
Definition: AnimatingAnAvatar.cs:20
RuntimeAnimatorController Animation
This is the animation that we'll be loading onto the Avatar, you must provide your own
Definition: AnimatingAnAvatar.cs:25
Handles Astra logging messages in C# allowing filtering and redirection
Definition: Logger.cs:15
static void LogError(object message)
A one-to-one with UnityEngine.Debug.LogError, records as Info level
Definition: Logger.cs:115
Definition: AnimationManager.cs:10
Definition: AnimatingAnAvatar.cs:9
Definition: AnimationManager.cs:10