当前位置:网站首页>Unity3D Button 鼠标悬浮进入与鼠标悬浮退出按钮事件
Unity3D Button 鼠标悬浮进入与鼠标悬浮退出按钮事件
2022-07-31 02:27:00 【java能飞翔】
需求
由于甲方验收未通过,项目需要改版,在修改界面时,想实现鼠标在一级菜单悬浮即可显示二级菜单的功能,主要如下图
注意,上图鼠标只是悬浮在场景漫游按钮上,并未点击左键或右键等
实现方法
思路是让类继承IPointerEnterHandler IPointerExitHandler两个接口,然后实现其中的方法
代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class ScentRoamButtonControl : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
/// <summary>
/// 所有的场景漫游模块的按钮
/// </summary>
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);
}
}
边栏推荐
- 力扣刷题之有效的正方形(每日一题7/29)
- Problems that need to be solved by the tcp framework
- 【shell基础】判断目录是否为空
- AI software development process in medical imaging field
- tcp框架需要解决的问题
- 12 磁盘相关命令
- 加密生活,Web3 项目合伙人的一天
- Inter-vlan routing + static routing + NAT (PAT + static NAT) comprehensive experiment
- General introduction to the Unity interface
- 10 权限介绍
猜你喜欢
Problems that need to be solved by the tcp framework
mmdetection trains a model related command
【Bank Series Phase 1】People's Bank of China
Tower of Hanoi problem
Linux下redis7的安装,启动与停止
Drools Rule Properties, Advanced Syntax
Introduction to flask series 】 【 flask - using SQLAlchemy
Observer mode (1)
Layer 2 broadcast storm (cause + judgment + solution)
Arbitrum Interview | L2 Summer, what does the standout Arbitrum bring to developers?
随机推荐
The difference between link and @import
真正的CTO,是一个懂产品的技术人
Manchester City confuses fans with smart scarf that detects emotions
C language applet -- common classic practice questions
【shell基础】判断目录是否为空
The modification is not properly placed in the sandbox, causing Apple compatibility issues
AtCoder Beginner Contest 261 Partial Solution
Software testing basic interface testing - getting started with Jmeter, you should pay attention to these things
力扣刷题之爬楼梯(7/30)
Calculate S=a+aa+…+aa…a
Difference between CMOS and TTL?
What have I experienced to become a tester who is harder than development?
Real-time image acquisition based on FPGA
uniapp uses 3rd party fonts
934. The Shortest Bridge
mysql index
The effective square of the test (one question of the day 7/29)
Classic linked list OJ strong training problem - fast and slow double pointer efficient solution
How to design the changing system requirements
Nacos