This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/UI/ObjectiveText.cs

55 lines
1.3 KiB
C#
Raw Permalink Normal View History

2023-06-01 17:03:48 +02:00
using System;
using System.Collections.Generic;
2023-06-01 17:03:48 +02:00
using TMPro;
using UnityEngine;
using UnityEngine.UI;
2023-06-02 06:30:58 +02:00
namespace UI
{
2023-06-02 06:30:58 +02:00
[ExecuteAlways]
public class ObjectiveText : MonoBehaviour
{
[SerializeField] public List<VisualObjectiveItemGUI> visualObjects;
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[SerializeField] private Color inCompleteColor = Color.white;
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[SerializeField] private Color completeColor = Color.yellow;
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[SerializeField] private float speed;
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[SerializeField] private Animator animator;
2023-06-02 06:30:58 +02:00
// Start is called before the first frame update
private void Start()
{
}
2023-06-02 06:30:58 +02:00
// Update is called once per frame
private void Update()
{
foreach (var item in visualObjects)
if (item.isComplete)
item.icon.color = Color.Lerp(item.icon.color, completeColor, Time.deltaTime * speed);
else
item.icon.color = Color.Lerp(item.icon.color, inCompleteColor, Time.deltaTime * speed);
}
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
public void FadeOut()
{
animator.Play("FadeOut");
}
public void FadeIn()
{
animator.Play("FadeIn");
}
}
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[Serializable]
public class VisualObjectiveItemGUI
{
2023-06-02 06:30:58 +02:00
public TMP_Text text;
public Image icon;
public bool isComplete;
}
}