MacacaViewSystem icon indicating copy to clipboard operation
MacacaViewSystem copied to clipboard

cannot get references in OverrideButtonEvent function

Open NOVIO60229 opened this issue 5 months ago • 0 comments

Hi, I have a function which will modify text of a TMP_Text on the scene. I want to print log on my TMP_Text after I press the button. Here is my code

[SerializeField]
TMP_Text logText;

[OverrideButtonEvent("Content/CustomEventButton")]
void CustomOverrideFunction(Component component )
{
    var log = "trigger CustomOverrideFunction, this on click event is override via script";
    logText.text = log;
    Debug.Log(log);
}

The output would be exception since logText is null. Seems it cannot get any reference in same class in a function with OverrideButtonEvent.

NOVIO60229 avatar Sep 10 '24 10:09 NOVIO60229