Export to .pdf

Docs

  • Code:
    • Settings / Scriptable objects
    • How to add Clothing Item, Variation

Features

  • Male and female body meshes
  • Customizable body shapes
  • Customizable face shapes
  • Customizable expressions
  • Blinking
  • Viseme blend shapes and lipsynch
  • Equipable clothing
  • Facial hair
  • Clothing material variations
  • Body part material variations
  • Mecanim compatible rig
  • Random avatar creation
  • Creating your own clothing in blender

Male and Female Body Meshes

The avatar comes with male and female versions of the body mesh. Changing gender will also switch the clothes to the specific gender version of the clothes piece.

Customizable body shapes

Avatar come with several body shape blend shapes.

You can set the given variables:

  • BodyFat (-100 to 100)
  • BodyMuscle (0 to 100)
  • BreastSize (-100 to 100) will only be applied to female version
  • NailsLength (0 to 100)
  • NailsCurve(0 to 100)

To apply the changes call the UpdateCustomization() to apply other changes as well. This will also apply the changes to the equipped clothes and shrink the hidden parts of the body mesh to prevent clipping.

Customizable Face Shapes

Avatar comes with a lot of facial customizable shapes.

You can set the given variables:

  • NoseWidth (-100 to 100)
  • NoseLength (-100 to 100)
  • NoseHeight (-100 to 100)
  • NoseBridge (-100 to 100)
  • NoseTilt (-100 to 100)
  • MouthWidth (-100 to 100)
  • LipsWidth (-100 to 100)
  • Cheeks (-100 to 100)
  • BrowWidth (-100 to 100)
  • BrowHeight (-100 to 100)
  • BrowProtrusion (-100 to 100)
  • BrowThickness (-100 to 100)
  • BrowCurve (-100 to 100)
  • EyesSize (-100 to 100)
  • EyesClosedDefault (0 to 100)
  • EarsSize (-100 to 100)
  • EarsFlare (-100 to 100)
  • EarsPointy (0 to 100)
  • JawWidth (-100 to 100)
  • ChinWidth (-100 to 100)
  • ChinProtrusion (-100 to 100)
  • ChinCleft (0 to 100)

To apply the changes call the UpdateCustomization() to apply other changes as well. This will also apply the changes to the facial hair.

Customizable Expressions

The avatar models come with blend shapes for the 5 basic emotions that can be blended together.

You can set the given variables:

  • ExpressionJoy (0 to 100)
  • ExpressionAnger (0 to 100)
  • ExpressionSadness (0 to 100)
  • ExpressionFear (0 to 100)
  • ExpressionDisgust (0 to 100)

To apply the changes call the UpdateCustomization(). This will also apply the changes to the facial hair. This will permanently apply expression settings to the player. To apply expression in general use the following method on the avatar instance:

avatar.SetExpression(AvatarCustomization.AvatarExpression.Anger...);

Blinking

Avatars blink automatically, but you can set some parameters to change it to your liking.

  • BlinkingAmount
  • BlinkingSpeed

Viseme blend shapes

While the blendshapes are created and available, the implementation of lipsynch has to be done by the end user. Do not forget to drive the blend shapes on facial hair as well.

Avatar models come with viseme shapes for lip synching and are compatible with https://developer.oculus.com/documentation/unity/audio-ovrlipsync-unity/

Alternatively you can use the simpler approach of just animating the jaw bone.

Scripting

Spawning an Avatar

You can find an Avatar prefab under Prefabs folder. Place the Avatar prefab reference in your script and then you can spawn your randomized avatar using the following code as an example.

public void SpawnAvatarWithRandomization(int seed = 100) {
        GameObject avatarInstance = Instantiate(AvatarPrefab, Vector3.zero, Quaternion.identity);

        AvatarCustomization avatar = avatarInstance.GetComponent<AvatarCustomization>();
        avatar.RandomizeBodyParameters(
            seed: seed,
            ignoreHeight: true,
            unifiedHairColors: true,
            noRandomExpressions: true
        );
        avatar.RandomizeClothing(
            seed: seed
        );
}

You can procedurally spawn your avatar using a seed → same seed with same settings will generate the same avatar. You can also choose different options when randomizing body parameters:

  • ignoreHeight: ignores height when randomizing it, it will default to 1.8m,
  • unifiedHairColors: facial hair, hair and eye brow colors will be the same if set to true,
  • noRandomExpressions: expression parameters will be set to 0 so they will not effect any face randomizations

Individual Settings

You can change individual settings via scripting like this:

public void SpawnAvatarIndividualSettings(Vector3 position) {
  GameObject avatarInstance = Instantiate(AvatarPrefab, position, Quaternion.identity);

  AvatarCustomization avatar = avatarInstance.GetComponent<AvatarCustomization>();
  avatar.BodyHeight = 1.6f;
  avatar.NoseBridge = 50f;
  avatar.BodyMuscle = 100f;
  avatar.UpdateCustomization();

    // set the gender
    avatar.SetGender(Gender.Male);
}

Make sure to check the source code to see the limits of each option in attributes, an example:

[AvatarFloatFieldAttribute("Nose Height", "noseHeight", -100, 100, Section = SECTION_FACE_PARAMETERS)]
public float NoseHeight = 0f;

NoseHeight can go from -100 to 100, any values that exceed these numbers may cause glitches on the avatar itself.

Load from Text Asset/Preset file

You can load a preset from a string or a text asset as such:

public void SpawnAvatarFromPreset(TextAsset asset, Vector3 position) {
    GameObject avatarInstance = Instantiate(AvatarPrefab, position, Quaternion.identity);

    AvatarCustomization avatar = avatarInstance.GetComponent<AvatarCustomization>();
    AvatarCustomization.ApplyConfigFile(asset, avatar);
}

You can also store avatar configuration into a string with:

GameObject avatarInstance = Instantiate(AvatarPrefab, position, Quaternion.identity);
AvatarCustomization avatar = avatarInstance.GetComponent<AvatarCustomization>();
string configurationString = AvatarCustomization.ToConfigString(avatar);

Change Clothing Item on Avatar

public ClothingItem GlassesClothingItem;

public void SpawnAvatarClothingOptions(Vector3 position) {
    GameObject avatarInstance = Instantiate(AvatarPrefab, position, Quaternion.identity);

    AvatarCustomization avatar = avatarInstance.GetComponent<AvatarCustomization>();
    avatar.AttachClothingItem(
        item: GlassesClothingItem,
        variationIndex: 1
    );
}

Update any Avatar Changes

There are two main methods that you can use to update the customization or apply any clothing item changes. If you only tweak avatar values e.g. face or body settings use this method:

avatar.UpdateCustomization();

If you have changed any clothing items use this method to apply the changes:

avatar.UpdateClothing();

Expressions API

You can set avatar expression like this:

AvatarCustomization avatar = avatarInstance.GetComponent<AvatarCustomization>();
avatar.SetExpression(AvatarCustomization.AvatarExpression.Anger);

// reset with 
avatar.SetExpression(AvatarCustomization.AvatarExpression.None);