obsolete support instead of modifying original

This commit is contained in:
mischa 2024-06-06 15:28:05 +02:00
parent 21115a3785
commit 3815ec6576
6 changed files with 69 additions and 5 deletions

View File

@ -22,7 +22,7 @@ public enum SyncDirection { ServerToClient, ClientToServer }
// [RequireComponent(typeof(NetworkIdentity))] disabled to allow child NetworkBehaviours // [RequireComponent(typeof(NetworkIdentity))] disabled to allow child NetworkBehaviours
[AddComponentMenu("")] [AddComponentMenu("")]
[HelpURL("https://mirror-networking.gitbook.io/docs/guides/networkbehaviour")] [HelpURL("https://mirror-networking.gitbook.io/docs/guides/networkbehaviour")]
public abstract class NetworkBehaviour : MonoBehaviour public abstract partial class NetworkBehaviour : MonoBehaviour
{ {
/// <summary>Sync direction for OnSerialize. ServerToClient by default. ClientToServer for client authority.</summary> /// <summary>Sync direction for OnSerialize. ServerToClient by default. ClientToServer for client authority.</summary>
[Tooltip("Server Authority calls OnSerialize on the server and syncs it to clients.\n\nClient Authority calls OnSerialize on the owning client, syncs it to server, which then broadcasts it to all other clients.\n\nUse server authority for cheat safety.")] [Tooltip("Server Authority calls OnSerialize on the server and syncs it to clients.\n\nClient Authority calls OnSerialize on the owning client, syncs it to server, which then broadcasts it to all other clients.\n\nUse server authority for cheat safety.")]
@ -1070,7 +1070,7 @@ protected T GetSyncVarNetworkBehaviour<T>(NetworkBehaviourSyncVar syncNetBehavio
{ {
return null; return null;
} }
// ensure componentIndex is in range. // ensure componentIndex is in range.
// show explicit errors if something went wrong, instead of IndexOutOfRangeException. // show explicit errors if something went wrong, instead of IndexOutOfRangeException.
// removing components at runtime isn't allowed, yet this happened in a project so we need to check for it. // removing components at runtime isn't allowed, yet this happened in a project so we need to check for it.

View File

@ -38,7 +38,7 @@ public struct NetworkIdentitySerialization
[DefaultExecutionOrder(-1)] [DefaultExecutionOrder(-1)]
[AddComponentMenu("Network/Network Identity")] [AddComponentMenu("Network/Network Identity")]
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-identity")] [HelpURL("https://mirror-networking.gitbook.io/docs/components/network-identity")]
public sealed class NetworkIdentity : MonoBehaviour public sealed partial class NetworkIdentity : MonoBehaviour
{ {
/// <summary>Returns true if running as a client and this object was spawned by a server.</summary> /// <summary>Returns true if running as a client and this object was spawned by a server.</summary>
// //

View File

@ -1,4 +1,7 @@
using System;
namespace Mirror namespace Mirror
{ {
public interface NetworkMessage {} // OLD NETWORK PROFILER SUPPORT: inherit from old IMessageBase. Later don't inherit from anything.
public interface NetworkMessage : IMessageBase {}
} }

View File

@ -0,0 +1,58 @@
// [Obsolete] path for our old Network Profiler because the new one doesn't work with Unity 2020.
// we can't change NetworkProfiler, but we can restore the old API with [Obsolete] paths.
using System;
using System.Collections.Generic;
using Mirror.RemoteCalls;
namespace Mirror
{
static class NetworkProfiler2020
{
public const string ObsoleteMessage = "Obsolete API is only kept for old Network Profiler and Unity 2020 support.";
}
// OBSOLETE PATH FOR OLD NETWORK PROFILER IN UNITY 2020
[Obsolete(NetworkProfiler2020.ObsoleteMessage)]
public interface IMessageBase{}
[Obsolete(NetworkProfiler2020.ObsoleteMessage)]
public struct SyncEventMessage : NetworkMessage
{
public ushort functionHash;
public uint netId;
}
[Obsolete(NetworkProfiler2020.ObsoleteMessage)]
public struct UpdateVarsMessage : NetworkMessage
{
public uint netId;
}
[Obsolete(NetworkProfiler2020.ObsoleteMessage)]
public abstract partial class NetworkBehaviour
{
public static RemoteCallDelegate GetRpcHandler(int functionHash) =>
RemoteProcedureCalls.GetDelegate((ushort)functionHash);
}
[Obsolete(NetworkProfiler2020.ObsoleteMessage)]
public sealed partial class NetworkIdentity
{
public static Dictionary<uint, NetworkIdentity> spawned
{
get
{
// server / host mode: use the one from server.
// host mode has access to all spawned.
if (NetworkServer.active)
return NetworkServer.spawned;
// client
if (NetworkClient.active)
return NetworkClient.spawned;
return null;
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a5684027f2ad43b9863abe03e630bc71
timeCreated: 1717679756

View File

@ -210,7 +210,7 @@ private GameObject GetSceneObject(ulong sceneId)
} }
} }
private GameObject GetPrefab(Guid assetId) private GameObject GetPrefab(uint assetId)
{ {
var networkManager = NetworkManager.singleton; var networkManager = NetworkManager.singleton;