rimworld-animation-studio/Assets/Scripts/RequiresAnimationDef.cs

36 lines
988 B
C#
Raw Normal View History

2022-09-19 05:35:34 +00:00
using System.Collections;
using System.Collections.Generic;
2022-10-15 06:00:47 +00:00
using System.Linq;
2022-09-19 05:35:34 +00:00
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class RequiresAnimationDef : MonoBehaviour
{
private Button button;
2022-10-15 06:00:47 +00:00
private List<Text> buttonText;
private List<Color> buttonTextColor = new List<Color>();
2022-09-19 05:35:34 +00:00
public void Start()
{
button = GetComponent<Button>();
2022-10-15 06:00:47 +00:00
buttonText = GetComponentsInChildren<Text>()?.ToList();
if (buttonText != null)
{
for (int i = 0; i < buttonText.Count; i++)
{ buttonTextColor.Add(buttonText[i].color); }
}
2022-09-19 05:35:34 +00:00
}
public void Update()
{
button.interactable = Workspace.animationDef != null;
2022-10-15 06:00:47 +00:00
for (int i = 0; i < buttonText.Count; i++)
{ buttonText[i].color = button.interactable ? buttonTextColor[i] : Constants.ColorMidGrey; }
2022-09-19 05:35:34 +00:00
}
}
}