Time.frameCount 帧数

static var frameCount : int

Description描述

The total number of frames that have passed (Read Only).

已经传递的帧的总数(只读)。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	private static int lastRecalculation = -1;
	static void RecalculateValue() {
		if (typeof(lastRecalculation) == Time.frameCount)
			return;

		ProcessData.AndDoSomeCalculations();
	}
}
// Makes sure that RecalculateValue only performs
// some operations once per frame and no more.
//确保RecalculateValue每帧只执行一次某些操作
static private var lastRecalculation = -1;
static function RecalculateValue () {
	if (lastRecalculation == Time.frameCount)
		return;
	ProcessData.AndDoSomeCalculations();
}
最后修改:2010年12月27日 Monday 15:27

本脚本参考基于Unity 3.4.1f5

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