-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathLoadVRM.cs
43 lines (36 loc) · 1.56 KB
/
LoadVRM.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityStandardAssets.Characters.ThirdPerson;
using UnityStandardAssets.Cameras;
using VRM;
public class LoadVRM : MonoBehaviour {
// Use this for initialization
void Start () {
//"StreamingAssets"フォルダの"VRoid.vrm"を読み込む
var path = Application.streamingAssetsPath + "/" + "VRoid.vrm";
// Actionコールバックで生成されたGameObjectが返される
VRMImporter.LoadVrmAsync(path, gameObject =>
{
//タグ:プレイヤーのオブジェクトを対象とする
gameObject.transform.position = new Vector3(7.0f, 1, 5);
gameObject.tag = "Player";
//アニメーターを設定する
RuntimeAnimatorController asset = (RuntimeAnimatorController)Instantiate(Resources.Load("Animator/ThirdPersonAnimatorController"));
gameObject.GetComponent<Animator>().runtimeAnimatorController = asset;
//コライダーなどの設定
gameObject.AddComponent<Rigidbody>();
gameObject.AddComponent<CapsuleCollider>();
gameObject.GetComponent<CapsuleCollider>().height = 1.85f;
gameObject.GetComponent<CapsuleCollider>().radius = 0.2f;
gameObject.GetComponent<CapsuleCollider>().center = new Vector3(0,0.85f,0);
gameObject.AddComponent<AnnouncePlayerPosition>();
gameObject.AddComponent<CheckCommand>();
gameObject.AddComponent<ThirdPersonUserControl>();
//カメラを設定
GameObject camera = GameObject.Find("FreeLookCameraRig");
camera.GetComponent<FreeLookCam>().target = gameObject.transform;
});
}
}