当前位置:网站首页>Unity3D Button mouse hover enter and mouse hover exit button events
Unity3D Button mouse hover enter and mouse hover exit button events
2022-07-31 02:40:00 【java can fly】
Requirements
Because Party A's acceptance failed, the project needs to be revised. When modifying the interface, I want to realize the function of displaying the second-level menu by hovering the mouse over the first-level menu. The main picture is as follows
Note that the mouse in the above picture is only hovering over the scene roaming button, and there is no left or right click, etc.
Implementation method
The idea is to let the class inherit the two interfaces of IPointerEnterHandler and IPointerExitHandler, and then implement the methods.
The code is as follows:
using System.span>Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using UnityEngine.EventSystems;public class ScentRoamButtonControl : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler{/// /// Buttons for all scene walkthrough modules/// public GameObject SceneButtons;public void OnPointerEnter(PointerEventData eventData){//throw new System.NotImplementedException();//Debug.Log("111");SceneButtons.SetActive(true);}public void OnPointerExit(PointerEventData eventData){//throw new System.NotImplementedException();SceneButtons.SetActive(false);}}
边栏推荐
猜你喜欢
随机推荐
The final exam first year course
CentOS7下mysql5.7.37的安装【完美方案】
Drools WorkBench的简介与使用
共模电感的仿真应用来了,满满的干货送给大家
mysql 视图
Maximum area of solar panel od js
Basic learning about Redis related content
Force buckled brush the stairs (7/30)
英特尔软硬优化,赋能东软加速智慧医疗时代到来
AI software development process in medical imaging field
mysql view
LeetCode Daily Question 2022/7/25-2022/7/31
【CV项目调试】CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT问题
The Sad History of Image Processing Technology
coldfusion8 background scheduled tasks take shell
Difference between CMOS and TTL?
Intranet Infiltration - Privilege Escalation
Face detection based on opencv
What level of software testing does it take to get a 9K job?
LeetCode 1161 The largest element in the layer and the LeetCode road of [BFS binary tree] HERODING