rimworld-animation-studio/Assets/Scripts/GUI/StageCard.cs

61 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class StageCard : MonoBehaviour
{
private Image banner;
private Toggle toggle;
public void OnNameChange()
{
}
public void OnSelectStage()
{
if (GetComponent<Toggle>().isOn && Workspace.stageID != transform.GetSiblingIndex())
{ Workspace.stageID = transform.GetSiblingIndex(); }
}
public void OnMoveStage(int delta)
{
if (AnimationController.Instance.MoveAnimationStage(transform.GetSiblingIndex(), delta))
{
int siblingCount = transform.parent.childCount;
int index = Mathf.Clamp(transform.GetSiblingIndex() + delta, 0, siblingCount - 1);
transform.SetSiblingIndex(index);
}
}
public void Start()
{
banner = transform.Find("Banner").GetComponent<Image>();
toggle = GetComponent<Toggle>();
toggle.group = StageCardManager.Instance.GetComponent<ToggleGroup>();
}
public void Update()
{
if (Workspace.stageID == transform.GetSiblingIndex())
{
banner.gameObject.SetActive(true);
if (toggle.isOn == false)
{ toggle.isOn = true; }
}
else
{
banner.gameObject.SetActive(false);
if (toggle.isOn)
{ toggle.isOn = false; }
}
}
}
}