Changing ZEPETO character color and worn item color
This guide aims to assist in creating engaging content.
ZEPETO characters are instantiated at runtime as a ZepetoCharacter object.
If you inspect the structure of ZepetoCharacter, you'll find a sub-object named Zepeto Context. Further within Zepeto Context, there's another object named body.
By replacing the body(Clone) Material of the body Object at runtime using scripts, you can change the color of the ZEPETO character.
For non-animated avatars, this approach changes the color of the entire face and body.
However, for animated avatars, you need to also modify the body(Clone) Material of the ANIME_BASEMODEL, which is a child of the body Object.
Please note that Material replacements are feasible with Material arrays of the same length.
📘 Unity Materials https://docs.unity3d.com/2020.3/Documentation/Manual/Materials.html
Below is a sample code that changes the body color of the Local Player.
Make sure to implement the logic so the character's color is changed only after the character has loaded.
- Altering the body Material may result in the ZEPETO avatar's makeup not being displayed correctly.
Worn items are instantiated as sub-objects under the body Object.
You can check the applied Material for each item from the Materials section of the item object.
By replacing the Materials at runtime using scripts, you can change the color of the items.
Below is a sample code that changes the color of the first item worn by the Local Player.
Ensure that the item's color is changed only after the character has loaded.
- Code Explanation
- this.body.transform.GetChild(0) refers to the first item among the worn items, i.e., the item at index 0.
- You can adapt this to change the color of other worn items.
- For items using multiple Materials, remember that Material replacements require Material arrays of the same length.
By leveraging the insights we've gained so far, you can modify the color of both the character and all items uniformly.
Here's a sample code that alters the color of the Local Player's character and item colors entirely when the "Change Color" button is clicked and reverts back to the original when the "Original Color" button is clicked:
- This method is not only applicable to the Local Player but also to any ZEPETO characters created at runtime, including NPC characters.
- Feel free to get creative and apply it in fun ways!