NetworkState - state synchronization
We can use NetworkState for data synchronization, which currently only supports server synchronization of data to all clients.
Similarly, complete the function and register
function Test:Awake() --The client updates the value upon receipt. self.onValueChange = function(value) self.value = value endend
function Test:NetworkInject() self.host.interact.networkIB.networkIBState:InjectIntState("value", self.onValueChange) --inject other functionend
The server updates the value using SetIntStateValue
(Please read NetworkIBStateX
for more interfaces).
function Test:ServerUpdateValue() if CL.Network.VRNetworkManager.ServerOnline then self.host.interact.networkIB.networkIBState:SetVec3StateValue("value", self.value) endend