2026-04-22 13:56:03 +09:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class ShieldRelocator : MonoBehaviour
|
|
|
|
|
{
|
2026-04-29 09:22:08 +09:00
|
|
|
public Transform pcAnchor;
|
|
|
|
|
public Transform mobileAnchor;
|
2026-04-22 13:56:03 +09:00
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
bool isMobile = Application.isMobilePlatform;
|
|
|
|
|
Transform targetParent = isMobile ? mobileAnchor : pcAnchor;
|
|
|
|
|
|
|
|
|
|
transform.SetParent(targetParent, false);
|
|
|
|
|
|
|
|
|
|
RectTransform rect = GetComponent<RectTransform>();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|