Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationEventAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.


Unity uGUIでマウスオーバー



using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

[RequireComponent( typeof( Image ) )]
public class TapOverComponent : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
    public Image image { get { return GetComponent<Image>(); } }

    // オブジェクトの範囲内にマウスポインタが入った際に呼び出されます。
    // this method called by mouse-pointer enter the object.
    public void OnPointerEnter( PointerEventData eventData )
        image.color = Color.red;

    // オブジェクトの範囲内からマウスポインタが出た際に呼び出されます。
    public void OnPointerExit( PointerEventData eventData )
        image.color = Color.white;


要素 概要
IPointerEnterHandler OnPointerEnterが定義されている
OnPointerEnter uGUIオブジェクトの範囲内にマウスポインタが入った際に呼び出される
IPointerExitHandler OnPointerExitが定義されている
OnPointerExit uGUIオブジェクトの範囲内からマウスポインタが出た際に呼び出される
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Help us understand the problem. What are the problem?