rimworld-animation-studio/Assets/Scripts/GUI/SelfContained/RequiresAnimationDef.cs
AbstractConcept 5ca7e486f8 Code refactor
2022-10-28 19:52:58 -05:00

35 lines
990 B
C#

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