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事件

相关推荐
辰小忆19 小时前
11 · RunCurveChart —— 实时运行曲线
c++·ui·duilib
敲上瘾3 天前
Qt核心机制:信号与槽详解
开发语言·c++·qt·ui·qt6.3
FRing034 天前
vue2干货总结10(json-server、vant-ui、postcss插件、axios二次封装、图形验证码、toast轻提示)
开发语言·前端·vue.js·ui·json·vue2·postcss
xy34535 天前
Axure 9.0 垂直菜单介绍
ui·产品经理·axure·原型设计
Oll Correct7 天前
Adobe illustrator 案例十四:花元素标志草图绘制
笔记·ui·adobe·illustrator
huaqianzkh8 天前
WinForm C#:循环修改控件UI闪烁卡顿?SuspendLayout / ResumeLayout 与 BeginUpdate 优化
开发语言·ui·c#
Oll Correct9 天前
Adobe illustrator 案例十三:adidas标志草图绘制
笔记·ui·adobe·illustrator
FungLeo9 天前
成为全栈·Vue 管理后台篇·Vue3 + Vite + Naive UI:后台工程基座怎么搭
前端·vue.js·ui·typescript·vite·前端工程化·biome
敲上瘾10 天前
Qt Widgets入门:项目模板解析与Hello World
开发语言·数据库·c++·qt·ui·qt6.3
Oll Correct11 天前
Adobe illustrator 案例十二:视频播放(Media & Video)图标绘制
笔记·ui·adobe·illustrator