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

相关推荐
修炼前端秘籍的小帅9 天前
Stitch——Google热门的免费AI UI设计工具
前端·人工智能·ui
王码码20359 天前
Flutter for OpenHarmony:socket_io_client 实时通信的事实标准(Node.js 后端的最佳拍档) 深度解析与鸿蒙适配指南
android·flutter·ui·华为·node.js·harmonyos
2501_921930839 天前
Flutter for OpenHarmony:第三方库实战 chewie 视频播放器UI组件详解
flutter·ui
梵得儿SHI9 天前
Vue3 生态工具实战宝典:UI 组件库 + 表单验证全解析(Element Plus/Ant Design Vue/VeeValidate)
前端·vue.js·ui·elementplus·vue性能优化·antdesignvue·表单验证方案
Unity游戏资源学习屋9 天前
【Unity UI资源包】GUI Pro - Casual Game 专为休闲手游打造的专业级UI资源包
ui·unity
麻瓜呀10 天前
vue2 Element-ui框架相关常见问题-表单组件重置显示异常
运维·服务器·ui
少云清10 天前
【UI自动化测试】4_PO模式 _PO模式封装
ui·po模式
菜鸟小芯10 天前
【GLM-5 陪练式创意 UI 实战】第二篇:创意魔法盒 —— 从 “开心” 到 “科技感”,AI 驱动的 UI 风格迭代
科技·ui