当前位置: 移动技术网 > IT编程>开发语言>.net > unity一个按钮实现开和关

unity一个按钮实现开和关

2019年02月20日  | 移动技术网IT编程  | 我要评论

生活大爆炸第一季1,南京二手房装修,天堂2私服发布

using system.collections;
using system.collections.generic;
using unityengine;

public class buttoncll : monobehaviour {
    private int countint = 0;
    public gameobject seting;
    private bool count = true;
    // use this for initialization
    void start () {
        
    }
    
    // update is called once per frame
    void update () {
        // *******************************************第一种方法******************************************
        //每次点击来判断它的奇偶性
        if (input .getkeyup (keycode.keypadenter))
        {
         
            countint++;
            if (countint %2==0)
            {
                seting.setactive(false);
            }
            else
            {
                seting.setactive(true);
            }       
        }
        // *******************************************第二种方法******************************************
        if (input .getkeydown (keycode .keypadenter ))
        {
            count = !count;
            if (count)
            {
                seting.setactive(false);
            }
            else
            {
                seting.setactive(true);
            }
        }
    }
}

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网