I am using messages, with child messages that contains additional bits of payload data in addition to the parent payload data. However, it does not seem that messages can handle a data payload split between parent and child. It does not throw errors, but the data does not get sent correctly. My debug log reads this as being sent/recieved MsgOut: KeyAudioClipIndex = 2 and Vec3=(2.4, 0.0, 1.1) MsgIn: KeyAudioClipIndex = 0 and Vec3=(2.4, 0.0, 1.1) ***The short data is lost (sent as a value of 2, but received as a value of 0), but the Vec3 is sent. However if I put all data in the child message class, then it works fine. (Both the short and vec3 are sent correctly) MsgOut: KeyAudioClipIndex = 2 and Vec3=(2.4, 0.0, 1.1) MsgIn: KeyAudioClipIndex = 2 and Vec3=(2.4, 0.0, 1.1) ***The short data is sent correctly (sent value of 2, received a value of 2) This code causes issues with message data loss. Code (csharp): public abstract class MessagePlayAudioEffect : MessageBase { public short keyAudioClipIndex; //msgData, index of the KeyAudioClip being played } public class MessagePlayAudioEffect3D : MessagePlayAudioEffect { public Vector3 vector3; //msgData, position of effect } This code works properly Code (csharp): public abstract class MessagePlayAudioEffect : MessageBase { } public class MessagePlayAudioEffect3D : MessagePlayAudioEffect { public short keyAudioClipIndex; //msgData, index of the KeyAudioClip being played public Vector3 vector3; //msgData, position of effect } Is message inheritance not supported, or bugged? Anybody else having this issue? As a work-around I can just copy and paste all fields into all message classes and not use inheritance. But this is very bad practice... you should never copy & paste code in multiple locations!!! Thanks in advance.
Hi Zullar I ran into the same issue. I've researched and tried different ways. The only reliable way I found to get it working is by overriding the default Serialize() and Deserialize() implementations and call their base, like so: Code (CSharp): using UnityEngine; using UnityEngine.Networking; public abstract class MessagePlayAudioEffect : MessageBase { public short keyAudioClipIndex; //msgData, index of the KeyAudioClip being played public override void Deserialize (NetworkReader reader) { base.Deserialize (reader); this.keyAudioClipIndex = reader.ReadInt16(); } public override void Serialize (NetworkWriter writer) { base.Serialize (writer); writer.Write(this.keyAudioClipIndex); } } public class MessagePlayAudioEffect3D : MessagePlayAudioEffect { public Vector3 vector3; //msgData, position of effect public override void Deserialize (NetworkReader reader) { base.Deserialize (reader); this.vector3 = reader.ReadVector3(); } public override void Serialize (NetworkWriter writer) { base.Serialize (writer); writer.Write(this.vector3); } } You can see in the Documentation that, should you not provide your own overrides, Unity will in fact auto-generate default ones. I'm not sure if it's an oversight or if there's some possible problems related to auto-generating that, but the Unity-generated code does not call into base.Serialize() and base.Deserialize() sadly. This causes a bit of boilerplate code, but at least you also get more control over serialization as a benefit, and it keeps your Message hierarchy intact. Hope this helps!