You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace MalbersAnimations.Conditions
|
|
|
|
|
|
{
|
|
|
|
|
|
public enum ComponentCondition {Enabled, ActiveAndEnabled }
|
|
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
public class C_Behaviour : MCondition
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string DisplayName => "Unity/Behavior";
|
|
|
|
|
|
|
|
|
|
|
|
[Tooltip("Target to check for the condition ")]
|
|
|
|
|
|
[RequiredField] public Behaviour Target;
|
|
|
|
|
|
[Tooltip("Conditions types")]
|
|
|
|
|
|
public ComponentCondition Condition;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override bool _Evaluate()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Target != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (Condition)
|
|
|
|
|
|
{
|
|
|
|
|
|
case ComponentCondition.Enabled: return Target.enabled;
|
|
|
|
|
|
case ComponentCondition.ActiveAndEnabled: return Target.isActiveAndEnabled;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void SetTarget(Object target)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (target is Behaviour) this.Target = target as Behaviour;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Reset() => Name = "New Behaviour Condition";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|