Accessing and changing events from a common resource file, like described in this video, do not work in Godot 4.2.2, from what I can see.
Does anyone how to make that work?
I had to solve the problem with an alternative solution, by letting UIController.cs (the UI node) have a reference to the Player Character in the main scene).
From both nodes with StatLabel.cs script inside the ui scene, I have a reference to the UIController in the root node of the ui scene.
In the StatLabel, I reference the StatResource like following:
public partial class StatLabel : Label
{
[Export] public Stat statType;
[Export] private UIController uiController;
private StatResource characterStatResource;
public override void _Ready()
{
characterStatResource = uiController.Character.GetStatResource(statType);
characterStatResource.Changed += HandleUpdate;
Text = characterStatResource.StatValue.ToString();
}
public void HandleUpdate()
{
Text = characterStatResource.StatValue.ToString();
}
}