You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
783 B

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;
}
}
}