Mathf.Repeat 重复

static function Repeat (t : float, length : float) : float

Description描述

Loops the value t, so that it is never larger than length and never smaller than 0.

循环数值t,0到length之间。t值永远不会大于length的值,也永远不会小于0。

This is similar to the modulo operator but it works with floating point numbers.

这是类似于模运算符,但可以使用浮点数。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Update() {
		transform.position = new Vector3(Mathf.Repeat(Time.time, 3), transform.position.y, transform.position.z);
	}
}
function Update () {
	// Set the x position to loop between 0 and 3
	//设置x位置在0到3之间循环
	transform.position = Vector3(
	Mathf.Repeat(Time.time, 3), transform.position.y, transform.position.z);
} 
Page last updated: 2011-2-23