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
end
end
function Test:NetworkInject()
self.host.interact.networkIB.networkIBState:InjectIntState("value", self.onValueChange)
--inject other function
end
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)
end
end