Created
October 14, 2025 22:18
-
-
Save Vavassor/c326009ba65a5380c417d10341be9fef to your computer and use it in GitHub Desktop.
VRChat U# Integer Sync Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UdonSharp; | |
| using UnityEngine; | |
| using VRC.SDKBase; | |
| [UdonBehaviourSyncMode(BehaviourSyncMode.Manual)] | |
| public class IntSetting : UdonSharpBehaviour | |
| { | |
| [SerializeField, UdonSynced] private int valueSync; | |
| public void SetValue(int newValue) | |
| { | |
| Networking.SetOwner(Networking.LocalPlayer, gameObject); | |
| valueSync = newValue; | |
| RequestSerialization(); | |
| ApplyValue(); | |
| } | |
| public override void OnDeserialization() | |
| { | |
| ApplyValue(); | |
| } | |
| private void ApplyValue() | |
| { | |
| // React to the value changing here! | |
| // Like if the number were a score, you'd update the scoreboard here. | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment