Light.range 范围

var range : float

Description描述

The range of the light.

灯光的范围。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public float duration = 3.0F;
	private float originalRange;
	void Update() {
		float amplitude = Mathf.PingPong(Time.time, duration);
		amplitude = amplitude / duration * 0.5F + 0.5F;
		light.range = originalRange * amplitude;
	}
	void Awake() {
		originalRange = light.range;
	}
}
// Pulse light's range between original range
// and half of the original one
//在原始范围与原始范围一半处变换灯光范围
var duration : float = 3.0;
private var originalRange : float;
originalRange = light.range;

function Update() {
	var amplitude : float = Mathf.PingPong( Time.time, duration );
	// transform from 0..duration to 0.5..1 range
	//从0..到持续到0.5..1的变化范围
	amplitude = amplitude / duration * 0.5 + 0.5;
	// set light range
	//设置灯光范围
	light.range = originalRange * amplitude;
}
最后修改:2011年3月30日 Wednesday 12:14

本脚本参考基于Unity 3.4.1f5

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