Unity 陀螺仪。。哈哈。。。。
来源:互联网 发布:大唐天下网络骗局 编辑:程序博客网 时间:2024/06/05 01:04
搞移动的童鞋有福喽。。。。。
http://blog.csdn.net/quannenggou/article/details/7513242
private var gyroBool : boolean;
private var gyro : Gyroscope;
private var rotFix : Quaternion;
function Start() {
var originalParent = transform.parent; // check if this transform has a parent
var camParent = new GameObject ("camParent"); // make a new parent
camParent.transform.position = transform.position; // move the new parent to this transform position
transform.parent = camParent.transform; // make this transform a child of the new parent
camParent.transform.parent = originalParent; // make the new parent a child of the original parent
gyroBool = Input.isGyroAvailable;
if (gyroBool) {
gyro = Input.gyro;
gyro.enabled = true;
if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
camParent.transform.eulerAngles = Vector3(90,90,0);
} else if (Screen.orientation == ScreenOrientation.Portrait) {
camParent.transform.eulerAngles = Vector3(90,180,0);
}
if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
rotFix = Quaternion(0,0,0.7071,0.7071);
} else if (Screen.orientation == ScreenOrientation.Portrait) {
rotFix = Quaternion(0,0,1,0);
}
//Screen.sleepTimeout = 0;
} else {
print("NO GYRO");
}
}
function Update () {
if (gyroBool) {
var camRot : Quaternion = gyro.attitude * rotFix;
transform.localRotation = camRot;
}
}
private var gyro : Gyroscope;
private var rotFix : Quaternion;
function Start() {
var originalParent = transform.parent; // check if this transform has a parent
var camParent = new GameObject ("camParent"); // make a new parent
camParent.transform.position = transform.position; // move the new parent to this transform position
transform.parent = camParent.transform; // make this transform a child of the new parent
camParent.transform.parent = originalParent; // make the new parent a child of the original parent
gyroBool = Input.isGyroAvailable;
if (gyroBool) {
gyro = Input.gyro;
gyro.enabled = true;
if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
camParent.transform.eulerAngles = Vector3(90,90,0);
} else if (Screen.orientation == ScreenOrientation.Portrait) {
camParent.transform.eulerAngles = Vector3(90,180,0);
}
if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
rotFix = Quaternion(0,0,0.7071,0.7071);
} else if (Screen.orientation == ScreenOrientation.Portrait) {
rotFix = Quaternion(0,0,1,0);
}
//Screen.sleepTimeout = 0;
} else {
print("NO GYRO");
}
}
function Update () {
if (gyroBool) {
var camRot : Quaternion = gyro.attitude * rotFix;
transform.localRotation = camRot;
}
}
- Unity 陀螺仪。。哈哈。。。。
- Unity陀螺仪
- Unity陀螺仪
- Unity陀螺仪
- unity陀螺仪
- Unity陀螺仪功能
- unity 陀螺仪的脚本
- Unity陀螺仪应用
- unity陀螺仪参数详解
- Unity陀螺仪功能
- Unity中陀螺仪控制
- 【Unity】Unity调用手机陀螺仪
- Unity 使用陀螺仪观察场景
- unity之陀螺仪和指南针
- Unity-陀螺仪控制Camera旋转
- unity 只有一个方向旋转的陀螺仪
- 陀螺仪
- 陀螺仪
- UITabBarController详解
- Spring 3.0 基于Annotation 的依赖注入实现详解
- Chp1之使用图标资源
- PBRT 快速入门
- Simplified Approach to Resolve ORA-4031
- Unity 陀螺仪。。哈哈。。。。
- Activity中Dialog创建流程以及SparseArray分析
- 一个游戏程序员的学习资料
- Shell Script中FOR循环的使用
- Ajax实现提示功能
- 黑马程序员——各种for循环语句的一个总结
- PKU 1166 The Clocks
- HDU 4320 - Arcane Numbers 1 / SWUN 1429 - 进制转化
- STL问题与解决(1)(刚开始)