当前位置:网站首页>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);
}
}
边栏推荐
- String为什么不可变?
- AI中的数学思想
- leetcode-952: Calculate max component size by common factor
- My first understanding of MySql, and the basic syntax of DDL and DML and DQL in sql statements
- Draw Your Cards
- The final exam first year course
- Observer mode (1)
- LeetCode Daily Question 2022/7/25-2022/7/31
- Classic linked list OJ strong training problem - fast and slow double pointer efficient solution
- CMOS和TTL的区别?
猜你喜欢

What level of software testing does it take to get a 9K job?

Basic introduction to ShardingJDBC

12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche

Drools基本介绍,入门案例,基本语法
![LeetCode 1161 The largest element in the layer and the LeetCode road of [BFS binary tree] HERODING](/img/56/fcc8ee6f592abf0a374fc950a3362f.png)
LeetCode 1161 The largest element in the layer and the LeetCode road of [BFS binary tree] HERODING

mysql view

基于FPGA的图像实时采集

Intel's software and hardware optimization empowers Neusoft to accelerate the arrival of the era of smart medical care

Classic linked list OJ strong training problem - fast and slow double pointer efficient solution

知识蒸馏7:知识蒸馏代码详解
随机推荐
CMOS和TTL的区别?
Coldfusion file read holes (CVE - 2010-2861)
[1154]如何将字符串转换为datetime
CV-Model [3]: MobileNet v2
验证整数输入
关于 mysql8.0数据库中主键位id,使用replace插入id为0时,实际id插入后自增导致数据重复插入 的解决方法
Basic introduction to ShardingJDBC
Drools基本介绍,入门案例,基本语法
Software testing basic interface testing - getting started with Jmeter, you should pay attention to these things
Drools Rule Properties, Advanced Syntax
Clustering index, and what is the difference between a clustering index
LeetCode 每日一题 2022/7/25-2022/7/31
The comprehensive result of the case statement, do you know it?[Verilog Advanced Tutorial]
12 磁盘相关命令
coldfusion8 background scheduled tasks take shell
Project development software directory structure specification
Force buckled brush the stairs (7/30)
Can an inexperienced college graduate switch to software testing?my real case
Android's webview cache related knowledge collection
【AcWing 62nd Weekly Game】