AvatarRenderLoader
The AvatarRenderLoader class is used for loading a 2D render of the avatar.
You can load a 2D render of your avatar using the Avatar Render Loader class which obtains a rendered image of your avatar via the Render API.
Property | Type | Description |
---|---|---|
Timout | int | Set or get the timout in seconds for the avatar render loader. |
Method | Returns | Description |
---|---|---|
LoadRender(
string url,
AvatarRenderScene scene,
string blendShapeMesh,
Dictionary<string,float> blendShapes
) | void | Loads a 2D render of the avatar at the supplied URL according to the supplied paramenters. |
url | string | URL of the avatar to render. This is the same URL as used to load the avatar model. |
scene | AvatarRenderScene | Type of scene to render. See below. |
blendShapeMesh (optional) | string | Target blend shape mesh name. Required to apply custom blend shape weights to the render. |
blendShapes (optional) | Dictionary<string, float> | Blend shape name and weight to apply to the avatar render. |
Property | Type | Description |
---|---|---|
FullBodyPostureTransparent | AvatarRenderScene | Creates a portrait with a pose from a full-body avatar with transparent background. |
Portrait | AvatarRenderScene | Creates a portrait from a half-body avatar. |
PortraitTransparent | AvatarRenderScene | Creates a portrait from a half-body avatar with transparent background. |
Event | EventArgs | Description |
---|---|---|
OnFailed | <FailureType, string> | Called upon failure. |
OnCompleted | <Texture2D> | Called upon success. |
ProgressChanged | <float, string> | Called upon download progress. |
public class AvatarRenderExample : MonoBehaviour
{
private const string TAG = nameof(AvatarRenderExample);
private string url = "https://api.readyplayer.me/v1/avatars/6185a4acfb622cf1cdc49348.glb";
private AvatarRenderScene scene = AvatarRenderScene.FullBodyPostureTransparent;
private string blendShapeMesh = "Wolf3D_Avatar"; //Main-Node for blendshapes
private Dictionary<string, float> blendShapes = new Dictionary<string, float>
{
{ "mouthSmile", 0.7f },
{ "viseme_aa", 0.5f },
{ "jawOpen", 0.3f }
};
void Start()
{
var avatarRenderer = new AvatarRenderLoader();
avatarRenderer.OnCompleted = Completed;
avatarRenderer.OnFailed = Fail;
avatarRenderer.LoadRender(url, scene, blendShapeMesh, blendShapes);
loadingPanel.SetActive(true);
}
private void Completed(Texture2D render)
{
// Do something with the image
}
private void Fail(FailureType type, string message)
{
// Errorhandling
}
}
Last modified 1mo ago