Input.accelerationEvents 加速度事件列表

static var accelerationEvents : AccelerationEvent[]

Description描述

Returns list of acceleration measurements which occurred during the last frame (Read Only) (Allocates temporary variables).

返回上一帧测量的加速值数据列表(只读)(分配临时变量)

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Update() {
		Vector3 acceleration = Vector3.zero;
		foreach (AccelerationEvent accEvent in Input.accelerationEvents) {
			acceleration += accEvent.acceleration * accEvent.deltaTime;
		}
		print(acceleration);
	}
}
// Calculates weighted sum of acceleration measurements which occurred during the last frame
//计算上一帧所测量的加速度加权和
// Might be handy if you want to get more precise measurements
//如果你想获取更精确的测量是很方便的
function Update () {
	var acceleration : Vector3 = Vector3.zero;
	for (var accEvent : AccelerationEvent in Input.accelerationEvents) {
		acceleration += accEvent.acceleration * accEvent.deltaTime;
	}
	print (acceleration);
}
最后修改:2011年3月11日 Friday 18:57

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。