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

相关推荐
Humbunklung1 小时前
Rust Floem UI 框架使用简介
开发语言·ui·rust
CodeCraft Studio15 小时前
【案例分享】如何借助JS UI组件库DHTMLX Suite构建高效物联网IIoT平台
javascript·物联网·ui
插件开发17 小时前
免费插件集-illustrator插件-Ai插件-随机填色
ui·illustrator
叹一曲当时只道是寻常1 天前
AI书签管理工具开发全记录(十三):TUI基本框架搭建
ui·go
海尔辛2 天前
Unity UI 性能优化--Sprite 篇
ui·unity·性能优化
QQ676580082 天前
基于 PyTorch 的 VGG16 深度学习人脸识别检测系统的实现+ui界面
人工智能·pytorch·python·深度学习·ui·人脸识别
pop_xiaoli2 天前
UI学习—cell的复用和自定义cell
学习·ui·ios
测试老哥3 天前
Pytest+Selenium UI自动化测试实战实例
自动化测试·软件测试·python·selenium·测试工具·ui·pytest
步、步、为营3 天前
.net jwt实现
ui·.net
藏在歌词里3 天前
Axure-元件&流程图
ui·photoshop