From f40abb21326c5a415c19ed1dae429f11031c8ab6 Mon Sep 17 00:00:00 2001 From: Le Duc Anh Date: Fri, 30 Jan 2026 17:21:15 +0700 Subject: [PATCH] update host player pos --- Assets/PerfectWorld/Prefab/UI/MiniMap.prefab | 6 +++--- .../Scripts/UI/MiniMap/MiniMapUI.cs | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Assets/PerfectWorld/Prefab/UI/MiniMap.prefab b/Assets/PerfectWorld/Prefab/UI/MiniMap.prefab index ea62888b08..d6a69e6547 100644 --- a/Assets/PerfectWorld/Prefab/UI/MiniMap.prefab +++ b/Assets/PerfectWorld/Prefab/UI/MiniMap.prefab @@ -276,7 +276,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: dbb3be46f1d07224f90ade7b25776f34, type: 3} m_Name: m_EditorClassIdentifier: - _debugHostPlayerPos: {x: 902, y: 138, z: 208} + _debugHostPlayerPos: {x: -225, y: 138, z: -19} _hostPlayerIcon: {fileID: 7794785241219751657} m_pA3DRadarBack: {fileID: 0} m_TexRadarBack: {fileID: 0} @@ -675,7 +675,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: 490, 570, 13 + m_text: 378, 549, 13 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -855,7 +855,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 141, y: 72} + m_AnchoredPosition: {x: 360, y: -28} m_SizeDelta: {x: 8, y: 8} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &1911266972102470756 diff --git a/Assets/PerfectWorld/Scripts/UI/MiniMap/MiniMapUI.cs b/Assets/PerfectWorld/Scripts/UI/MiniMap/MiniMapUI.cs index 77cf415bef..121fa34c93 100644 --- a/Assets/PerfectWorld/Scripts/UI/MiniMap/MiniMapUI.cs +++ b/Assets/PerfectWorld/Scripts/UI/MiniMap/MiniMapUI.cs @@ -111,6 +111,7 @@ namespace PerfectWorld.UI.MiniMap Vector2 C = rcMiniMap.center; Vector2Int ptHost = new Vector2Int(); + Vector2 ptHostFloat = new Vector2(); Vector2Int idxHost = new Vector2Int(); Vector2Int ptThisCenter = new Vector2Int(); Vector2Int[] idxCorner = new Vector2Int[MINIMAP_MAX]; @@ -127,14 +128,17 @@ namespace PerfectWorld.UI.MiniMap ptHost.x = Mathf.FloorToInt((vecPosHost.x + fOffsetX) * 512.0f / 1024.0f); ptHost.y = Mathf.FloorToInt((fOffsetY - vecPosHost.z) * 512.0f / 1024.0f); + ptHostFloat.x = (vecPosHost.x + fOffsetX) * 512.0f / 1024.0f; + ptHostFloat.y = (fOffsetY - vecPosHost.z) * 512.0f / 1024.0f; idxHost.x = ptHost.x / nSide; idxHost.y = ptHost.y / nSide; - rcThis.x = idxHost.x * nSide; - rcThis.y = idxHost.y * nSide; - rcThis.width = nSide; - rcThis.height = nSide; + rcThis.xMin = idxHost.x * nSide; + rcThis.yMax = idxHost.y * nSide; + rcThis.xMax = rcThis.xMin + nSide; + rcThis.yMin = rcThis.yMax + nSide; + RectTransform hostPlayerIconClone = null; ptThisCenter = rcThis.Center(); if( ptHost.y <= ptThisCenter.y ) { @@ -148,6 +152,7 @@ namespace PerfectWorld.UI.MiniMap idxCorner[MINIMAP_LL].y = idxHost.y; idxCorner[MINIMAP_LR].x = idxHost.x; idxCorner[MINIMAP_LR].y = idxHost.y; + hostPlayerIconClone = Instantiate(_hostPlayerIcon, m_ImageMapParts[MINIMAP_LR].transform); } else // Upper right. { @@ -159,6 +164,8 @@ namespace PerfectWorld.UI.MiniMap idxCorner[MINIMAP_LL].y = idxHost.y; idxCorner[MINIMAP_LR].x = idxHost.x + 1; idxCorner[MINIMAP_LR].y = idxHost.y; + // _hostPlayerIcon.transform.SetParent(m_ImageMapParts[MINIMAP_LR].transform); + hostPlayerIconClone = Instantiate(_hostPlayerIcon, m_ImageMapParts[MINIMAP_LL].transform); } } else @@ -173,6 +180,8 @@ namespace PerfectWorld.UI.MiniMap idxCorner[MINIMAP_LL].y = idxHost.y + 1; idxCorner[MINIMAP_LR].x = idxHost.x; idxCorner[MINIMAP_LR].y = idxHost.y + 1; + // _hostPlayerIcon.transform.SetParent(m_ImageMapParts[MINIMAP_UL].transform); + hostPlayerIconClone = Instantiate(_hostPlayerIcon, m_ImageMapParts[MINIMAP_UR].transform); } else // Lower right. { @@ -184,6 +193,8 @@ namespace PerfectWorld.UI.MiniMap idxCorner[MINIMAP_LL].y = idxHost.y + 1; idxCorner[MINIMAP_LR].x = idxHost.x + 1; idxCorner[MINIMAP_LR].y = idxHost.y + 1; + // _hostPlayerIcon.transform.SetParent(m_ImageMapParts[MINIMAP_UR].transform); + hostPlayerIconClone = Instantiate(_hostPlayerIcon, m_ImageMapParts[MINIMAP_UL].transform); } } @@ -199,7 +210,7 @@ namespace PerfectWorld.UI.MiniMap rcHost.width = Mathf.FloorToInt(W * m_fZoom); rcHost.height = Mathf.FloorToInt(H * m_fZoom); - _hostPlayerIcon.anchoredPosition = new Vector2(rcHost.x / 10, rcHost.y / 10); + hostPlayerIconClone.anchoredPosition = new Vector2(ptHostFloat.x - ptThisCenter.x, ptHostFloat.y - ptThisCenter.y); int i, j; bool bval;