unity一个按钮实现开和关
程序员文章站
2022-06-30 11:55:08
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ButtonCll : MonoBehaviour { private int countint = 0; publ... ......
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); } } } }