Skip to content

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

@JLChnToZ

Description

@JLChnToZ

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}!");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions