Skip to content

Commit

Permalink
fix: fixing return RPC not generating serialize functions
Browse files Browse the repository at this point in the history
if only using a type in a UniTask<MyType> RpcMyRpc(), a serialize functions for MyType will now be generated. previous this would give runtime error because no writer for MyType found.
  • Loading branch information
James-Frowen committed Apr 19, 2024
1 parent 2dc5df2 commit 3d162b8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Assets/Mirage/Weaver/Processors/RpcProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,15 @@ protected ReturnType ValidateReturnType(MethodDefinition md, RemoteCallType call
// UniTask is allowed
var unitaskType = typeof(UniTask<int>).GetGenericTypeDefinition();
if (returnType.Is(unitaskType))
{
var genericReturnType = (GenericInstanceType)returnType;
var genericArg = genericReturnType.GenericArguments[0];
// ensure serialize functions exist
_ = writers.GetFunction_Throws(genericArg);
_ = readers.GetFunction_Throws(genericArg);

return ReturnType.UniTask;
}

throw new RpcException($"Use UniTask<{md.ReturnType}> to return values from [ClientRpc] or [ServerRpc]", md);
}
Expand Down

0 comments on commit 3d162b8

Please sign in to comment.