UGUI 鼠标悬浮UI出现弹框,鼠标在图片边缘出现闪烁

1、背景:鼠标悬浮在UI上出现提示框

cs 复制代码
public class SpecialParam_list : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    public void OnPointerEnter(PointerEventData eventData)
    {
        TipBox.Instance.ShowBox(Input.mousePosition, value);
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        TipBox.Instance.HideBox();
    }

}




using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TipBox : UnitySingleton<TipBox>
{
    SpecialFyALand_Panel fyALand_Panel;
    GameObject tioObj;
    public float offset = 1;
    [SerializeField]
    private float threshold = 1f;
    public  void ShowBox(Vector2 pos, string ac  )
    {
     
       
        if (tioObj == null)
        {
            tioObj = ResMgr.GetInstance().Load<GameObject>("TipBox", ResourcesType.UIPrefabs);
            tioObj.transform.SetParent(GameObject.Find("Canvas").transform);
            tioObj.transform.SetAsLastSibling();
        } 
        TipBoxInfo tipBoxInfo = tioObj.GetComponent<TipBoxInfo>();
        tipBoxInfo.InitData( ac );
        tioObj.SetActive(true);
        tioObj.transform.SetAsLastSibling();
        tipBoxInfo.transform.position = new Vector2(pos.x, pos.y) + new Vector2(0, 0) * offset;
        //tipBoxInfo.transform.position = new Vector3(pos.x, pos.y, 0) + new Vector3(963, 539, 0) * offset;

    }
    public void HideBox()
    {
        if (tioObj != null&& tioObj.activeSelf)
            tioObj.SetActive(false);
    }
}

2、鼠标一旦出现在图片边缘弹框就会不停的闪烁

3、解决方案:将弹框包含所有的物体的RaycastTarget去掉

PS:个人猜测原因是弹窗的移入导致出发了pointenter事件

相关推荐
松树戈10 小时前
plus-ui&RuoYi-Vue-Plus 基于pgSql本地运行实践
前端·vue.js·spring boot·ui
Jelian_1 天前
element-ui的el-cascader增加全选按钮实现(附源码)
vue.js·ui·elementui
向宇it2 天前
【unity游戏开发——编辑器扩展】使用EditorGUI的EditorGUILayout绘制工具类在自定义编辑器窗口绘制各种UI控件
开发语言·ui·unity·c#·编辑器·游戏引擎
小众AI2 天前
UI-TARS: 基于视觉语言模型的多模式代理
人工智能·ui·语言模型
花落已飘2 天前
LVGL(lv_btnmatrix矩阵按钮)
ui·c·lvgl
kooboo china.2 天前
在UI 原型设计中,交互规则有哪些核心要素?
ui·编辑器·交互
编程乐趣2 天前
推荐一个Winform开源的UI工具包
microsoft·ui·开源
读心悦2 天前
CSS结构性伪类、UI伪类与动态伪类全解析:从文档结构到交互状态的精准选择
css·ui·交互
逍遥德3 天前
CSS可以继承的样式汇总
前端·css·ui
洛克希德马丁3 天前
QLineEdit增加点击回显功能
c++·qt·ui