# Unity C#でのモデルのパラメータ設定について

**URL:** <https://creatorsforum.live2d.com/t/topic/499>\
**Category:** トラブル報告\
**Created:** [2022 年 1 月 25 日午前 4:12 UTC](https://creatorsforum.live2d.com/t/topic/499 "2022-01-25T04:12:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marry\_rian](https://sea1.discourse-cdn.com/flex015/user_avatar/creatorsforum.live2d.com/marry_rian/32/249_2.png) [@marry\_rian](https://creatorsforum.live2d.com/u/marry_rian)\
**Post date:** [2022 年 1 月 25 日午前 4:12 UTC](https://creatorsforum.live2d.com/t/topic/499/1 "2022-01-25T04:12:15Z")

</div>

【Cubism SDKのバージョン】Cubism SDK for Unity R4  
【OS名・バージョン】Windows10  
【開発使用ツール】（Visual Studio 2019、Unity 2020.3.25f1

【不具合の状況】  
Unity C#で、モデルのパラメータ設定を以下のサイトを参考に作成しました。

■モデルのパラメータ更新について  
[https://docs.live2d.com/cubism-sdk-tutorials/about-parameterupdating-of-model/](https://docs.live2d.com/cubism-sdk-tutorials/about-parameterupdating-of-model/)

C#でクラスを作成し、モデルのプレハブ直下にクラスのコンポーネントを追加しています。

そのクラスのLateUpdate（）の中で、口と前髪のパラメータの設定を行った際  
Unity上の再生（プレビュー）では、口、前髪とパラメータが設定されますが、  
Windowsにビルドすると、口は設定されますが、前髪のパラメータが設定されません。

もしかすると、Unity側の設定かもしれませんが、ご存じの方がいましたら  
教えてください。

private void LateUpdate()  
{  
CubismModel \_model = this.FindCubismModel();

//口のパラメータ  
\_model.Parameters[12].Value = 1.0f;

//前髪のパラメータ  
\_model.Parameters[23].Value = 1.0f;  
}

---

<div class="post-metadata">

**Author:** ![ono-at-live2d-com](https://sea1.discourse-cdn.com/flex015/user_avatar/creatorsforum.live2d.com/ono-at-live2d-com/32/167_2.png) [@ono-at-live2d-com](https://creatorsforum.live2d.com/u/ono-at-live2d-com)\
**Post date:** [2022 年 1 月 26 日午前 7:11 UTC](https://creatorsforum.live2d.com/t/topic/499/2 "2022-01-26T07:11:02Z")

</div>

@marry_rian 様

いつも弊社製品をご愛顧くださり誠にありがとうございます。  
Live2Dスタッフでございます。

お問い合わせいただいた内容を確認した限り、おそらくコンポーネントの実行順が原因だと思われます。  
口のパラメータも前髪のパラメータも値は正常に適用され、その後物理演算によって前髪のパラメータが上書きされている可能性があります。

原因が上記の内容である場合、作成していただいたコンポーネントの実行順を物理演算よりも後に設定することで回避することが可能です。  
Unityの機能によって制御する方法のほか、Cubism SDK for Unityにもコンポーネントの実行順を制御する機能がありますので、いずれかの方法で設定してください。  
Cubism SDK for Unityの実行順を制御する機能の使用方法につきましては、以下のページをご覧ください。  
[https://docs.live2d.com/cubism-sdk-tutorials/updatecontroller/](https://docs.live2d.com/cubism-sdk-tutorials/updatecontroller/)

以上、よろしくお願いいたします。
