Files

28 lines
686 B
C#
Raw Permalink Normal View History

using UnityEngine;
using UnityEngine.UI;
public class ShieldRelocator : MonoBehaviour
{
2026-04-29 09:22:08 +09:00
public Transform pcAnchor;
public Transform mobileAnchor;
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);
}
}