Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please let [FieldChangeCallback] supports hooking to a callback method #172

Open
JLChnToZ opened this issue Sep 21, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@JLChnToZ
Copy link

As we all know [FieldChangeCallback] is to instruct the U# compiler use specified property setter to handle a field value assigned from external source such as other udons or remote sync. But there's still a scenario that is not allowed, which is U# compiler don't like I directly assigns the value form other U# behaviors. Although we can use public exposed properties as workaround, but what if others want to use udon graphs to assign the value? This workaround makes the entry point not consistent. I even haven't said using properties require a few more udon instructions at least to get/set a value yet (under the hood).

That's why I want to propose extending the [FieldChangeCallback] functionality to let it specify a method. Instead of (rolling back the original value under the hood before hand) setting the value ourselves, this provides the raw input of the callback. We can use it to hook some event listener etc.

[FieldChangeCallback(nameof(OnValueChanged))]
public int someValue;

void OnValueChanged(int oldValue)
{
    Debug.Log($"The value has been changed from {oldValue} to {someValue}!");
}
@JLChnToZ JLChnToZ added the enhancement New feature or request label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant