wrong property value after button clicked

hello!
this is my code:

using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class MyClass : MonoBehaviour
{
    [SerializeField] private int value1;
    [SerializeField] private int value2;
    [SerializeField] private int value3;
   

    void MyFunction()
    {
        value1 = 10;
        value2 = 20;
        value3 = 30;
    }

    public void CallButtonClicked()
    {
        Debug.Log($"{value1} {value2} {value3}");
    }
}

the event CallButtonClicked is selected in the OnClick list of the button: choosing the gameobject where myclass is attached and choosing the function…

if I call MyFunction and the values take the 10, 20, 30, when I press the button, the values are 0…

I found a workaround using the listener by code… but is not a good stuff… any ideas?
thank you

Hello, I moved your post to the UGUI Forum since it’s not using UI Toolkit (where you originally posted it).

You should check the values on the Inspector inside Unity for the values of value1, value2 and value3, those are the values that will appear when you click the button. Also in this code there’s no explicit call to MyFunction(), so make sure you’re actually calling it.

thank you Julia!
the MyFunction is only for information: the values shown in editor are 10, 20, 30, and the debug.log write me 0 0 0