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

相关推荐
Jiaberrr1 小时前
Element UI教程:如何将Radio单选框的圆框改为方框
前端·javascript·vue.js·ui·elementui
神一样的老师2 天前
如何解决 Photoshop 中的“暂存盘已满”错误
ui·photoshop
伊织code2 天前
GraphRAG-Local-UI - 基于 GraphRAG 支持本地的聊天UI
ui·llm·rag·graphrag·local-ui
Avalon7123 天前
UniVue大版本更新:UniVue2.0.0-preview
游戏·ui·unity·c#
iQM754 天前
TinyVue:一款轻量级且功能强大的Vue UI组件库
前端·javascript·vue.js·ui·jenkins·excel
Logrus IT4 天前
如何提高游戏本地化的质量使用QE门户网站Logrus IT
ui·软件工程·玩游戏
Stu古月月仔5 天前
虚幻引擎-设置UI自适应屏幕大小
ui·游戏引擎·虚幻
coffee_baby5 天前
状态模式原理剖析
java·ui·ajax·设计模式·状态模式
宋小土6 天前
Naive UI 选择器 Select 的:render-label 怎么使用(Vue3 + TS)
开发语言·前端·javascript·vue.js·ui