Return 2 FLOAT from 1 VOID

i have to make a button on the new UI of unity,
to semplify my work i want to set 2 float directly from the buttons in the editor.
usually i use something like this:

public float ExampleToSet;

public void Example (float ExampleFloat)
 ExampleToSet = ExampleFloat;

and i set ExampleFloat from a field in the editor,
but if i try to wrote something like this:

    public float ExampleToSet;
    public void Example (float ExampleFloat1, float ExampleFloat2)
     ExampleToSet = ExampleFloat1 + ExampleFloat2;

in the button editor [on click()] i can’t set Example as a function.

any help?
thanks in advance

  1. You are talking about passing parameters, not return types.

  2. Add the desired function as a Listener via script. Only one parameter is possible, but you can circumvent this by using a custom class instance as the parameter, which in turn may contain as many variables as you wish.

    public Button button;
    public float float1;
    public float float2;
    public float exampleToSet;
    void Start() {
         ButtonParameter buttonParameter = new ButtonParameter (float1, float2);
         button.onClick.AddListener(delegate { Example (buttonParameter ); });
    public void Example (ButtonParameter buttonParameter ) {
           exampleToSet = buttonParameter.exampleFloat1 + buttonParameter.exampleFloat2;
    public class ButtonParameter {
         public float exampleFloat1;
         public float exampleFloat2;
         public ButtonParameter() {}
          public ButtonParameter(float f1, float f2) {
             exampleFloat1 = f1;
             exampleFloat2 = f2;