修复web平台兼容性问题

This commit is contained in:
shenjianxing 2025-03-27 13:14:48 +08:00
parent b7c053dd0c
commit 41c68a734a
8 changed files with 32 additions and 27 deletions

View File

@ -44,14 +44,14 @@ public class DeviceController : MonoSingleton<DeviceController>
} }
if (uitip != null) if (uitip != null)
{ {
uitip.Set(deviceItem.tipItem.label); uitip.Open(new UIDeviceTipData() { txt = deviceItem.tipItem.label });
uitip.Active(true); uitip.Show();
return; return;
} }
} }
else else
{ {
uitip?.Active(false); uitip?.Hide();
} }
} }
@ -100,10 +100,6 @@ public class DeviceController : MonoSingleton<DeviceController>
{ {
#if !VR #if !VR
var uitip = UIKit.GetPanel<UIDeviceTip>(); var uitip = UIKit.GetPanel<UIDeviceTip>();
if (uitip != null)
{
uitip = UIKit.OpenPanel<UIDeviceTip>(UILevel.PopUI);
}
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit; RaycastHit hit;
if (Physics.Raycast(ray, out hit)) if (Physics.Raycast(ray, out hit))
@ -112,12 +108,12 @@ public class DeviceController : MonoSingleton<DeviceController>
if (uitip != null && deviceItem != null && deviceItem.tipItem != null && EventSystem.current.IsPointerOverGameObject() == false) if (uitip != null && deviceItem != null && deviceItem.tipItem != null && EventSystem.current.IsPointerOverGameObject() == false)
{ {
uitip.Set(deviceItem.tipItem.label); uitip.Open(new UIDeviceTipData() { txt = deviceItem.tipItem.label });
uitip.Active(true); uitip.Show();
return; return;
} }
} }
uitip?.Active(false); uitip?.Hide();
#endif #endif
} }
public DeviceItem GetDeviceItem(string name) public DeviceItem GetDeviceItem(string name)

View File

@ -28,7 +28,7 @@ public class TipItem : MonoBehaviour
{ {
if (tip != null) if (tip != null)
{ {
tip.Active(false); tip.Hide();
} }
} }
} }
@ -59,22 +59,25 @@ public class TipItem : MonoBehaviour
tip = UIKit.GetPanel<UIDeviceTip>(); tip = UIKit.GetPanel<UIDeviceTip>();
if (tip == null) if (tip == null)
{ {
tip = UIKit.OpenPanel<UIDeviceTip>(UILevel.PopUI); Debug.LogError($"{gameObject}:Tip");
UIKit.OpenPanelAsync<UIDeviceTip>(UILevel.PopUI).ToAction().StartGlobal(() =>
tip.Set(label); {
tip.Active(true); tip = UIKit.GetPanel<UIDeviceTip>();
tip.Open(new UIDeviceTipData() { txt = label });
tip.Show();
});
} }
else else
{ {
tip.Set(label); tip.Open(new UIDeviceTipData() { txt = label});
tip.Active(true); tip.Show();
} }
} }
public void OnExit() public void OnExit()
{ {
if (tip != null) if (tip != null)
{ {
tip.Active(false); tip.Hide();
} }
} }
@ -87,7 +90,7 @@ public class TipItem : MonoBehaviour
{ {
if (tip != null) if (tip != null)
{ {
tip.Active(false); tip.Hide();
} }
} }
} }

View File

@ -41,6 +41,8 @@ public class Launch : MonoBehaviour
}); });
yield return UIKit.OpenPanelAsync<UILoading>(); yield return UIKit.OpenPanelAsync<UILoading>();
yield return UIKit.OpenPanelAsync<UIDeviceTip>(canvasLevel: UILevel.PopUI);
UIKit.GetPanel<UIDeviceTip>().Hide();
yield return new WaitUntil(() => isLoadFinished == true); yield return new WaitUntil(() => isLoadFinished == true);
if (Global.Instance.appData.preLoad != null && Global.Instance.appData.preLoad.action != null) if (Global.Instance.appData.preLoad != null && Global.Instance.appData.preLoad.action != null)
{ {

View File

@ -8,6 +8,7 @@ namespace QFramework.Example
{ {
public class UIDeviceTipData : UIPanelData public class UIDeviceTipData : UIPanelData
{ {
public string txt;
} }
public partial class UIDeviceTip : UIPanel public partial class UIDeviceTip : UIPanel
{ {
@ -20,6 +21,11 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)
{ {
if (uiData != null)
{
mData = uiData as UIDeviceTipData ?? new UIDeviceTipData();
Label.text = Regex.Replace(mData.txt, @"\\n", "\n");
}
} }
#if !VR #if !VR
@ -33,21 +39,19 @@ namespace QFramework.Example
} }
#endif #endif
public void Set(string txt) //public void Active(bool active)
{ //{
Label.text = Regex.Replace(txt, @"\\n", "\n"); // Point.gameObject.SetActive(active);
} //}
public void Active(bool active)
{
Point.gameObject.SetActive(active);
}
protected override void OnShow() protected override void OnShow()
{ {
//Active(true);
} }
protected override void OnHide() protected override void OnHide()
{ {
//Active(false);
} }
protected override void OnClose() protected override void OnClose()