按键短按长按

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

public class ShouBingMuLu : MonoBehaviour
{


    public GameObject MuLu;
    public GameObject MuLu02;

    public float time = 0;

    private bool SJ = true;

    // Use this for initialization
    void Start()
    {
        if (MuLu != null)
        {
            MuLu.SetActive(false);
        }
        if (MuLu02 != null)
        {
            MuLu02.SetActive(false);
        }
    }

    // Update is called once per frame
    void Update()
    {

        if (this.gameObject.GetComponent().CeJianTaiQi == true)
        {
            SJ = true;
        }

        if (this.gameObject.GetComponent().CeJianAnZhu == true)
        {
            if (SJ == true)
            {
                time += Time.deltaTime;
            }
        }

        if (time < 1 && 0 < time)
        {
            if (MuLu != null && MuLu02 != null)
            {
                if (MuLu.activeSelf == false && MuLu02.activeSelf == false)
                {
                    if (this.gameObject.GetComponent().CeJianTaiQi == true)
                    {
                        if (MuLu != null)
                        {
                            MuLu.SetActive(true);
                            //重置时间
                            time = 0;
                            SJ = false;
                        }
                    }
                }
                else
                {
                    if (this.gameObject.GetComponent().CeJianTaiQi == true)
                    {
                        MuLu.SetActive(false);
                        MuLu02.SetActive(false);
                        //重置时间
                        time = 0;
                        SJ = false;
                    }

                }
            }

        }

        if (time >= 1)
        {
            if (MuLu02 != null)
            {
                if (MuLu02.activeSelf == false)
                {
                    if (MuLu.activeSelf == false)
                    {
                        MuLu02.SetActive(true);
                        this.gameObject.GetComponent().CeJianAnXia = false;
                        //重置时间
                        time = 0;
                        SJ = false;
                    }
                    else
                    {
                        MuLu.SetActive(false);
                        MuLu02.SetActive(true);
                        this.gameObject.GetComponent().CeJianAnXia = false;
                        //重置时间
                        time = 0;
                        SJ = false;
                    }

                }
                else
                {
                    time = 0;
                }
            }
        }

        
    }
}

你可能感兴趣的:(Scripts)