using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OpenDoor : MonoBehaviour
{
    
    public string animName="Door";
    private Animation anim;
    /// <summary>
    /// Start is called on the frame when a script is enabled just before
    /// any of the Update methods is called the first time.
    /// </summary>
    void Start()
    {
        anim=transform.parent.gameObject.GetComponent<Animation>();
    }
    private bool state=false;
    private void OnMouseDown() {
        if(state)
        {
            if(anim.isPlaying==false)
                anim[animName].time=anim[animName].length;
            anim[animName].speed=-1;
        }
        else
        {
            anim[animName].speed=1;
        }
        anim.Play(animName);
        state=!state;
    }
}

 

相关文章:

  • 2021-11-29
  • 2021-11-28
  • 2021-11-30
  • 2021-11-07
  • 2022-12-23
  • 2021-11-28
  • 2021-09-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-28
  • 2021-11-29
  • 2022-01-02
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案