Skip to content

Xbox 360 avatars in C# and .NET

To use Xbox 360 avatars in C#, reference Sona.csproj from the SDK download, open a SonaContext with your licence and add each avatar from its manifest. It runs on .NET 8 and inside Unity.

A C# program's run, and the avatar.png it saved: an avatar mid-wave

Steps

  1. Download the SDK for your platform (getting it), and have a manifest as base64.
  2. Reference Sona.csproj in your download from your project.
  3. Open a SonaContext with your licence and a source: SonaSourceSpec.Gate() streams the item files from 360sona, SonaSourceSpec.Dir(folder) reads a folder of your own.
  4. Add the avatar with AddBase64 and call Update until it is ready. Then play clips, read joints or render it.
  <SonaBindings
      Condition="'$(SonaBindings)' == ''">sdk/bindings/csharp</SonaBindings>
</PropertyGroup>

<ItemGroup>
  <ProjectReference Include="$(SonaBindings)/Sona.csproj" />
</ItemGroup>

Open a context and add the avatar

var options = new SonaOptions
{
    Licence = File.ReadAllBytes(args[0]),
    AppId = Environment.GetEnvironmentVariable("SONA_APP_ID"),
};
// the gate: item files from 360sona
options.Sources.Add(dir != null ? SonaSourceSpec.Dir(dir) :
    SonaSourceSpec.Gate());
using var ctx = new SonaContext(options);

var avatar = ctx.AddBase64(args[1]);
while (avatar.State != SonaAvatarState.Ready &&
    avatar.State != SonaAvatarState.Failed) ctx.Update(1.0 / 60);

Then avatar.Play("GenericWave") waves, TryGetJointWorld reads where a joint is, and SonaHeadless draws a picture of it with no window.

More

  • The C# tutorial builds the whole console program, which saves a picture of the wave.
  • In Unity, the same binding sits under the Unity package (Xbox 360 avatars in Unity).
  • Credit: show "Powered by 360sona" where your users see the avatars. EncodePng adds the credit to a PNG's text chunks.
  • 360sona is not affiliated with or endorsed by Microsoft.

This page as Markdown · All the docs as one file (llms-full.txt)