Skip to content

Instantly share code, notes, and snippets.

@zaneclaes
Last active June 15, 2016 16:53
Show Gist options
  • Save zaneclaes/ec22f752fa1526a10f973166080075fa to your computer and use it in GitHub Desktop.
Save zaneclaes/ec22f752fa1526a10f973166080075fa to your computer and use it in GitHub Desktop.
WorldObjectNetworkObject wno = NetworkManager.Instance.WorldObjectNetworkObject.GetComponent<WorldObjectBehavior> ().networkObject;
// None of these fire:
wno.pendingInitialized += delegate(INetworkBehavior behavior, NetworkObject networkObject) {
Debug.Log ("[GLOBAL] PENDING initialized " + behavior);
};
wno.onReady += delegate {
Debug.Log ("[GLOBAL] onReady");
};
wno.readBinary += delegate(BeardedManStudios.BMSByte data) {
Debug.Log ("[GLOBAL] read:" + data);
};
// This `objectInitialized` fires:
NetworkManager.Instance.objectInitialized += delegate(INetworkBehavior unityGameObject, NetworkObject obj) {
Debug.Log("Initialized.");// And this gets logged...
// But at this point in time, the values stored in the NetworkObject are all default values (i.e., null/empty).
// I'd like to use them to modify the object that is/was initialized.
// None of these fire:
WorldObjectNetworkObject wobj = obj as WorldObjectNetworkObject;
wobj.onReady += delegate {
Debug.Log ("OBJECT READY");
};
wobj.pendingInitialized += delegate(INetworkBehavior behavior, NetworkObject networkObject) {
Debug.Log ("PENDING initialized " + behavior);
};
wobj.readBinary += delegate(BeardedManStudios.BMSByte data) {
Debug.Log ("read:" + data);
};
// Notice that this ALSO never fires, and it's a data-field delegate...
// Even though the server does this when it spawns the object:
// obj.GetComponent<NetworkedWorldObject> ().networkObject.prefabKey = 'b';
wobj.prefabKeyChanged += delegate(char field, ulong timestep) {
Debug.Log ("CHANGE " + field);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment