using System.Collections.Generic; using TriInspector; using UnityEngine; namespace R0bbie.Timeline { /// /// Activate GameObjects from a list /// [AddComponentMenu("Timeline/Commands/GameObjects Set Active (Step Command)")] [RequireComponent(typeof(Step))] public class GameObjectsSetActiveCmd : StepCmd { [Title("Set Objects Status")] [SerializeField] List objectsToActivate = new List(); [SerializeField] List objectsToDeactivate = new List(); protected override void Init() { init = true; } public override void Activate(Step _parentStep) { base.Activate(_parentStep); // Activate all requested GameObjects foreach (var objectToActivate in objectsToActivate) { objectToActivate.SetActive(true); } // Deactivate all requested GameObjects foreach (var objectToDeactivate in objectsToDeactivate) { objectToDeactivate.SetActive(false); } // Then job of this command is done, complete it and deactivate Complete(); } protected override void Cleanup() { active = false; } } }