using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 门
///
public class Door : MonoBehaviour
{
public bool doorStart = false ;
public string animName = "Door";
private Animation anim;
private void Start()
{
anim = GetComponent<Animation>();
}
//点击当前物体是调用
private void OnMouseDown()
{
//如果开门状态
if (doorStart)
{
//关门
if (anim.isPlaying == false)
{
anim[animName].time = anim[animName].length;//从最后开始播
}
anim[animName].speed = -1;//倒叙播放
}
else
{
//开门
anim[animName].speed = 1;
}
//播放动画
anim.Play(animName);
doorStart =! doorStart;
}
}