using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; namespace RimWorldAnimationStudio { public class SelectActorLayerDialog : DialogBox { public void OnEnable() { Initialize(); } public void Initialize() { if (Workspace.animationDef == null) return; Transform contentWindow = transform.FindDeepChild("Content"); Reset(); for (int i = 0; i < Workspace.actorLayers.Count; i++) { string actorLayer = Workspace.actorLayers[i]; Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform; _optionToggle.Find("Text").GetComponent().text = actorLayer; Toggle toggleComp = _optionToggle.GetComponent(); toggleComp.isOn = Workspace.Instance.GetCurrentPawnAnimationClip().layer == actorLayer; toggleComp.onValueChanged.AddListener(delegate { PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip(); if (clip != null) { clip.layer = actorLayer; } Workspace.Instance.RecordEvent("Actor layer set"); }); toggleComp.group = contentWindow.GetComponent(); } } public void Reset() { Transform contentWindow = transform.FindDeepChild("Content"); RemoveCloneObjectsFromParent(contentWindow); } } }