When Using UGUI Button _ OnClick(), Why i can't find the function which has more than one parameters.

Hello, I’m Beginners in Unity. Thank you a lot for reading my Questions.

Why i cant’t find the fucnction which gets more than one parameters in inspector?
(UGUI - Button-Onclick())

(no parameter, 1 parameter - each find, works well)
(2,3,4… parameters - Can’t find in OnClick() Inspector)

Here’s Code(Not that Long)using UnityEngine;

using System.Collections;
using UnityEngine.UI;

public class ButtonCtrl : MonoBehaviour {

public Text ShowingText;

// Can Find in Onclick() Inspector 
public void GetButtonName(Button bt)
{ ShowingText.text = bt.name;}

// Can Find in Onclick() Inspector 
public void GetRectTransfomr(RectTransform rt)
{ Debug.Log(rt.position); }

// NOTE !! Can't Find in Onclick() Inspector 
public void GetButtonNameNRectTransfomr(Button bt, RectTransform rt)
{ ShowingText.text = bt.name;
  Debug.Log(rt.position); }

}

===========
Is there any reasons to prevent using more than 1 parameter fuctions in UGUI BUTTON?

Have a nice Day :slight_smile:

Tutorial for UI buttons: “Custom functions need to be public, void and have one or no parameters …”

I don’t know the reason for this.

You could try to add the function programatically:

button.OnClick.AddEventListener(() => yourFunction());

where button is of type UnityEngine.UI.Button.