Last active
August 29, 2015 13:59
-
-
Save haramakoto/10948762 to your computer and use it in GitHub Desktop.
Riftが動いたら何かするコンポーネント
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
/// <summary> | |
/// Riftが動いたら何かするコンポーネント。OculusUnityIntegrationに含まれる、OVRDevice.csもAddComponentされている必要があります。 | |
/// </summary> | |
public class OVRMoveCheckAndDoSomething : MonoBehaviour { | |
#region parameters | |
float preRotX; | |
Quaternion ovrRot; | |
bool isCheckStart; | |
#endregion | |
#region lifecycle | |
void Start () { | |
ovrRot = Quaternion.identity; | |
Invoke("StartCheck",1); | |
} | |
// Update is called once per frame | |
void Update () { | |
OVRDevice.GetOrientation(0,ref ovrRot); | |
float currentRotX = ovrRot.eulerAngles.x; | |
if( Mathf.Abs( currentRotX - preRotX ) > 30.0f && isCheckStart)ActionOnRiftMove(); | |
preRotX = currentRotX; | |
} | |
#endregion | |
#region private | |
void StartCheck(){ | |
isCheckStart = true; | |
} | |
void ActionOnRiftMove(){ | |
//do something | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment