Astra Unity 2.6.6
Astra Unity Plugin
Examples/Avatars/LoadAnyUserAvatarByGuid.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Astra.Asset;
namespace Astra.Examples
{
public class LoadAnyUserAvatarByGuid : MonoBehaviour {
public TextAsset Config = null;
public string Guid;
void Start () {
Configuration.ProjectConfigJob initJob = null;
if(Config != null)
{
initJob = Configuration.Initialize(Config);
}
if(initJob != null)
{
//we have a config so wait for boot then load
initJob.OnJobDone += (_) =>
{
LoadMyAvatar();
};
}
else
{
//no need to boot, just load right now
LoadMyAvatar();
}
}
protected void LoadMyAvatar()
{
var options = new AvatarLoadJob.AvatarLoadOptions {
guid = Guid, //the guid of the avatar we want to load
userAndAppOnly = false, //tells the system to look globally in the user space
avatarItem = null //if you had a ref already you could use it here
};
var job = Loader.LoadAvatar(options);
job.OnJobDone += (_) =>
{
if(_.wasSuccess == false)
{
Astra.Logger.LogError("Failed to load avatar: " + Guid);
return;
}
var result = job.GetResult();
Astra.Logger.Log("Loaded avatar: " + result.AstraName + " : " + result.AstraGuid);
};
}
}
}
string Guid
A known guid, but the user may or may not be the logged in user
Definition: LoadAnyUserAvatarByGuid.cs:19
TextAsset Config
If not null will init the config
Definition: LoadAnyUserAvatarByGuid.cs:14
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
static void Log(object message)
A one-to-one with UnityEngine.Debug.Log, records as Info level
Definition: Logger.cs:99
Definition: AnimationManager.cs:10
Definition: AnimatingAnAvatar.cs:9
Definition: AnimationManager.cs:10