-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathExampleMod.cs
More file actions
62 lines (53 loc) · 1.69 KB
/
Copy pathExampleMod.cs
File metadata and controls
62 lines (53 loc) · 1.69 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using UnityEngine;
using VMC;
using VMCMod;
[VMCPlugin(
Name: "ExampleMod",
Version: "1.0.0",
Author: "sh_akira",
Description: "サンプルModです。右手に球体を取り付けます。Settingボタンで色をランダムに変更します。",
AuthorURL: "https://twitter.com/sh_akira",
PluginURL: "http://mod.vmc.info/")]
public class ExampleMod : MonoBehaviour
{
private Transform rightHandTransform;
private GameObject sphere;
private Material sphereMaterial;
private void Awake()
{
VMCEvents.OnModelLoaded += OnModelLoaded;
VMCEvents.OnCameraChanged += OnCameraChanged;
}
void Start()
{
Debug.Log("Example Mod started.");
sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
sphereMaterial = sphere.GetComponent<Renderer>().material;
}
void Update()
{
if (rightHandTransform != null)
{
sphere.transform.position = rightHandTransform.position;
}
}
[OnSetting]
public void OnSetting()
{
if (sphereMaterial != null)
{
sphereMaterial.color = new Color(Random.value, Random.value, Random.value);
}
}
private void OnModelLoaded(GameObject currentModel)
{
if (currentModel == null) return;
var animator = currentModel.GetComponent<Animator>();
rightHandTransform = animator.GetBoneTransform(HumanBodyBones.RightMiddleProximal); //右手中指のボーン
}
private void OnCameraChanged(Camera currentCamera)
{
//カメラ切り替え時に現在のカメラを取得できます
}
}