当前位置:网站首页>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);
}
}
边栏推荐
- Static route analysis (the longest mask matching principle + active and standby routes)
- C language applet -- common classic practice questions
- The principle of complete replication of virtual machines (cloud computing)
- 拒绝加班,程序员开发的效率工具集
- The effective square of the test (one question of the day 7/29)
- Installation, start and stop of redis7 under Linux
- 修改未正确放入沙盒造成苹果兼容性问题
- Project development software directory structure specification
- leetcode-1161: Maximum in-layer element sum
- 加密生活,Web3 项目合伙人的一天
猜你喜欢
To write good test cases, you must first learn test design
Crypto Life, a day in the life of a Web3 project partner
The Sad History of Image Processing Technology
Teach you how to configure Jenkins automated email notifications
图像处理技术的心酸史
"Cloud native's master, master and vulgar skills" - 2022 National New College Entrance Examination Volume I Composition
General introduction to the Unity interface
f.grid_sample
Drools basic introduction, introductory case, basic syntax
ShardingJDBC usage summary
随机推荐
How to design the changing system requirements
LeetCode Daily Question 2022/7/25-2022/7/31
Layer 2 broadcast storm (cause + judgment + solution)
mysql 索引
Static route analysis (the longest mask matching principle + active and standby routes)
Problems that need to be solved by the tcp framework
【AcWing 62nd Weekly Game】
Linux下redis7的安装,启动与停止
Real-time image acquisition based on FPGA
加密生活,Web3 项目合伙人的一天
Mathematical Ideas in AI
【shell基础】判断目录是否为空
Unity界面总体介绍
Installation, start and stop of redis7 under Linux
拒绝加班,程序员开发的效率工具集
The real CTO is a technical person who understands products
19.支持向量机-优化目标和大间距直观理解
What does a software test report contain?
leetcode-1161: Maximum in-layer element sum
Difference between CMOS and TTL?