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