Hello All:
Unity 4.6 comes with new UI system which has different way of handling different event like mouse over, mouse out, mouse in, click etc.
In this post I will share how to handle these events properly in Unity 4.6 UI. Unity 4.6 UI provides following Interfaces to handle these events
Following code shows how to handle these interfaces
Hope this helps. Happy coding.
Unity 4.6 comes with new UI system which has different way of handling different event like mouse over, mouse out, mouse in, click etc.
In this post I will share how to handle these events properly in Unity 4.6 UI. Unity 4.6 UI provides following Interfaces to handle these events
- IPointerEnterHandler
- IPointerClickHandler
- IPointerExitHandler
Following code shows how to handle these interfaces
using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.EventSystems; public class AwesomeGameObject : IPointerEnterHandler, IPointerClickHandler, IPointerExitHandler { void Awake() { } public void Start() { } public void OnPointerEnter(PointerEventData eventData) { //handle this for pointer enter } public void OnPointerClick(PointerEventData eventData) { //Handle this for click } public void OnPointerExit(PointerEventData eventData) { //Handle this for exit } }
Hope this helps. Happy coding.
Thanks for printing this post. Hope you liked it.
Keep visiting and sharing.
Thanks,
Ashwani.
Keep visiting and sharing.
Thanks,
Ashwani.
0 comments :
Post a Comment