OnButtonClickImportantEnableSaintsEditorbefore using
This is a method decorator, which will bind this method to the target button's click event.
Parameters:
string buttonTarget=nullthe target button.nullto get it form the current target.object value=nullthe value passed to the method. Note unity only supportbool,int,float,stringandUnityEngine.Object. To pass aUnityEngine.Object, use a string name of the target, and set theisCallbackparameter totruebool isCallback=false: whenvalueis a string, set this totrueto obtain the actual value from a method/property/field
// Please ensure you already have SaintsEditor enabled in your project before trying this example using SaintsField.Playa; [OnButtonClick] public void OnButtonClickVoid() { Debug.Log("OnButtonClick Void"); } [OnButtonClick(value: 2)] public void OnButtonClickInt(int value) { Debug.Log(quot;OnButtonClick ${value}"); } [OnButtonClick(value: true)] public void OnButtonClickBool(bool value) { Debug.Log(quot;OnButtonClick ${value}"); } [OnButtonClick(value: 0.3f)] public void OnButtonClickFloat(float value) { Debug.Log(quot;OnButtonClick ${value}"); } private GameObject ThisGo => this.gameObject; [OnButtonClick(value: nameof(ThisGo), isCallback: true)] public void OnButtonClickComp(UnityEngine.Object value) { Debug.Log(quot;OnButtonClick ${value}"); }
It'll display a UI that where the event is binded
