七,激光门
3,为其添加音频组件,将laser_hum拖进去,勾选loop,3d中的Min Distance设为1.8
4,添加light组件,设置颜色(255,40,0),range改成5,intensity改为0.6,lightmapping设为 realtime only(这样当门关上时不会
重新渲染此light使光还留在场景中)
1,将models中的fx_laserFence_lasers拖到层级视图中,设置如图009,并且方便管理编号_001
3,为其添加音频组件,将laser_hum拖进去,勾选loop,3d中的Min Distance设为1.8
4,添加light组件,设置颜色(255,40,0),range改成5,intensity改为0.6,lightmapping设为 realtime only(这样当门关上时不会
重新渲染此light使光还留在场景中)
5,添加脚本DoneLaserBlinking 控制激光门开关
using UnityEngine;
using System.Collections;
public class DoneLaserBlinking : MonoBehaviour
{
public float onTime; // Amount of time in seconds the laser is on for.
public float offTime; // Amount of time in seconds the laser is off for.
private float timer; // Timer to time the laser blinking.
void Update ()
{
// Increment the timer by the amount of time since the last frame.
timer += Time.deltaTime;
// If the beam is on and the onTime has been reached...
if(renderer.enabled && timer >= onTime)
// Switch the beam.
SwitchBeam();
// If the beam is off and the offTime has been reached...
if(!renderer.enabled && timer >= offTime)
// Switch the beam.
SwitchBeam();
}
void SwitchBeam ()
{
// Reset the timer.
timer = 0f;
// Switch whether the beam and light are on or off.
renderer.enabled =