using UnityEngine; using UnityEngine.UI; public class ShieldRelocator : MonoBehaviour { public Transform pcAnchor; public Transform mobileAnchor; void Awake() { bool isMobile = Application.isMobilePlatform; Transform targetParent = isMobile ? mobileAnchor : pcAnchor; transform.SetParent(targetParent, false); RectTransform rect = GetComponent(); rect.pivot = new Vector2(0.5f, 0.5f); rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); rect.anchoredPosition = Vector2.zero; LayoutRebuilder.ForceRebuildLayoutImmediate(rect); } }