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 RichLabel, 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.
Note: decorators like OnEvent, OnButtonClick does not support this $: yet. I'm still working on making all APIs consistent.