[Fix] FishNet
This commit is contained in:
@@ -15,12 +15,12 @@ MonoBehaviour:
|
|||||||
_prefabs:
|
_prefabs:
|
||||||
- {fileID: 4512293259955182956, guid: fe2b65b02f0484b41aa8cfa9fbbb0e1d, type: 3}
|
- {fileID: 4512293259955182956, guid: fe2b65b02f0484b41aa8cfa9fbbb0e1d, type: 3}
|
||||||
- {fileID: 4512293259955182956, guid: 35639798ad77fc145871588b25d66259, type: 3}
|
- {fileID: 4512293259955182956, guid: 35639798ad77fc145871588b25d66259, type: 3}
|
||||||
|
- {fileID: 201277550, guid: 26a567abbe21227428f5c3d309d1d73c, type: 3}
|
||||||
- {fileID: 4512293259955182956, guid: 0d6d0f48b03b17f49a6340103cd9b9d0, type: 3}
|
- {fileID: 4512293259955182956, guid: 0d6d0f48b03b17f49a6340103cd9b9d0, type: 3}
|
||||||
- {fileID: 8475222101369129519, guid: 8cf33e8e99a9b0c4c8f29ff725650de6, type: 3}
|
- {fileID: 8475222101369129519, guid: 8cf33e8e99a9b0c4c8f29ff725650de6, type: 3}
|
||||||
- {fileID: 4512293259955182956, guid: dafef736ca1ae384e9a19eb672843563, type: 3}
|
- {fileID: 4512293259955182956, guid: dafef736ca1ae384e9a19eb672843563, type: 3}
|
||||||
- {fileID: 201277550, guid: 5b712878ecece354ba4ffb026c0a221c, type: 3}
|
- {fileID: 201277550, guid: 5b712878ecece354ba4ffb026c0a221c, type: 3}
|
||||||
- {fileID: 4512293259955182956, guid: b8017cef39731ba439c70fecc09488e3, type: 3}
|
- {fileID: 4512293259955182956, guid: b8017cef39731ba439c70fecc09488e3, type: 3}
|
||||||
- {fileID: 201277550, guid: 26a567abbe21227428f5c3d309d1d73c, type: 3}
|
|
||||||
- {fileID: 4512293259955182956, guid: 44611030e61220d42ab7c37ba3c0ea92, type: 3}
|
- {fileID: 4512293259955182956, guid: 44611030e61220d42ab7c37ba3c0ea92, type: 3}
|
||||||
- {fileID: 8192566354860284824, guid: 6331b3542e64a564c81bc39cedf70c8d, type: 3}
|
- {fileID: 8192566354860284824, guid: 6331b3542e64a564c81bc39cedf70c8d, type: 3}
|
||||||
- {fileID: 4512293259955182956, guid: f32d4c19de900e64cb73cedcb8ba6f70, type: 3}
|
- {fileID: 4512293259955182956, guid: f32d4c19de900e64cb73cedcb8ba6f70, type: 3}
|
||||||
|
|||||||
+1
-1
@@ -10,5 +10,5 @@ AssetOrigin:
|
|||||||
productId: 207815
|
productId: 207815
|
||||||
packageName: 'FishNet: Networking Evolved'
|
packageName: 'FishNet: Networking Evolved'
|
||||||
packageVersion: 4.7.1R
|
packageVersion: 4.7.1R
|
||||||
assetPath: Assets/FishNet/Demos/Prediction/Rigidbody/Prefabs/RigidbodyPrediction.prefab
|
assetPath: Assets/FishNet/Demos/Prediction/Rigidbody/Scripts/Prefabs/RigidbodyPrediction.prefab
|
||||||
uploadId: 892096
|
uploadId: 892096
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 785b3b8173586e8429ac05c83e552200
|
guid: 8e4a30af35ccc06478592b32c8f12540
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -1,302 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using FishNet.Managing;
|
|
||||||
using FishNet.Managing.Statistic;
|
|
||||||
using FishNet.Managing.Timing;
|
|
||||||
using FishNet.Transporting;
|
|
||||||
using GameKit.Dependencies.Utilities;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace FishNet.Editing
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Used to resize a window.
|
|
||||||
/// </summary>
|
|
||||||
internal struct WindowResizeData
|
|
||||||
{
|
|
||||||
public readonly Vector2 CursorStartPosition;
|
|
||||||
public readonly Vector2 WindowStartHeight;
|
|
||||||
public readonly bool IsValid;
|
|
||||||
|
|
||||||
public WindowResizeData(Vector2 cursorPosition, Vector2 windowHeight)
|
|
||||||
{
|
|
||||||
CursorStartPosition = cursorPosition;
|
|
||||||
WindowStartHeight = windowHeight;
|
|
||||||
|
|
||||||
IsValid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to store Inbound and Outbound traffic details.
|
|
||||||
/// </summary>
|
|
||||||
public class BidirectionalNetworkTraffic : IResettable
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Received traffic.
|
|
||||||
/// </summary>
|
|
||||||
internal NetworkTraffic InboundTraffic;
|
|
||||||
/// <summary>
|
|
||||||
/// Sent traffic.
|
|
||||||
/// </summary>
|
|
||||||
internal NetworkTraffic OutboundTraffic;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a clone of this class using cache.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public BidirectionalNetworkTraffic CloneUsingCache()
|
|
||||||
{
|
|
||||||
if (InboundTraffic == null)
|
|
||||||
{
|
|
||||||
NetworkManagerExtensions.LogError($"One or more NetworkTraffic values is null. {nameof(BidirectionalNetworkTraffic)} cannot be cloned.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
BidirectionalNetworkTraffic traffic = ResettableObjectCaches<BidirectionalNetworkTraffic>.Retrieve();
|
|
||||||
|
|
||||||
traffic.InboundTraffic = InboundTraffic;
|
|
||||||
traffic.OutboundTraffic = OutboundTraffic;
|
|
||||||
|
|
||||||
return traffic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Re-initializes by calling ResetState, then InitializeState.
|
|
||||||
/// </summary>
|
|
||||||
public void Reinitialize()
|
|
||||||
{
|
|
||||||
ResetState();
|
|
||||||
InitializeState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetState()
|
|
||||||
{
|
|
||||||
ResettableObjectCaches<NetworkTraffic>.StoreAndDefault(ref InboundTraffic);
|
|
||||||
ResettableObjectCaches<NetworkTraffic>.StoreAndDefault(ref OutboundTraffic);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeState()
|
|
||||||
{
|
|
||||||
InboundTraffic = ResettableObjectCaches<NetworkTraffic>.Retrieve();
|
|
||||||
OutboundTraffic = ResettableObjectCaches<NetworkTraffic>.Retrieve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class NetworkTraffic : IResettable
|
|
||||||
{
|
|
||||||
#region Types.
|
|
||||||
/// <summary>
|
|
||||||
/// Information about a single packet.
|
|
||||||
/// </summary>
|
|
||||||
public struct Packet
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Details about the packet, such as method or class name.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>This may be empty.</remarks>
|
|
||||||
public string Details;
|
|
||||||
/// <summary>
|
|
||||||
/// Bytes used.
|
|
||||||
/// </summary>
|
|
||||||
public ulong Bytes;
|
|
||||||
/// <summary>
|
|
||||||
/// Originating GameObject.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>GameObject is used rather than a script reference because we do not want to risk unintentionally holding a script in memory. Unity will automatically clean up GameObjects, so they are safe to reference.</remarks>
|
|
||||||
public GameObject GameObject;
|
|
||||||
public Packet(ulong bytes) : this(details: string.Empty, bytes, gameObject: null) { }
|
|
||||||
public Packet(string details, ulong bytes) : this(details, bytes, gameObject: null) { }
|
|
||||||
public Packet(ulong bytes, GameObject gameObject) : this(details: string.Empty, bytes, gameObject) { }
|
|
||||||
|
|
||||||
public Packet(string details, ulong bytes, GameObject gameObject)
|
|
||||||
{
|
|
||||||
Details = details;
|
|
||||||
Bytes = bytes;
|
|
||||||
GameObject = gameObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Container for multiple Packets of the same type.
|
|
||||||
/// </summary>
|
|
||||||
public class PacketGroup : IResettable
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// PacketId of this metric.
|
|
||||||
/// </summary>
|
|
||||||
public PacketId PacketId { get; private set; } = PacketId.Unset;
|
|
||||||
/// <summary>
|
|
||||||
/// Bytes of all packets using PacketId.
|
|
||||||
/// </summary>
|
|
||||||
public ulong Bytes { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Percent Bytes is when compared against Bytes of other PacketMetrics.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>This can only be completed after all Packet entries for each PacketId are added.</remarks>
|
|
||||||
public float Percent { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// True if PacketId is for unspecified packets.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsUnspecifiedPacketId => PacketId == NetworkTrafficStatistics.UNSPECIFIED_PACKETID;
|
|
||||||
/// <summary>
|
|
||||||
/// Currently added packets.
|
|
||||||
/// </summary>
|
|
||||||
private List<Packet> _packets = new();
|
|
||||||
|
|
||||||
public void Initialize(PacketId packetId)
|
|
||||||
{
|
|
||||||
PacketId = packetId;
|
|
||||||
}
|
|
||||||
// public void Initialize(PacketId packetId, ulong bytes) => Initialize(packetId, details: string.Empty, bytes, gameObject: null);
|
|
||||||
// public void Initialize(PacketId packetId, ulong bytes, GameObject gameObject) => Initialize(packetId, details: string.Empty, bytes, gameObject);
|
|
||||||
// public void Initialize(PacketId packetId, string details, ulong bytes) => Initialize(packetId, details, bytes, gameObject: null);
|
|
||||||
// public void Initialize(PacketId packetId, string details, ulong bytes, GameObject gameObject)
|
|
||||||
// {
|
|
||||||
// PacketId = packetId;
|
|
||||||
//
|
|
||||||
// _packets.Add(new(details, bytes, gameObject));
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds traffic from a specified packetId.
|
|
||||||
/// </summary>
|
|
||||||
public void AddPacket(string details, ulong bytes, GameObject gameObject)
|
|
||||||
{
|
|
||||||
Bytes += bytes;
|
|
||||||
|
|
||||||
_packets.Add(new(details, bytes, gameObject));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets Percent using Bytes against allPacketGroupBytes.
|
|
||||||
/// </summary>
|
|
||||||
public void SetPercent(ulong allPacketGroupBytes)
|
|
||||||
{
|
|
||||||
//Prevent divide by 0.
|
|
||||||
if (Bytes == 0)
|
|
||||||
Percent = 0;
|
|
||||||
else
|
|
||||||
Percent = (float)Bytes / allPacketGroupBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetState()
|
|
||||||
{
|
|
||||||
PacketId = PacketId.Unset;
|
|
||||||
Bytes = 0;
|
|
||||||
Percent = 0f;
|
|
||||||
_packets.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeState() { }
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// PacketGroup for each PacketId processed.
|
|
||||||
/// </summary>
|
|
||||||
private Dictionary<PacketId, PacketGroup> _packetGroups;
|
|
||||||
/// <summary>
|
|
||||||
/// Total bytes for all packets.
|
|
||||||
/// </summary>
|
|
||||||
public ulong Bytes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds traffic from a specified packetId.
|
|
||||||
/// </summary>
|
|
||||||
public void AddPacketIdData(PacketId packetId, string details, ulong bytes, GameObject gameObject) => LAddPacketId(packetId, details, bytes, gameObject);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds traffic from a specified packetId.
|
|
||||||
/// </summary>
|
|
||||||
public void AddSocketData(ulong bytes)
|
|
||||||
{
|
|
||||||
LAddPacketId(NetworkTrafficStatistics.UNSPECIFIED_PACKETID, details: string.Empty, bytes, gameObject: null);
|
|
||||||
Bytes += bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds traffic to a PackerGroup.
|
|
||||||
/// </summary>
|
|
||||||
private void LAddPacketId(PacketId packetId, string details, ulong bytes, GameObject gameObject)
|
|
||||||
{
|
|
||||||
if (!_packetGroups.TryGetValue(packetId, out PacketGroup packetGroup))
|
|
||||||
{
|
|
||||||
packetGroup = ResettableObjectCaches<PacketGroup>.Retrieve();
|
|
||||||
packetGroup.Initialize(packetId);
|
|
||||||
|
|
||||||
_packetGroups[packetId] = packetGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
packetGroup.AddPacket(details, bytes, gameObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Calculates and sets Percentage value on each PacketGroup.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>This should only be called after all PacketGroup entries have been created.</remarks>
|
|
||||||
public void SetPacketGroupPercentages()
|
|
||||||
{
|
|
||||||
//Field would probably get cached at runtime during iteration but let's be certain.
|
|
||||||
ulong bytes = Bytes;
|
|
||||||
|
|
||||||
foreach (PacketGroup pg in _packetGroups.Values)
|
|
||||||
pg.SetPercent(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetState()
|
|
||||||
{
|
|
||||||
Bytes = 0;
|
|
||||||
ResettableT2CollectionCaches<PacketId, PacketGroup>.StoreAndDefault(ref _packetGroups);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeState()
|
|
||||||
{
|
|
||||||
_packetGroups = ResettableT2CollectionCaches<PacketId, PacketGroup>.RetrieveDictionary();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Data for a profiled tick.
|
|
||||||
/// </summary>
|
|
||||||
internal class ProfiledTickData : IResettable
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Tick this is for.
|
|
||||||
/// </summary>
|
|
||||||
public uint Tick;
|
|
||||||
/// <summary>
|
|
||||||
/// Traffic collection for the server.
|
|
||||||
/// </summary>
|
|
||||||
public BidirectionalNetworkTraffic ServerTraffic;
|
|
||||||
/// <summary>
|
|
||||||
/// Traffic collection for the client.
|
|
||||||
/// </summary>
|
|
||||||
public BidirectionalNetworkTraffic ClientTraffic;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes and returns if successful.
|
|
||||||
/// </summary>
|
|
||||||
public bool TryInitialize(uint tick, BidirectionalNetworkTraffic serverTraffic, BidirectionalNetworkTraffic clientTraffic)
|
|
||||||
{
|
|
||||||
Tick = tick;
|
|
||||||
|
|
||||||
ServerTraffic = serverTraffic.CloneUsingCache();
|
|
||||||
ClientTraffic = clientTraffic.CloneUsingCache();
|
|
||||||
|
|
||||||
return ServerTraffic != null && ClientTraffic != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Resets all values and stores to caches as needed.
|
|
||||||
/// </summary>
|
|
||||||
public void ResetState()
|
|
||||||
{
|
|
||||||
Tick = TimeManager.UNSET_TICK;
|
|
||||||
|
|
||||||
ResettableObjectCaches<BidirectionalNetworkTraffic>.StoreAndDefault(ref ServerTraffic);
|
|
||||||
ResettableObjectCaches<BidirectionalNetworkTraffic>.StoreAndDefault(ref ClientTraffic);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeState() { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8e4a30af35ccc06478592b32c8f12540
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
AssetOrigin:
|
|
||||||
serializedVersion: 1
|
|
||||||
productId: 207815
|
|
||||||
packageName: 'FishNet: Networking Evolved'
|
|
||||||
packageVersion: 4.6.22R
|
|
||||||
assetPath: Assets/FishNet/Runtime/Editor/NetworkProfiler/Types.cs
|
|
||||||
uploadId: 866910
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
namespace GameKit.Dependencies.Utilities
|
|
||||||
{
|
|
||||||
public static class Guids
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A buffer convert data and discard.
|
|
||||||
/// </summary>
|
|
||||||
public static byte[] Buffer = new byte[16];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 51b4d6f1925ec014d8e37fc1d8c89c71
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
AssetOrigin:
|
|
||||||
serializedVersion: 1
|
|
||||||
productId: 207815
|
|
||||||
packageName: 'FishNet: Networking Evolved'
|
|
||||||
packageVersion: 4.6.22R
|
|
||||||
assetPath: Assets/FishNet/Runtime/Plugins/GameKit/Dependencies/Utilities/Guids.cs
|
|
||||||
uploadId: 866910
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"com.unity.2d.sprite": "1.0.0",
|
||||||
"com.unity.burst": "1.8.28",
|
"com.unity.burst": "1.8.28",
|
||||||
"com.unity.collab-proxy": "2.11.3",
|
"com.unity.collab-proxy": "2.11.3",
|
||||||
"com.unity.collections": "2.6.2",
|
"com.unity.collections": "2.6.2",
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
"com.unity.modules.jsonserialize": "1.0.0",
|
"com.unity.modules.jsonserialize": "1.0.0",
|
||||||
"com.unity.modules.particlesystem": "1.0.0",
|
"com.unity.modules.particlesystem": "1.0.0",
|
||||||
"com.unity.modules.physics": "1.0.0",
|
"com.unity.modules.physics": "1.0.0",
|
||||||
|
"com.unity.modules.physics2d": "1.0.0",
|
||||||
"com.unity.modules.screencapture": "1.0.0",
|
"com.unity.modules.screencapture": "1.0.0",
|
||||||
"com.unity.modules.subsystems": "1.0.0",
|
"com.unity.modules.subsystems": "1.0.0",
|
||||||
"com.unity.modules.terrain": "1.0.0",
|
"com.unity.modules.terrain": "1.0.0",
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"com.unity.2d.sprite": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "builtin",
|
||||||
|
"dependencies": {}
|
||||||
|
},
|
||||||
"com.unity.burst": {
|
"com.unity.burst": {
|
||||||
"version": "1.8.28",
|
"version": "1.8.28",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
@@ -295,6 +301,12 @@
|
|||||||
"source": "builtin",
|
"source": "builtin",
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
},
|
},
|
||||||
|
"com.unity.modules.physics2d": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "builtin",
|
||||||
|
"dependencies": {}
|
||||||
|
},
|
||||||
"com.unity.modules.screencapture": {
|
"com.unity.modules.screencapture": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user