Mathf
- Abs
- Acos
- Approximately
- Asin
- Atan2
- Atan
- CeilToInt
- Ceil
- Clamp01
- Clamp
- ClosestPowerOfTwo
- Cos
- Deg2Rad
- DeltaAngle
- Epsilon
- Exp
- FloorToInt
- Floor
- Infinity
- InverseLerp
- IsPowerOfTwo
- LerpAngle
- Lerp
- Log10
- Log
- Max
- Min
- MoveTowardsAngle
- MoveTowards
- NegativeInfinity
- NextPowerOfTwo
- PingPong
- PI
- Pow
- Rad2Deg
- Repeat
- RoundToInt
- Round
- Sign
- Sin
- SmoothDampAngle
- SmoothDamp
- SmoothStep
- Sqrt
- Tan
Mathf.Clamp 限制
static function Clamp (value : float, min : float, max : float) : float
Description描述
Clamps a value between a minimum float and maximum float value.
限制value的值在min和max之间, 如果value小于min,返回min。 如果value大于max,返回max,否则返回value
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Update() {
transform.position = new Vector3(Mathf.Clamp(Time.time, 1.0F, 3.0F), 0, 0);
}
}
•static function Clamp (value : int, min : int, max : int) : int
Description描述
Clamps value between min and max and returns value.
限制value的值在min和max之间,并返回value。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public void Awake() {
print(Mathf.Clamp(10, 1, 3));
}
}
// Clamps the value 10 to be between 1 and 3.
// prints 3 to the console
//现在10在1~3之间,3被打印到控制台
print(Mathf.Clamp(10, 1, 3));
最后修改:2011年2月23日 Wednesday 13:56