技能主要更新,修复卡顿并加入动画,以及各种其他更新。
This commit is contained in:
@@ -2,8 +2,8 @@ using UnityEngine;
|
||||
|
||||
public class WebViewPanelFollower : MonoBehaviour
|
||||
{
|
||||
public RectTransform panelRect; // 拖拽要跟随的 UI Panel 的 RectTransform
|
||||
public Camera uiCamera; // UI 相机,通常是 Canvas 的 Event Camera
|
||||
public RectTransform panelRect; // ��קҪ����� UI Panel �� RectTransform
|
||||
public Camera uiCamera; // UI �����ͨ���� Canvas �� Event Camera
|
||||
|
||||
private Rect lastPanelRect;
|
||||
private WebViewWin32.RECT lastUnityWindowRect;
|
||||
@@ -43,17 +43,17 @@ public class WebViewPanelFollower : MonoBehaviour
|
||||
if (panelRect == null || uiCamera == null || WebViewLauncher.Instance == null)
|
||||
return;
|
||||
|
||||
// 获取当前 panel 的屏幕矩形
|
||||
// ��ȡ��ǰ panel ����Ļ����
|
||||
Rect currentPanelRect = GetPanelScreenRect(panelRect);
|
||||
|
||||
// 获取当前 Unity 窗口位置(仅在 build 中需要)
|
||||
WebViewWin32.RECT currentUnityWindowRect = new WebViewWin32.RECT();
|
||||
// ��ȡ��ǰ Unity ����λ�ã����� build ����Ҫ��
|
||||
#if !UNITY_EDITOR
|
||||
WebViewWin32.RECT currentUnityWindowRect = new WebViewWin32.RECT();
|
||||
if (!WebViewWin32.TryGetClientScreenRect(System.Diagnostics.Process.GetCurrentProcess(), out currentUnityWindowRect))
|
||||
return;
|
||||
#endif
|
||||
|
||||
// 检查是否需要更新
|
||||
// ����Ƿ���Ҫ����
|
||||
if (!hasLastRect ||
|
||||
!ApproximatelyEqual(currentPanelRect, lastPanelRect)
|
||||
#if !UNITY_EDITOR
|
||||
@@ -63,18 +63,18 @@ public class WebViewPanelFollower : MonoBehaviour
|
||||
{
|
||||
int x, y;
|
||||
#if UNITY_EDITOR
|
||||
// 在编辑器中,直接使用屏幕坐标(相对于屏幕左上角)
|
||||
// �ڱ༭���У�ֱ��ʹ����Ļ���꣨�������Ļ���Ͻǣ�
|
||||
x = Mathf.RoundToInt(currentPanelRect.x);
|
||||
y = Mathf.RoundToInt(Screen.height - currentPanelRect.y - currentPanelRect.height);
|
||||
#else
|
||||
// 在 build 中,使用 Unity 窗口位置 + 相对坐标
|
||||
// �� build �У�ʹ�� Unity ����λ�� + �������
|
||||
x = Mathf.RoundToInt(currentUnityWindowRect.Left + currentPanelRect.x);
|
||||
y = Mathf.RoundToInt(currentUnityWindowRect.Top + (Screen.height - currentPanelRect.y - currentPanelRect.height));
|
||||
#endif
|
||||
int w = Mathf.RoundToInt(currentPanelRect.width);
|
||||
int h = Mathf.RoundToInt(currentPanelRect.height);
|
||||
|
||||
// 更新 WebView 窗口
|
||||
// ���� WebView ����
|
||||
bool success = WebViewLauncher.Instance.TryUpdateWebViewRect(x, y, w, h);
|
||||
if (success)
|
||||
{
|
||||
@@ -102,8 +102,8 @@ public class WebViewPanelFollower : MonoBehaviour
|
||||
|
||||
Rect currentPanelRect = GetPanelScreenRect(panelRect);
|
||||
|
||||
WebViewWin32.RECT currentUnityWindowRect = new WebViewWin32.RECT();
|
||||
#if !UNITY_EDITOR
|
||||
WebViewWin32.RECT currentUnityWindowRect = new WebViewWin32.RECT();
|
||||
if (!WebViewWin32.TryGetClientScreenRect(System.Diagnostics.Process.GetCurrentProcess(), out currentUnityWindowRect))
|
||||
return;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user