Files
Continentis/Assets/OtherPlugins/Feel/MMTools/Accessories/MMActivation/MMConditionalActivation.cs
SoulliesOfficial d09b58fd80 架构大更
2026-03-20 11:56:50 -04:00

39 lines
1.2 KiB
C#

using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this component to a gameobject, and it'll let you enable target monos after all other targets have been
/// disabled
/// </summary>
[AddComponentMenu("More Mountains/Tools/Activation/MM Conditional Activation")]
public class MMConditionalActivation : MonoBehaviour
{
/// a list of monos to enable
public MonoBehaviour[] EnableThese;
/// a list of all the monos that have to have been disabled first
public MonoBehaviour[] AfterTheseAreAllDisabled;
protected bool _enabled;
/// <summary>
/// On update, we check if we should disable
/// </summary>
protected virtual void Update()
{
if (_enabled) return;
var allDisabled = true;
foreach (var component in AfterTheseAreAllDisabled)
if (component.isActiveAndEnabled)
allDisabled = false;
if (allDisabled)
{
foreach (var component in EnableThese) component.enabled = true;
_enabled = true;
}
}
}
}