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);
}
Page last updated: 2011-3-11