Skip to main content

API Reference (WIP)

caution

This page is still a work in progress. If you have any questions regarding the usage of the API, don't hesitate to contact us directly.

Session​

ISession​

A session is an interface that contains all the tasks currently used to interact with the Union Avatars API. It also handles logs and user authorization.

For more information about the Union Avatars API Endpoints check: Union Avatars API Docs

Session Context​

Class containing all the information needed to perform operations in the API.

VariablesDescription
UrlBase URL of Union Avatars API
UserTokenContainer of the user’s API token
OrganizationID of the organization of the platform
API KeyAdmin API key to perform special operations such as user registering

Server Session​

Implementation of ISession that performs client-side operations in the API. It makes use of Unity’s WebRequests using a helper class.

Creating and using a Session​

ServerSession session = new ServerSession(organization: "YOUR ORG ID"); await session.Login("username", "password"); AvatarMetadata[] avatarMetadatas = await session.GetAvatars();
ServerSession session = new ServerSession(organization: "YOUR ORG ID"); await session.Login("username", "password"); AvatarMetadata[] avatarMetadatas = await session.GetAvatars();
Create your own implementation of the ISession

If the server session does not meet your needs, you can create your own implementation using the provided session as a template. For example, you could create a client-server architecture where instead of letting the client perform the API requests directly, it redirects them to a game server with API credentials.


Avatars​

Avatar Importer​

Helper class that handles Runtime importing of GLTF data using GLTFast.

It contains methods that automatically convert the imported avatar binaries into a Unity Humanoid.

Importing an avatar​

var avatar = await session.GetAvatar(new System.Guid("AVATAR_ID")); await AvatarImporter.ImportAvatarAsHumanoid(avatar, animatorController, cts.Token);
var avatar = await session.GetAvatar(new System.Guid("AVATAR_ID")); await AvatarImporter.ImportAvatarAsHumanoid(avatar, animatorController, cts.Token);

Importing an avatar using LOD (All levels)​

var avatar = await session.GetAvatar(new System.Guid("AVATAR_ID")); await AvatarImporter.ImportAvatarAsHumanoidLOD(avatar, animatorController, cts.Token);
var avatar = await session.GetAvatar(new System.Guid("AVATAR_ID")); await AvatarImporter.ImportAvatarAsHumanoidLOD(avatar, animatorController, cts.Token);

Importing an avatar using LOD (Single level)​

var avatar = await session.GetAvatar(new System.Guid("AVATAR_ID")); int LOD_LEVEL = 2 await AvatarImporter.ImportAvatarAsHumanoidLOD(avatar, animatorController, LOD_LEVEL, cts.Token);
var avatar = await session.GetAvatar(new System.Guid("AVATAR_ID")); int LOD_LEVEL = 2 await AvatarImporter.ImportAvatarAsHumanoidLOD(avatar, animatorController, LOD_LEVEL, cts.Token);