「Unity/VRM」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→準備) |
(→UniVRMのインストール) |
||
| 行16: | 行16: | ||
</pre> | </pre> | ||
Unityプロジェクトを開いて、Packagesの下に、VRMが、あれば成功。 | Unityプロジェクトを開いて、Packagesの下に、VRMが、あれば成功。 | ||
| + | |||
| + | ===モデルを動的に読み込む場合=== | ||
| + | <pre> | ||
| + | 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(); | ||
| + | } | ||
| + | } | ||
| + | </pre> | ||
| + | 参考:https://zenn.dev/nishi/articles/c44fc709a7d575 | ||
2022年12月17日 (土) 08:53時点における版
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();
}
}
