Loading 2D Avatars

This example demonstrates how to request an avatar render image via the Render API and apply the result to a UI sprite. This approach may be useful for showing a profile picture of an avatar in a heads-up display or use it as a button icon.

This example has been tested in Unity 2020.3LTS and newer versions.

Scene and Code

Assets/Samples/Enoch Avatar Loader/1.0.0/AvatarRender/AvatarRenderExample

  1. Open and play the AvatarRender/AvatarRenderExample Scene.

  2. Open the AvatarRenderExample.cs script.

    • Notice that a 2D render uses the same avatar URL as the 3D render of the same avatar.

    • Creates an instance of AvatarRenderLoader.

    • Defines the OnCompleted() callback for the AvatarRenderLoader; this is called when loading has successfully completed and creates a sprite for the avatar.

    • Calls LoadRender() with the URL for the avatar to load, the type of scene to render, the name of the target blend shape mesh, and the blend shapes.

See the AvatarRenderLoader API documentation for details on LoadRender() arguments.

Last updated