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();
        confirm_button_chinese = transform.FindNameAllChild("confirm_button_chinese").GetComponent();
        input_button = transform.FindNameAllChild("input_english").GetComponent();

        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();
            }
        }
    }

}

 

你可能感兴趣的:(unity3d,NGUI)