Skip to content

Commit 4e246ff

Browse files
authored
fix: Compile error when a class with Rpcs inherits from an intermediate base class with no Rpcs. (#2751)
* Fix: Compile error when a class with Rpcs inherits from an intermediate base class with no Rpcs. * Changelog * Same thing, but actually doing it correctly this time. * Avoiding unnecessary formatting changes.
1 parent 53de8a4 commit 4e246ff

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66

77
Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).
88

9+
## [Unreleased]
10+
11+
### Fixed
12+
13+
- Fixed a bug where having a class with Rpcs that inherits from a class without Rpcs that inherits from NetworkVariable would cause a compile error. (#2751)
14+
915
## [1.7.0] - 2023-10-11
1016

1117
### Added

com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,10 @@ private void ProcessNetworkBehaviour(TypeDefinition typeDefinition, string[] ass
12371237
}
12381238
}
12391239

1240-
if (rpcHandlers.Count > 0)
1240+
//if (rpcHandlers.Count > 0)
12411241
{
1242+
1243+
// This always needs to generate even if it's empty.
12421244
var initializeRpcsMethodDef = new MethodDefinition(
12431245
k_NetworkBehaviour___initializeRpcs,
12441246
MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.HideBySig,

com.unity.netcode.gameobjects/Tests/Runtime/RpcTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ namespace Unity.Netcode.RuntimeTests
1212
{
1313
public class RpcTests : NetcodeIntegrationTest
1414
{
15+
public class CompileTimeNoRpcsBaseClassTest : NetworkBehaviour
16+
{
17+
18+
}
19+
20+
public class CompileTimeHasRpcsChildClassDerivedFromNoRpcsBaseClassTest : CompileTimeNoRpcsBaseClassTest
21+
{
22+
[ServerRpc]
23+
public void SomeDummyServerRpc()
24+
{
25+
26+
}
27+
}
28+
1529
public class GenericRpcTestNB<T> : NetworkBehaviour where T : unmanaged
1630
{
1731
public event Action<T, ServerRpcParams> OnServer_Rpc;

0 commit comments

Comments
 (0)