using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; namespace Networking { public static class ExtensionMethods { public static bool TryRead(this NetworkMessage msg, out T outMsg) where T : MessageBase, new() { try { outMsg = msg.ReadMessage(); return true; } catch { outMsg = default(T); return false; } } public static T TryRead(this NetworkMessage msg) where T : MessageBase, new() { T retval; if (msg.TryRead(out retval)) return retval; return null; } } }