For all callback related parameter like ShowIf, HideIf, EnableIf, DisableIf, RequiredIf, FieldShowIf, FieldHideIf, FieldEnableIf, FieldDisableIf,
and the show parameter in InfoBox, AboveText etc.
They use this XPath-like syntax, but the start point is from the current field.
For example, by using upwalk, damage will only be enabled if it's a member (field/propery) of BuildObject type (or its subtype)
[Serializable] public class BuildingAttackBrain { [EnableIf("..@as(BuildObject)")] [InfoBox("Only available in BuildObject type", show: "..@not-as(BuildObject)")] public int damage; }
you can also downwalk
[Serializable] public struct DownWalkProp { public string myContent; } // same as: [AboveText("<field.myContent/>")] [AboveText("$field::" + nameof(DownWalkProp.myContent))] public DownWalkProp v2;
For decorators that accept a callback, you can usually use $ to indicate that you want a callback. The callback can be a method, a property, or a field.
Use \\$ if you do not want it to be a callback. This is useful for decorators like LabelText, InfoBox that the displaying string itself starts with $.
Using $: if the callback is a static/const field. We support the following style:
namespace SaintsField.Samples.Scripts { public class StaticCallback : SaintsMonoBehaviour { private static readonly string StaticString = "This is a static string"; private const string ConstString = "This is a constant string"; // using full type name [AboveText("$:SaintsField.Samples.Scripts." + nameof(StaticCallback) + "." + nameof(StaticString))] // using only type name. This is slow and might find the incorrect target. // We'll first search the assembly of this object. If not found, then search all assemblies. [InfoBox("$:" + nameof(StaticCallback) + "." + nameof(ConstString))] public int field; #if UNITY_EDITOR private static Texture2D ImageCallback(string name) => AssetDatabase.LoadAssetAtPath<Texture2D>( quot;Assets/SaintsField/Editor/Editor Default Resources/SaintsField/{name}.png"); #endif #if UNITY_EDITOR // use only field/method name. This will only try to search on the current target. [BelowImage("$:" + nameof(ImageCallback), maxWidth: 20)] #endif public string imgName; [ShowInInspector] private static bool _disableMe = true; #if UNITY_EDITOR [DisableIf("$:" + nameof(_disableMe))] [RequiredIf("$:" + nameof(_disableMe), false)] #endif public string disableIf; } }
You can skip the namespace part. And if you also skip the type part, we'll try to find the callback from the current type first, then search all types in the current assembly, and finally search all types in all assemblies.