rabidus-test/Assets/MonumentPreview.cs

41 lines
852 B
C#
Raw Permalink Normal View History

2023-10-02 19:12:35 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MonumentPreview : MonoBehaviour
{
[SerializeField] private Image _image;
[SerializeField] private UITextShow _UITextShow;
private Animator _animator;
private void Awake()
{
_animator = GetComponent<Animator>();
}
private bool _isOpened = false;
public void ShowInfo(MonumentInfo monumentInfo)
{
_image.sprite = monumentInfo.Image;
_UITextShow.ShowSubtitle(monumentInfo.Description, 0, 5f, OpenWindow, HideWindow);
}
private void OpenWindow()
{
if (_isOpened)
return;
_isOpened = true;
_animator.Play("Open");
}
private void HideWindow()
{
_animator.Play("Close");
_isOpened = false;
}
}