Mathf.InverseLerp 反插值

static function InverseLerp (from : float, to : float, value : float) : float

Description描述

Calculates the Lerp parameter between of two values.

计算两个值之间的Lerp参数。也就是value在from和to之间的比例值。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public float walkSpeed = 5.0F;
	public float runSpeed = 10.0F;
	public float speed = 8.0F;
	void Start() {
		float parameter = Mathf.InverseLerp(walkSpeed, runSpeed, speed);
	}
}
var walkSpeed = 5.0;
var runSpeed = 10.0;
var speed = 8.0;

function Start() {
	// parameter is now 3 / 5
	//现在参数是3/5
	var parameter : float = Mathf.InverseLerp(walkSpeed, runSpeed, speed);
}
Page last updated: 2011-2-23