/// <summary> /// Handle additional <see cref="UpdateMessage"/> data. /// </summary> /// <param name="obj"></param> /// <param name="msg"></param> /// <param name="packet"></param> /// <param name="reader"></param> /// <returns></returns> protected override Error PostHandleMessage(GameObject obj, UpdateMessage msg, PacketBuffer packet, BinaryReader reader) { TextMesh textMesh = obj.GetComponent <TextMesh>(); ShapeComponent shapeComp = obj.GetComponent <ShapeComponent>(); if (textMesh != null && shapeComp != null) { textMesh.fontSize = (int)msg.Attributes.ScaleZ; textMesh.color = shapeComp.Colour; } // Convert position to Unity position. obj.transform.localPosition = FrameTransform.RemoteToUnity(obj.transform.localPosition, ServerInfo.CoordinateFrame); if (shapeComp != null && (msg.Flags & (ushort)Text3DFlag.SceenFacing) != (shapeComp.ObjectFlags & (ushort)Text3DFlag.SceenFacing)) { // Screen facing flag changed. if ((msg.Flags & (ushort)Text3DFlag.SceenFacing) != 0) { // Need to use -forward for text. ScreenFacing.AddToManager(obj, -Vector3.forward, Vector3.up); } else { // Need to use -forward for text. ScreenFacing.RemoveFromManager(obj); } } return(new Error()); }
/// <summary> /// Handle additional <see cref="CreateMessage"/> data. /// </summary> /// <param name="obj"></param> /// <param name="msg"></param> /// <param name="packet"></param> /// <param name="reader"></param> /// <returns></returns> protected override Error PostHandleMessage(GameObject obj, CreateMessage msg, PacketBuffer packet, BinaryReader reader) { // Convert position to Unity position. obj.transform.localPosition = FrameTransform.RemoteToUnity(obj.transform.localPosition, ServerInfo.CoordinateFrame); // Read the text in the buffer. int textLength = reader.ReadUInt16(); if (textLength > 0) { TextMesh textMesh = obj.GetComponent <TextMesh>(); if (textMesh == null) { textMesh = obj.AddComponent <TextMesh>(); } byte[] textBytes = reader.ReadBytes(textLength); textMesh.text = System.Text.Encoding.UTF8.GetString(textBytes); ShapeComponent shapeComp = obj.GetComponent <ShapeComponent>(); if (shapeComp != null) { textMesh.fontSize = (int)msg.Attributes.ScaleZ; textMesh.color = shapeComp.Colour; } } if ((msg.Flags & (ushort)Text3DFlag.SceenFacing) != 0) { // Need to use -forward for text. ScreenFacing.AddToManager(obj, -Vector3.forward, Vector3.up); } return(base.PostHandleMessage(obj, msg, packet, reader)); }