Creating an avatar
Create a head​
Before creating a full avatar we first need a Head
. A Head
is generated from a single frontal face picture.
csharp
async void CreateHead(){// The face image is sent in base64 formatstring base64 = ImageConverter.ConvertImageToBase64("path/to/image");// You can also convert it from a byte array// string base64 = ImageConverter.ConvertImageToBase64(byte[]);HeadRequest request = new HeadRequest(){Name = "MyHead",SelfieImg = base64};Head head = await session.CreateHead(request);if(head == null)Debug.LogError("Couldn't create head");// ...}
csharp
async void CreateHead(){// The face image is sent in base64 formatstring base64 = ImageConverter.ConvertImageToBase64("path/to/image");// You can also convert it from a byte array// string base64 = ImageConverter.ConvertImageToBase64(byte[]);HeadRequest request = new HeadRequest(){Name = "MyHead",SelfieImg = base64};Head head = await session.CreateHead(request);if(head == null)Debug.LogError("Couldn't create head");// ...}
Create an avatar​
csharp
async void CreateAvatar(){// ...AvatarRequest request = new AvatarRequest(){Name = "MyHead",Style = Style.phr,HeadId = head.Id,OutfitId = outfit.Id};AvatarMetadata avatar = await session.CreateAvatar(request);if(avatar == null)Debug.LogError("Couldn't create avatar");// ...}
csharp
async void CreateAvatar(){// ...AvatarRequest request = new AvatarRequest(){Name = "MyHead",Style = Style.phr,HeadId = head.Id,OutfitId = outfit.Id};AvatarMetadata avatar = await session.CreateAvatar(request);if(avatar == null)Debug.LogError("Couldn't create avatar");// ...}