2025-02-10 10:54:47 +08:00

62 lines
1.1 KiB
C#

using QFramework;
using QFramework.Example;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class TipItem : MonoBehaviour
{
UIDeviceTip tip;
public string label;
public void Set(string label)
{
this.label = label;
}
private void OnMouseEnter()
{
OnEnter();
}
public void OnEnter()
{
tip = UIKit.GetPanel<UIDeviceTip>();
if (tip == null)
{
UIKit.OpenPanelAsync<UIDeviceTip>(UILevel.PopUI).ToAction().Start(this, () =>
{
tip = UIKit.GetPanel<UIDeviceTip>();
tip.Set(label);
tip.Active(true);
});
}
else
{
tip.Set(label);
tip.Active(true);
}
}
public void OnExit()
{
if (tip != null)
{
tip.Active(false);
}
}
private void OnMouseExit()
{
OnExit();
}
private void OnMouseUpAsButton()
{
if (tip != null)
{
tip.Active(false);
}
}
}