Use of .cdi3.json

Updated: 10/28/2021

Summary

This section explains how to customize the display names of parameters, parameter groups, and parts using .cdi3.json.

It is assumed that .cdi3.json has been written out for the model data to be used.

See “About supplementary view files” for more information about .cdi3.json and its implementation in SDK for Native / SDK for Web.

As a preliminary preparation, refer to [Import SDK – Place Models], import the model data with .cdi3.json exported and place the prefab, then select the root object of the prefab.

Use in Inspector

When model data containing .cdi3.json is imported, the names of the parameters and parts listed in .cdi3.json can be displayed in the Inspector of the model prefab.


Users can also assign any name they want.
To set a name, enter the name in the Display Name field under [Cubism Display Info Parameter Name] or [Cubism Display Info Part Name].
If Display Name is empty, the name listed in .cdi3.json is used.

Display Name is not yet set:

With Display Name set to:

Notation of parameters when setting the Display Name:

Use in Applications

The following code is an example of actual use in an application.
A C# script can be created with the following content and attached to the model prefab.

using Live2D.Cubism.Core;
using UnityEngine;
using UnityEngine.UI;
using Live2D.Cubism.Framework;

public class ViewAllParameter : MonoBehaviour
{
    public Text text;

    private CubismParameter[] parameters;
    private string[] parametersName;
    
    // Start is called before the first frame update
    void Start()
    {
        CubismModel model = gameObject.GetComponent<CubismModel>();
        parameters = model.Parameters;
        parametersName = new string[parameters.Length];
        text.text = string.Empty;

        for (int i = 0; i < model.Parameters.Length; i++)
        {
            var displayInfoParameterName = parameters[i].GetComponent<CubismDisplayInfoParameterName>();
            parametersName[i] = displayInfoParameterName != null
                ? (string.IsNullOrEmpty(displayInfoParameterName.DisplayName) ? displayInfoParameterName.Name : displayInfoParameterName.DisplayName)
                : string.Empty;
            text.text += parametersName[i] + '\n';
        }
    }
}

The following is an example of the display when applied to a Scroll View.

Was this article helpful?
YesNo
Please let us know what you think about this article.