Enum CompareOperator
Specifies the comparison operator used when evaluating a field condition in a conditional Inspector attribute.
Namespace: Scylla.Core.Attributes
Assembly: ScyllaCore.dll
Syntax
public enum CompareOperator
Remarks
CompareOperator is consumed by ConditionalAttributeBase and
all attributes that derive from it -
ShowIfAttribute, HideIfAttribute,
EnableIfAttribute, and DisableIfAttribute.
The operator controls how the runtime value of the condition field is compared
against the value supplied to the attribute constructor.
When no explicit CompareOperator is provided to a conditional attribute,
Equals is used as the default. When no compare value is provided
at all (i.e. only a field name is given), the condition evaluates the
truthiness of the field - non-zero numbers, non-null references, and
non-empty strings are treated as true.
Ordering operators (LessThan, LessThanOrEqual,
GreaterThan, GreaterThanOrEqual) are meaningful
only for numeric field types (int, float, double, etc.).
Applying them to non-numeric fields produces undefined behaviour in the custom
Inspector drawer.
BitwiseAnd is intended for fields whose type is an enum
decorated with [System.Flags]. The condition is met when the bitwise AND
of the field value and the compare value is non-zero, meaning at least one of
the specified flag bits is set.
Equality check - show a prefab slot only when a boolean toggle is enabled:
[SerializeField] private bool _useProjectile;
[ShowIf(nameof(_useProjectile))] // implicit Equals + truthiness
[SerializeField] private GameObject _projectilePrefab;
Ordering check - show a critical-hit VFX slot only when damage exceeds a threshold:
[SerializeField] private int _attackDamage = 25;
[ShowIf(nameof(_attackDamage), 50, CompareOperator.GreaterThan)]
[SerializeField] private ParticleSystem _criticalHitEffect;
Flags check - enable an advanced options group only when certain mode flags are set:
[System.Flags]
public enum DebugFlags { None = 0, Verbose = 1, Profiling = 2, Networking = 4 }
[SerializeField] private DebugFlags _activeFlags;
[ShowIf(nameof(_activeFlags), DebugFlags.Profiling, CompareOperator.BitwiseAnd)]
[SerializeField] private int _profilingSampleCount = 100;
Fields
| Name | Description |
|---|---|
| BitwiseAnd | Condition is met when the bitwise AND of the field value and the compare value is non-zero - meaning at least one flag bit specified in the compare value is set on the field. |
| Equals | Condition is met when the field value is equal to the compare value. |
| GreaterThan | Condition is met when the field value is strictly greater than the compare value. |
| GreaterThanOrEqual | Condition is met when the field value is greater than or equal to the compare value. |
| LessThan | Condition is met when the field value is strictly less than the compare value. |
| LessThanOrEqual | Condition is met when the field value is less than or equal to the compare value. |
| NotEquals | Condition is met when the field value is not equal to the compare value. |