The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.0.0-pre.4] - 2021-01-04 ### Added - Added `com.unity.modules.physics` and `com.unity.modules.physics2d` package dependencies (#1565) ### Removed - Removed `com.unity.modules.ai` package dependency (#1565) - Removed `FixedQueue`, `StreamExtensions`, `TypeExtensions` (#1398) ### Fixed - Fixed in-scene NetworkObjects that are moved into the DDOL scene not getting restored to their original active state (enabled/disabled) after a full scene transition (#1354) - Fixed invalid IL code being generated when using `this` instead of `this ref` for the FastBufferReader/FastBufferWriter parameter of an extension method. (#1393) - Fixed an issue where if you are running as a server (not host) the LoadEventCompleted and UnloadEventCompleted events would fire early by the NetworkSceneManager (#1379) - Fixed a runtime error when sending an array of an INetworkSerializable type that's implemented as a struct (#1402) - NetworkConfig will no longer throw an OverflowException in GetConfig() when ForceSamePrefabs is enabled and the number of prefabs causes the config blob size to exceed 1300 bytes. (#1385) - Fixed NetworkVariable not calling NetworkSerialize on INetworkSerializable types (#1383) - Fixed NullReferenceException on ImportReferences call in NetworkBehaviourILPP (#1434) - Fixed NetworkObjects not being despawned before they are destroyed during shutdown for client, host, and server instances. (#1390) - Fixed KeyNotFound exception when removing ownership of a newly spawned NetworkObject that is already owned by the server. (#1500) - Fixed NetworkManager.LocalClient not being set when starting as a host. (#1511) - Fixed a few memory leak cases when shutting down NetworkManager during Incoming Message Queue processing. (#1323) ### Changed - The SDK no longer limits message size to 64k. (The transport may still impose its own limits, but the SDK no longer does.) (#1384) - Updated com.unity.collections to 1.1.0 (#1451)
146 lines
5.1 KiB
C#
146 lines
5.1 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Mono.Cecil;
|
|
using Mono.Cecil.Cil;
|
|
using Unity.CompilationPipeline.Common.Diagnostics;
|
|
using Unity.CompilationPipeline.Common.ILPostProcessing;
|
|
using ILPPInterface = Unity.CompilationPipeline.Common.ILPostProcessing.ILPostProcessor;
|
|
|
|
namespace Unity.Netcode.Editor.CodeGen
|
|
{
|
|
internal sealed class RuntimeAccessModifiersILPP : ILPPInterface
|
|
{
|
|
public override ILPPInterface GetInstance() => this;
|
|
|
|
public override bool WillProcess(ICompiledAssembly compiledAssembly) => compiledAssembly.Name == CodeGenHelpers.RuntimeAssemblyName;
|
|
|
|
private readonly List<DiagnosticMessage> m_Diagnostics = new List<DiagnosticMessage>();
|
|
|
|
public override ILPostProcessResult Process(ICompiledAssembly compiledAssembly)
|
|
{
|
|
if (!WillProcess(compiledAssembly))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
m_Diagnostics.Clear();
|
|
|
|
// read
|
|
var assemblyDefinition = CodeGenHelpers.AssemblyDefinitionFor(compiledAssembly, out var unused);
|
|
if (assemblyDefinition == null)
|
|
{
|
|
m_Diagnostics.AddError($"Cannot read Netcode Runtime assembly definition: {compiledAssembly.Name}");
|
|
return null;
|
|
}
|
|
|
|
// process
|
|
var mainModule = assemblyDefinition.MainModule;
|
|
if (mainModule != null)
|
|
{
|
|
foreach (var typeDefinition in mainModule.Types)
|
|
{
|
|
if (!typeDefinition.IsClass)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
switch (typeDefinition.Name)
|
|
{
|
|
case nameof(NetworkManager):
|
|
ProcessNetworkManager(typeDefinition, compiledAssembly.Defines);
|
|
break;
|
|
case nameof(NetworkBehaviour):
|
|
ProcessNetworkBehaviour(typeDefinition);
|
|
break;
|
|
case nameof(NetworkVariableHelper):
|
|
ProcessNetworkVariableHelper(typeDefinition);
|
|
break;
|
|
case nameof(__RpcParams):
|
|
typeDefinition.IsPublic = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_Diagnostics.AddError($"Cannot get main module from Netcode Runtime assembly definition: {compiledAssembly.Name}");
|
|
}
|
|
|
|
// write
|
|
var pe = new MemoryStream();
|
|
var pdb = new MemoryStream();
|
|
|
|
var writerParameters = new WriterParameters
|
|
{
|
|
SymbolWriterProvider = new PortablePdbWriterProvider(),
|
|
SymbolStream = pdb,
|
|
WriteSymbols = true
|
|
};
|
|
|
|
assemblyDefinition.Write(pe, writerParameters);
|
|
|
|
return new ILPostProcessResult(new InMemoryAssembly(pe.ToArray(), pdb.ToArray()), m_Diagnostics);
|
|
}
|
|
|
|
private void ProcessNetworkManager(TypeDefinition typeDefinition, string[] assemblyDefines)
|
|
{
|
|
foreach (var fieldDefinition in typeDefinition.Fields)
|
|
{
|
|
if (fieldDefinition.Name == nameof(NetworkManager.__rpc_func_table))
|
|
{
|
|
fieldDefinition.IsPublic = true;
|
|
}
|
|
|
|
if (fieldDefinition.Name == nameof(NetworkManager.RpcReceiveHandler))
|
|
{
|
|
fieldDefinition.IsPublic = true;
|
|
}
|
|
|
|
if (fieldDefinition.Name == nameof(NetworkManager.__rpc_name_table))
|
|
{
|
|
fieldDefinition.IsPublic = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ProcessNetworkVariableHelper(TypeDefinition typeDefinition)
|
|
{
|
|
foreach (var methodDefinition in typeDefinition.Methods)
|
|
{
|
|
if (methodDefinition.Name == nameof(NetworkVariableHelper.InitializeDelegates))
|
|
{
|
|
methodDefinition.IsPublic = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ProcessNetworkBehaviour(TypeDefinition typeDefinition)
|
|
{
|
|
foreach (var nestedType in typeDefinition.NestedTypes)
|
|
{
|
|
if (nestedType.Name == nameof(NetworkBehaviour.__RpcExecStage))
|
|
{
|
|
nestedType.IsNestedFamily = true;
|
|
}
|
|
}
|
|
|
|
foreach (var fieldDefinition in typeDefinition.Fields)
|
|
{
|
|
if (fieldDefinition.Name == nameof(NetworkBehaviour.__rpc_exec_stage))
|
|
{
|
|
fieldDefinition.IsFamily = true;
|
|
}
|
|
}
|
|
|
|
foreach (var methodDefinition in typeDefinition.Methods)
|
|
{
|
|
if (methodDefinition.Name == nameof(NetworkBehaviour.__sendServerRpc)
|
|
|| methodDefinition.Name == nameof(NetworkBehaviour.__sendClientRpc))
|
|
{
|
|
methodDefinition.IsFamily = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|