public class SmileInteractive : MonoBehaviour {
VRInteractiveItem interactiveItem; // SD_unitychan ʹ͋ΔVRInteractiveItemΛ͑ΔΑ͏ʹ
Animator anim; // SD_unitychan ͷإΞχϝʔγϣϯΛมߋͰ͖ΔΑ͏ʹ
void Awake () // StartͩͱɺOnEnable ʹؒʹ߹Θͳ͍ͷͰɺAwakeͰ
{
interactiveItem = GetComponent<VRInteractiveItem>(); // ಉ͡ΦϒδΣΫτதͷVRInteractiveItemΛरͬͯ͘Δ
anim = GetComponent<Animator> (); // ಉ͡ΦϒδΣΫτதͷAnimatorΛरͬͯ͘Δ
}
private void OnEnable () // ར༻ՄೳʹͳͬͨࡍʹݺΕΔ
{
interactiveItem.OnOver += Smile; // ϚεΦʔόʔͨ࣌͠ͷΠϕϯτؔSmile ΛՃ
interactiveItem.OnOut += Normal; // Ϛε͕֎Εͨ࣌ͷΠϕϯτؔNormal ΛՃ
}
private void OnDisable () // ࠷ޙʹݺΕΔ
{
interactiveItem.OnOver -= Smile; // OnEnable ͰՃͨ͠ͷͷޙ࢝
interactiveItem.OnOut -= Normal; // ಉ্
}
private void Smile() // Πϕϯτؔ
{
anim.CrossFade("smile@sd_hmd", 0); // smileΞχϝʔγϣϯʹมߋ
anim.SetLayerWeight (1, 1);
}
private void Normal() // Πϕϯτؔ
{
anim.CrossFade("default@sd_hmd", 0); // ௨ৗΞχϝʔγϣϯʹมߋ
anim.SetLayerWeight (1, 1);
}
} ࢹΛ߹ΘͤΔͱসإΛ֬ೝ εΫϦϓτ͕ͪΌΜͱಈ͍͍ͯΔ͔ͷ֬ೝ