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("选中之后被结束选中之前一直被调用");} }
Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ...
[详细]
Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ...
[详细]