55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using TriInspector;
|
|
using UnityEngine;
|
|
|
|
namespace R0bbie.Timeline
|
|
{
|
|
/// <summary>
|
|
/// Activate GameObjects from a list
|
|
/// </summary>
|
|
[AddComponentMenu("Timeline/Commands/GameObjects Set Active (Step Command)")]
|
|
[RequireComponent(typeof(Step))]
|
|
public class GameObjectsSetActiveCmd : StepCmd
|
|
{
|
|
[Title("Set Objects Status")]
|
|
[SerializeField] List<GameObject> objectsToActivate = new List<GameObject>();
|
|
[SerializeField] List<GameObject> objectsToDeactivate = new List<GameObject>();
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
}
|
|
}
|