using System.Collections.Generic; using CinemaDirector.Helpers; using UnityEngine; namespace CinemaDirector { [CutsceneItem("Utility", "Mass Disabler", new CutsceneItemGenre[] { CutsceneItemGenre.GlobalItem })] public class MassDisabler : CinemaGlobalAction, IRevertable { public List GameObjects = new List(); public List Tags = new List(); private List tagsCache = new List(); [SerializeField] private RevertMode editorRevertMode; [SerializeField] private RevertMode runtimeRevertMode; public RevertMode EditorRevertMode { get { return editorRevertMode; } set { editorRevertMode = value; } } public RevertMode RuntimeRevertMode { get { return runtimeRevertMode; } set { runtimeRevertMode = value; } } public RevertInfo[] CacheState() { List list = new List(); foreach (string tag in Tags) { GameObject[] array = GameObject.FindGameObjectsWithTag(tag); GameObject[] array2 = array; foreach (GameObject gameObject in array2) { if (gameObject != null) { list.Add(gameObject); } } } list.AddRange(GameObjects); List list2 = new List(); foreach (GameObject item in list) { if (item != null) { list2.Add(new RevertInfo(this, item, "SetActive", item.activeInHierarchy)); } } return list2.ToArray(); } public override void Trigger() { tagsCache.Clear(); foreach (string tag in Tags) { GameObject[] array = GameObject.FindGameObjectsWithTag(tag); GameObject[] array2 = array; foreach (GameObject item in array2) { tagsCache.Add(item); } } setActive(false); } public override void End() { setActive(true); } public override void ReverseTrigger() { End(); } public override void ReverseEnd() { Trigger(); } private void setActive(bool enabled) { foreach (GameObject gameObject in GameObjects) { gameObject.SetActive(enabled); } foreach (GameObject item in tagsCache) { item.SetActive(enabled); } } } }