How to make text appear for all players

Hi everyone!
So i want for my players to see when joined the state of an interaction which displays text, but currently it only works on local. What else i would need to be able to do, in order to make it network friendly?

As I understand it i need to be constantly updating the variables in the Update function with their own get variable, and then ondeserealization set those variables, am i correct?

That’s pretty much correct, but it shouldn’t have to be constantly updating. Just when it’s changed, or a new player joins to my understanding.

Here is a UdonSharp example (untested)

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using UnityEngine.UI;

public class TEST_UpdateTextBox : UdonSharpBehaviour{

    public Text TheTextBox;//the text box you want to display the text in

    [UdonSynced] string TextToDisplay;

    private void Start() {
        UpdateTextBox("Hello World");
    }

    public void UpdateTextBox(string Text) {
        TextToDisplay = Text;
        RequestSerialization();//this update the veriable for everyone
        OnDeserialization();//this might not be necessary, but I'm calling it because I'm not certain if it runs for yourself when you request serialization, or for just remote players
    }
    public override void OnDeserialization() {//this runs when the remote player receives the new veriable after you request serialization
        TheTextBox.text = TextToDisplay;
    }
    public override void OnPlayerJoined(VRCPlayerApi player) { //when a player joins late this will run to sync the variable so they see it too
        RequestSerialization();
    }
}



This is what i have so far, I implemented the Onjoined request serialization, but it doesn’t work :confused:

If other players are changing the text on the object (not just viewing the displayed output) you will need to set them as the owner of the object the udon behavior is on.

My understanding is that only the object owner can change synced variables.

Here is an altered example.

public class TEST_UpdateTextBox : UdonSharpBehaviour{

    public Text TheTextBox;//the text box you want to display the text in

    [UdonSynced] string TextToDisplay;

    public override void Interact() {
        if (!Networking.IsOwner(Networking.LocalPlayer, gameObject)) { Networking.SetOwner(Networking.LocalPlayer, gameObject); } //sets the player to owner if they are not the owner
        UpdateTextBox(Networking.LocalPlayer.displayName);
    }
    public void UpdateTextBox(string Text) {
        TextToDisplay = Text;
        RequestSerialization();//this update the veriable for everyone
        OnDeserialization();//this might not be necessary, but I'm calling it because I'm not certain if it runs for yourself when you request serialization, or for just remote players
    }
    public override void OnDeserialization() {//this runs when the remote player receives the new veriable after you request serialization
        TheTextBox.text = TextToDisplay;
    }
    public override void OnPlayerJoined(VRCPlayerApi player) { //when a player joins late this will run to sync the variable so they see it too
        RequestSerialization();
    }
}