6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Live2DのSampleApp1で指定モーション再生

Last updated at Posted at 2015-04-28

Live2D Communityの英語フォーラム経由で、SampleApp1プロジェクトで指定モーション再生したいけどわからんってあったのでちょっと調べてみた。
前に書いたけどもSampleApp1プロジェクトはLive2D SDKの中で一番難しいやつです。
 → Live2DのUnitySDKをコードリーディング

Unityの場合だけど、他のSDKでもほぼ同じように流用できるかと思います。

#修正箇所
Live2DモデルのGameObjectにアタッチしてるソースに少し追加するだけでOK!
01.png

以下のコードを末尾に追加するだけ。前にソース解析したからここまでシンプルに!

LAppModelProxy.cs
// 指定モーションの再生
public void Motion_Change(){
    model.StartMotion("tap_body", 0, 2);
}

model.StartMotionの引数については、以下の通りです。

 ・引数1(model.jsonのグループID)

 ・引数2(model.jsonのGroupIDの中の再生したいファイル番号)
 02.png

 ・引数3(優先度。idleモーションが1なので2を渡すとidleモーションより優先される)

あとUGUIのbutton作ってLive2DのGameObjectをセットすると呼べます
03.png

haru1.gif

ちなみにLAppDefine.csにデバッグ用のフラグ変数があって、trueにすると当たり判定などデバッグ機能がオンになるので活用して下さい
04.png

2015/10/29追記
SampleApp1でDrawMeshモードを使いたい場合、LAppModel.csのInit()で以下のように指定します

LAppModel.cs
public void Init(String modelJson)
{
    updating = true;
    initialized = false;

    modelSetting = new ModelSettingJson(modelJson);

    if (LAppDefine.DEBUG_LOG) Debug.Log("Start to load model");

	// Live2D Model
    if (modelSetting.GetModelFile() != null)
    {
        loadModelData(modelHomeDir + modelSetting.GetModelFile());
        // DrawMeshモード
        GetLive2DModelUnity ().setRenderMode (Live2D.L2D_RENDER_DRAW_MESH);

        var len = modelSetting.GetTextureNum();
        for (int i = 0; i < len; i++)
        {
            loadTexture(i, modelHomeDir + modelSetting.GetTextureFile(i));
        }
    }
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?