using System; using TMPro; using UnityEngine; using UnityEngine.UI; namespace ShrinkTutorial { public class ShrinkTutorialDialog : MonoBehaviour { private RectTransform _rectTransform; private RectTransform _arrowRectTransform; private TextMeshProUGUI _contentText; private GameObject _skipButtonObject; private Action _skipAction; public void Initialize(Transform parent, Action skipAction) { _skipAction = skipAction; _rectTransform = GetComponent(); if (!_rectTransform) _rectTransform = gameObject.AddComponent(); _rectTransform.SetParent(parent, false); _rectTransform.sizeDelta = new Vector2(360f, 180f); _rectTransform.anchorMin = new Vector2(0.5f, 0.5f); _rectTransform.anchorMax = new Vector2(0.5f, 0.5f); _rectTransform.pivot = new Vector2(0.5f, 0.5f); var background = gameObject.AddComponent(); background.color = new Color(0.08f, 0.1f, 0.14f, 0.96f); background.raycastTarget = true; var content = CreateText("Content", "Tutorial", 24, TextAlignmentOptions.TopLeft); var contentRect = content.rectTransform; contentRect.SetParent(_rectTransform, false); contentRect.anchorMin = new Vector2(0f, 0f); contentRect.anchorMax = new Vector2(1f, 1f); contentRect.offsetMin = new Vector2(24f, 64f); contentRect.offsetMax = new Vector2(-24f, -24f); _contentText = content; var skipButton = new GameObject("SkipButton", typeof(RectTransform), typeof(Image), typeof(Button)); var skipRect = skipButton.GetComponent(); skipRect.SetParent(_rectTransform, false); skipRect.anchorMin = new Vector2(1f, 0f); skipRect.anchorMax = new Vector2(1f, 0f); skipRect.pivot = new Vector2(1f, 0f); skipRect.anchoredPosition = new Vector2(-16f, 16f); skipRect.sizeDelta = new Vector2(96f, 36f); var skipImage = skipButton.GetComponent(); skipImage.color = new Color(0.22f, 0.34f, 0.5f, 1f); var skipButtonComponent = skipButton.GetComponent