Unity/VRM
提供: 初心者エンジニアの簡易メモ
UnityでVRMを動かす方法
参考:https://konichallengelog.com/unity_vrm_lipsync/
人形素材をDLとインストール
- https://3d.nicovideo.jp/works/td32797 からDL
- DLしたdirを、UnityのAssets以下にドラッグ
- VRM内の青色アイコンのPrefabを、ヒエラルキーにドラッグして、表示されればOK
UniVRMのインストール
Package/manifest.jsonのdependencies以下に、com.vrmc〜の4行追加
"dependencies": {
"com.vrmc.vrmshaders": "https://github.com/vrm-c/UniVRM.git?path=/Assets/VRMShaders#v0.107.0",
"com.vrmc.gltf": "https://github.com/vrm-c/UniVRM.git?path=/Assets/UniGLTF#v0.107.0",
"com.vrmc.univrm": "https://github.com/vrm-c/UniVRM.git?path=/Assets/VRM#v0.107.0",
"com.vrmc.vrm": "https://github.com/vrm-c/UniVRM.git?path=/Assets/VRM10#v0.107.0",
Unityプロジェクトを開いて、Packagesの下に、VRMが、あれば成功。
モデルを動的に読み込む場合
using UnityEngine;
using UniGLTF;
using VRM;
using VRMShaders;
public class SampleScene : MonoBehaviour
{
void Start()
{
Load();
}
async void Load()
{
string path = Application.streamingAssetsPath + "/../Alicia_VRM/Alicia/VRM/AliciaSolid.vrm";
Debug.Log(path);
RuntimeGltfInstance instance = await VrmUtility.LoadAsync(path, new RuntimeOnlyAwaitCaller());
// this.instance.EnableUpdateWhenOffscreen();
instance.ShowMeshes();
}
}
