using System; using CIG.Translation; using SUISS.Core; using Tweening; using UnityEngine; public class OverlayTitle : MonoBehaviour { public void Initialize(ILocalizedString titleText, ILocalizedString subtitleText = null) { this._title.LocalizedString = titleText; if (Localization.IsNullOrEmpty(subtitleText)) { this._subtitle.gameObject.SetActive(false); } else { this._subtitle.gameObject.SetActive(true); this._subtitle.LocalizedString = subtitleText; } } public void ShowOpenAnimation(Action onFinished = null) { if (this._tweener.IsPlaying) { this._tweener.Stop(); } if (onFinished != null) { Tweener.FinishedPlayingEventHandler onFinishedInternal = null; onFinishedInternal = delegate(Tweener tweener) { tweener.FinishedPlaying -= onFinishedInternal; onFinished(); }; this._tweener.FinishedPlaying += onFinishedInternal; } this._tweener.Reset(false); this._tweener.Play(); } public void ShowCloseAnimation(Action onFinished = null) { if (this._tweener.IsPlaying) { this._tweener.Stop(); } if (onFinished != null) { Tweener.FinishedPlayingEventHandler onFinishedInternal = null; onFinishedInternal = delegate(Tweener tweener) { tweener.FinishedPlaying -= onFinishedInternal; onFinished(); }; this._tweener.FinishedPlaying += onFinishedInternal; } this._tweener.Reset(true); this._tweener.PlayReverse(); } public static OverlayTitle Get(Component comp) { OverlayTitle overlayTitle = comp.GetComponent(); if (overlayTitle == null) { overlayTitle = OverlayTitle.Create(comp.gameObject); } return overlayTitle; } private static OverlayTitle Create(GameObject go) { OverlayManager instance = SingletonMonobehaviour.Instance; return instance.CreateOverlay(go, instance.TitlePrefab); } [SerializeField] private LocalizedText _title; [SerializeField] private LocalizedText _subtitle; [SerializeField] private Tweener _tweener; }