Skip to content

Instantly share code, notes, and snippets.

@haramakoto
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haramakoto/10948762 to your computer and use it in GitHub Desktop.
Save haramakoto/10948762 to your computer and use it in GitHub Desktop.
Riftが動いたら何かするコンポーネント
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