using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System;publicclassUIEvent:MonoBehaviour {publicGameObject btnGo;publicGameObject sliderGo;publicGameObject dropDownGo;// Start is called before the first frame updatevoidStart(){btnGo.GetComponent<Button>().onClick.AddListener(this.ButtonOnClick);btnGo.GetComponent<Slider>().onValueChanged.AddListener(this.SliderOnClick);btnGo.GetComponent<Dropdown>().onValueChanged.AddListener(this.DropDownOnClick);}voidButtonOnClick(){Debug.Log("ButtonOnClick");}voidSliderOnClick(floatvalue){Debug.Log("SliderOnClick");}voidDropDownOnClick(Int32value){Debug.Log("DropDownOnClick");}// Update is called once per framevoidUpdate(){} }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems;publicclassUIEventManager:MonoBehaviour, IPointerDownHandler {//实现的接口 鼠标点击Image会触发//要确保Image组件里的Raycast Target被勾选//因为这种方法是通过射线检测来实现的publicvoidOnPointerDown(PointerEventData eventData){Debug.Log("IPointerDownHandler");} }
using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; /** UI必须有继承自Selectable组件的组件*/ publicclassImageII:MonoBehaviour,ISelectHandler,IDeselectHandler,IUpdateSelectedHandler {publicvoidOnSelect(BaseEventData eventData){print("UI被选中了");}publicvoidOnDeselect(BaseEventData eventData){print("UI被结束选中");}publicvoidOnUpdateSelected(BaseEventData eventData){print("选中之后被结束选中之前一直被调用");} }
本文详细介绍了一种利用 ESP8266 01S 模块构建 Web 服务器的成功实践方案。通过具体的代码示例和详细的步骤说明,帮助读者快速掌握该模块的使用方法。在疫情期间,作者重新审视并研究了这一未被充分利用的模块,最终成功实现了 Web 服务器的功能。本文不仅提供了完整的代码实现,还涵盖了调试过程中遇到的常见问题及其解决方法,为初学者提供了宝贵的参考。 ...
[详细]