1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

身内向け Unity Naninovel Live2D 導入

1
Last updated at Posted at 2026-06-29

Unity導入編

  1. UnityHubでUnityをインストール
    Unity 6.3 LTS (6000.3.18f1)
    image.png
    image.png
    image.png

  2. 新しいプロジェクトを Universal 2Dで作成する
    image.png

Live2D導入編

  1. Cubism 5 SDK for Unity R5 をダウンロードする
    https://www.live2d.com/sdk/download/unity/
    image.png

  2. 上でダウンロードしたものをAssetsの中に放り込む
    こんな感じのが生成されていればOK
    image.png

  3. Live2Dを表示するための設定
    ・Assets/Settings/Renderer2D.assetを選択する
    ・Inspector の一番下にある「Add Renderer Feature」をクリック
    ・「Cubism Render Pass Feature」を選択
    [参考]
    https://zenn.dev/tutupizizizi/articles/unity-live2d-urp-texture-fix
    image.png

  4. 青い箱をヒエラルキーにドラッグドロップしてからCubism Fade Contollerに natu_cg_1.fadeMotionListをセットする
    image.png

  5. 適当にモーションが動くか動作確認する
    image.png
    image.png

Naninovel導入編

  1. ウィンドウ>Package Management>パッケージマネージャを開く

  2. マイアセット>Naninovel>「インポートします」を押す
    image.png

  3. Scenario>Entryというファイルがあるので、書き加える
    image.png
    image.png

    @setAnimParam param_on:mo_1 param_off:mo_2,mo_3
    NOW mo_1
    
    @setAnimParam param_on:mo_2 param_off:mo_1,mo_3
    NOW mo_2
    
    @setAnimParam param_on:mo_3 param_off:mo_1,mo_2
    NOW mo_3
    
  4. AnimatorParameterというスクリプトをつくる
    image.png

    using System;
    using Naninovel;
    using Naninovel.Commands;
    using NUnit.Framework.Constraints;
    using UnityEngine;
    
    // エイリアスの参考
    // https://naninovel.com/ja/guide/custom-commands#%E3%83%8F%E3%82%9A%E3%83%A9%E3%83%A1%E3%83%BC%E3%82%BF%E3%82%A8%E3%82%A4%E3%83%AA%E3%82%A2%E3%82%B9
    
    [Serializable, Alias("setAnimParam")]
    public class AnimatorParameter : Command
    {
        public StringListParameter param_on;
        public StringListParameter param_off;
    
    
        public override Awaitable Execute(ExecutionContext ctx)
        {
            Debug.Log($"setAnimParam が呼ばれた {param_on}{param_off}");
    
            GameObject target = GameObject.FindGameObjectWithTag("natu_1");
    
            if (target != null)
            {
                Animator animator = target.GetComponent<Animator>();
                if (animator != null)
                {
                    //animator.SetBool(param, true);
                    foreach (string p in param_on)
                    {
                        animator.SetBool(p, true);
                    }
                    foreach (string p in param_off)
                    {
                        animator.SetBool(p, false);
                    }
    
                }
                else
                {
                    Debug.LogError("animatorが取得できなかった。");
                }
            }
            else
            {
                Debug.LogError("targetが取得できなかった。");
            }
    
            // if (Assigned(Name)) Debug.Log($"Hello, {Name}!");
            // else Debug.Log("Hello World!");
            return Async.Completed;
        }
    }
    

    [参考]
    https://naninovel.com/ja/guide/custom-commands#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%88%E3%82%99%E3%81%AE%E8%BF%BD%E5%8A%A0

  5. animatorを設定する
    他も同様に
    image.png
    image.png

  6. タグをnatu_1にする
    image.png

  7. NullReferenceException: Object reference not set to のエラーが出る場合、編集してからStory Editorの保存ボタンを押すと直る
    image.png
    image.png

VSCode導入編

  1. Enable>Trust Foler & Continue
    image.png
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?