FieldChangeCallback execution order

So I was working on my other world and I found this thing called “FieldChangeCallback” Otherwise it did seem to work like how I wanted.

However when I have multiple callbacks, I cant seem to be able to decide the execution order for these callbacks. Like what if I had a callback that is dependent on another callback?

In cases like these I need to control which callback comes first. Cause right now late joiners will get the sprite as null, because they havent gotten the sprite from ItemName callback first, like the rest of the players.

Why don’t you just assign cardImage.sprite in the first callback? Then the execution order matters less.

thats what I tried first, but it didnt help. Cause even so the card sprite was blank for late joiners. Which is why I tried this solution, so if I can somehow control which variables get synced first in late join, then late joiners can get the sprite accordingly

ok I found a solution that works for me, even tho it wasnt part of my original plan. So now I just have the Update give my image the sprite if bool is on. And inside the bool setup I define where the img component is and if it should be enabled or disabled.

But still it could be a big change if people could define the execution order of the udonsynced variables for late joiners.

Is this a card object that always has an image object attached to it?

I am wondering why the GetComponent is not in Startup function. It’s a reference that can be used multiple times.

If you can GetComponent at startup, then you don’t need the ShowItem to run first

Also the Update function runs every frame.

so basically it can be toggled if the image is enabled or not.
and the card itself can be spawned from vrc object pool, meaning that by default is not active.

and I have tried that method at some point even with OnEnable. However it didnt work as I wanted, so Im going with this plan which has no issues at all.

What I’ve done in cases like this is skip the bool entirely and just sync the itemName value and handle showing it in its callback. I’d normally have an array of names as well so I can sync an int instead of a string, but either way works.

If I wanted to hide the image, I’d just set the itemName int to -1 (False) and handle the logic for that in the callback. You could probably just set the name string to some placeholder like “-hidden-” instead.

private int itemName {
    get => _itemName;
    set {
        _itemName = value;
        if (value < 0) {
            HideTheImageFunction();
            return;
        }
        ShowImage(value);
    }
}