Upgrade to Pro — share decks privately, control downloads, hide ads and more …

超初心者向け!ハコスコ×Unity=簡単VR

 超初心者向け!ハコスコ×Unity=簡単VR

Unityインストールから始める、ハコスコを使ったUnityハンズオンセミナーの資料です。

Makoto Ito

July 08, 2016
Tweet

More Decks by Makoto Ito

Other Decks in Technology

Transcript

  1. εΫϦϓτͷฤू ্هεΫϦϓτΛଧͪࠐΉ using UnityEngine;
 using System.Collections;
 using VRStandardAssets.Utils; // VRStandardAssets.Utils໊લۭ͕ؒར༻Ͱ͖ΔΑ͏ʹ௥Ճ


    
 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);
 }
 }