Initial Setup

Development Environment:

It is assumed to be relevant to Unity4.X or later.
No other environment is guaranteed to work.


The library setting:

Enter Live2DUnity.dll to any place below the project Assets.
Import live2d when using the library class from the script.


The file setting for the Live2D:

Please add the extension of ".bytes" in the end of the file name from the explorer or the finder because of the Unity specification.
XXX.moc    →    XXX.moc.bytes
XXX.json    →    XXX.json.bytes
XXX.mtn    →    XXX.mtn.bytes

The extension ".bytes" is not displayed when importing to the Unity editor.
The extension ".bytes" is not needed for the path to specify the file.

*Remember to add the extension ".bytes" from the explorer or the finder, not on the Unity editor, as the original file extension is not changed when doing it on the Unity editor.


Acquire the model or the Texture:

・When setting the model or the Texture on the editor
1. Place the model or the Texture in any directory.
2. Describe the variable for the model or the Texture as the public one like below, and save it.
  1. public TextAsset mocFile ;
  2. public Texture2D[] texture ;

3. Attach the script which describes above variable to any of the game objects, and drag and drop the file to the relevant part of the Inspector.


・When setting the model or the Texture dynamically from the script

1. Place the model or the Texture in any directory below the Resources folder.
2. Load the file as follows. Specify the relative pathname below Resources/.

  1. // Load the model
  2. TextAsset modelMoc = (TextAsset)Resources.Load("XXX.moc" , typeof(TextAsset));
  3. Live2DModelUnity live2DModel = Live2DModelUnity.loadModel(modelMoc.bytes);
  4.  
  5. // Load the Texture
  6. Texture2D texture = (Texture2D)Resources.Load("XXX/XXX"typeof(Texture2D)); // The extension like ".png" is not needed for the path.
  7. live2DModel.setTexture(0, texture);




Make settings of the size and the position of the model

You can make settings of them by Transform from the Inspector of Unity.
Or you can also make settings of them from the matrix when using the framework of the Live2D.

Comments