Unity3d 用戶動態設置技能響應按鍵 NGUI

public class Modefiay : MonoBehaviour
{

    private UILabel input_label;
    private UIButton confirm_button_chinese, input_button;
    private KeyCode current_skill_box_setting_keycode = KeyCode.None;
    private bool is_wait_input = false;

  void Awake()
    {

        input_label = transform.FindNameAllChild("input_label").GetComponent<UILabel>();
        confirm_button_chinese = transform.FindNameAllChild("confirm_button_chinese").GetComponent<UIButton>();
        input_button = transform.FindNameAllChild("input_english").GetComponent<UIButton>();

        input_button.onClick.Add(new EventDelegate(() =>
        {
            input_label.text = "";
            is_wait_input = true;

        }));

        confirm_button_chinese.onClick.Add(new EventDelegate(() =>
        {
            if (current_skill_box_setting_keycode != KeyCode.None)
            {
                is_wait_input = false;
            }
        }));
    }
    //e.keyCode;
    private Event e;
    void OnGUI()
    {
        if (is_wait_input && Event.current.rawType == EventType.KeyDown)
        {
            e = Event.current;
            if (KeyCode.None != e.keyCode)
            {
                input_label.text = Enum.GetName(typeof(KeyCode), e.keyCode);
                current_skill_box_setting_keycode = e.keyCode;
                e.Use();
            }
        }
    }

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章