mirror of
https://github.com/Kaveinator/NetickProForUnity.git
synced 2025-10-26 01:49:05 -07:00
Added packet loss stats to NetworkInfo and made several other improvements.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
Resources/Network Icons.meta
Normal file
8
Resources/Network Icons.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 782dd34b520f8284cb0814cda8b110c9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Resources/Network Icons/Latency.png
Normal file
BIN
Resources/Network Icons/Latency.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
153
Resources/Network Icons/Latency.png.meta
Normal file
153
Resources/Network Icons/Latency.png.meta
Normal file
@@ -0,0 +1,153 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb6fa20d7adc7b24bbf6fd42a8c1c849
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Resources/Network Icons/PacketLoss.png
Normal file
BIN
Resources/Network Icons/PacketLoss.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
153
Resources/Network Icons/PacketLoss.png.meta
Normal file
153
Resources/Network Icons/PacketLoss.png.meta
Normal file
@@ -0,0 +1,153 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 112899f4f25b21643b5b16572a335708
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Resources/Network Icons/ServerLag.png
Normal file
BIN
Resources/Network Icons/ServerLag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
153
Resources/Network Icons/ServerLag.png.meta
Normal file
153
Resources/Network Icons/ServerLag.png.meta
Normal file
@@ -0,0 +1,153 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe073c3e22414a449a3f4edbd22eb225
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,14 +17,21 @@ namespace Netick.Samples
|
||||
|
||||
public bool AutoStart;
|
||||
public bool AutoConnect;
|
||||
public bool ShowDisconnectButton = true;
|
||||
public bool ShowConnectButton = true;
|
||||
|
||||
[Header("Network")]
|
||||
[Range(0, 65535)]
|
||||
public int Port;
|
||||
public string ServerIPAddress = "127.0.0.1";
|
||||
|
||||
[Header("Headless Server FPS")]
|
||||
public bool Cap = true;
|
||||
public int FPS = 450;
|
||||
|
||||
[Header("UI")]
|
||||
public bool ShowDisconnectButton = true;
|
||||
public bool ShowConnectButton = true;
|
||||
public Vector2 Offset = new Vector2(36, 0);
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
if (Port == 0)
|
||||
@@ -35,6 +42,7 @@ namespace Netick.Samples
|
||||
{
|
||||
if (Application.isBatchMode)
|
||||
{
|
||||
Application.targetFrameRate = FPS;
|
||||
Network.StartAsServer(Transport, Port, SandboxPrefab);
|
||||
}
|
||||
|
||||
@@ -72,24 +80,27 @@ namespace Netick.Samples
|
||||
{
|
||||
if (Sandbox != null && Sandbox.IsClient)
|
||||
{
|
||||
if (!Sandbox.IsVisible)
|
||||
return;
|
||||
|
||||
if (Sandbox.IsConnected)
|
||||
{
|
||||
if (ShowDisconnectButton)
|
||||
{
|
||||
GUI.Label(new Rect(10, 130, 200, 50), $"Connected to {Sandbox.ServerEndPoint}");
|
||||
GUI.Label(new Rect(Offset.x, Offset.y + 170, 200, 50), $"Connected to {Sandbox.ServerEndPoint}");
|
||||
|
||||
if (GUI.Button(new Rect(10, 220, 200, 50), "Disconnect"))
|
||||
if (GUI.Button(new Rect(Offset.x, Offset.y + 220, 200, 50), "Disconnect"))
|
||||
Sandbox.DisconnectFromServer();
|
||||
}
|
||||
|
||||
}
|
||||
else if (ShowConnectButton)
|
||||
{
|
||||
if (GUI.Button(new Rect(10, 10, 200, 50), "Connect"))
|
||||
if (GUI.Button(new Rect(Offset.x, Offset.y + 40, 200, 50), "Connect"))
|
||||
Sandbox.Connect(Port, ServerIPAddress);
|
||||
|
||||
ServerIPAddress = GUI.TextField(new Rect(10, 70, 200, 50), ServerIPAddress);
|
||||
Port = int.Parse(GUI.TextField(new Rect(10, 130, 200, 50), Port.ToString()));
|
||||
ServerIPAddress = GUI.TextField(new Rect(Offset.x, Offset.y + 100, 200, 50), ServerIPAddress);
|
||||
Port = int.Parse(GUI.TextField(new Rect(Offset.x, Offset.y+ 160, 200, 50), Port.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,23 +108,23 @@ namespace Netick.Samples
|
||||
return;
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(10, 10, 200, 50), "Run Host"))
|
||||
if (GUI.Button(new Rect(Offset.x, Offset.y + 40, 200, 50), "Run Host"))
|
||||
{
|
||||
Network.StartAsHost(Transport, Port, SandboxPrefab);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(10, 70, 200, 50), "Run Client"))
|
||||
if (GUI.Button(new Rect(Offset.x, Offset.y + 100, 200, 50), "Run Client"))
|
||||
{
|
||||
var sandbox = Network.StartAsClient(Transport, Port, SandboxPrefab);
|
||||
sandbox.Connect(Port, ServerIPAddress);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(10, 130, 200, 50), "Run Server"))
|
||||
if (GUI.Button(new Rect(Offset.x, Offset.y + 160, 200, 50), "Run Server"))
|
||||
{
|
||||
Network.StartAsServer(Transport, Port, SandboxPrefab);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(10, 190, 200, 50), "Run Host + Client"))
|
||||
if (GUI.Button(new Rect(Offset.x, Offset.y + 220, 200, 50), "Run Host + Client"))
|
||||
{
|
||||
var sandboxes = Network.StartAsMultiplePeers(Transport, Port, SandboxPrefab, StartServerInMultiplePeersMode, true, Clients);
|
||||
|
||||
@@ -124,7 +135,7 @@ namespace Netick.Samples
|
||||
}
|
||||
}
|
||||
|
||||
ServerIPAddress = GUI.TextField(new Rect(10, 250, 200, 50), ServerIPAddress);
|
||||
ServerIPAddress = GUI.TextField(new Rect(Offset.x, Offset.y + 280, 200, 50), ServerIPAddress);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,26 +8,85 @@ namespace Netick.Samples
|
||||
[AddComponentMenu("Netick/Network Info")]
|
||||
public class NetworkInfo : NetworkEventsListener
|
||||
{
|
||||
[Header("Network Stats")]
|
||||
public Vector2 Offset = new Vector2(27, 20);
|
||||
|
||||
[Header("Network Conditions Icons")]
|
||||
public float MediumLatencyThreshold = 150;
|
||||
public float HighLatencyThreshold = 250;
|
||||
public float MediumPacketLossThreshold = 1;
|
||||
public float HighPacketLossThreshold = 10;
|
||||
|
||||
public Vector2 Icon1Offset = new Vector2(-80, 30);
|
||||
public Vector2 Icon2Offset = new Vector2(-80, 70);
|
||||
public Vector2 Icon3Offset = new Vector2(-80, 110);
|
||||
public float IconSize = 30;
|
||||
|
||||
private Texture _packetLossIcon;
|
||||
private Texture _latencyIcon;
|
||||
private Texture _serverLagIcon;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_packetLossIcon = Resources.Load<Texture>("Network Icons/PacketLoss");
|
||||
_latencyIcon = Resources.Load<Texture>("Network Icons/Latency");
|
||||
_serverLagIcon = Resources.Load<Texture>("Network Icons/ServerLag");
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (Network.Instance != null)
|
||||
if (Network.IsRunning)
|
||||
{
|
||||
if (Sandbox != null && Sandbox.IsConnected)
|
||||
{
|
||||
Draw(0, "In", Sandbox.InKBps.ToString(), "KB/s");
|
||||
Draw(1, "Out", Sandbox.OutKBps.ToString(), "KB/s");
|
||||
Draw(2, "RTT", (Sandbox.RTT * 1000f).ToString(), "ms");
|
||||
Draw(3, "Interp Delay", (Sandbox.InterpolationDelay * 1000f).ToString(), "ms");
|
||||
Draw(4, "Resims", Sandbox.Monitor.Resimulations.Average.ToString(), "Ticks");
|
||||
Draw(5, "Delta time", (Time.deltaTime * 1000f).ToString(), "ms");
|
||||
DrawText(0, "RTT", (Sandbox.RTT * 1000f).ToString(), "ms");
|
||||
DrawText(1, "In", Sandbox.InKBps.ToString(), "KB/s");
|
||||
DrawText(2, "Out", Sandbox.OutKBps.ToString(), "KB/s");
|
||||
DrawText(3, "In Loss", (Sandbox.InPacketLoss * 100f).ToString(), "%");
|
||||
DrawText(4, "Out Loss", (Sandbox.OutPacketLoss * 100f).ToString(), "%");
|
||||
DrawText(5, "Interp Delay", (Sandbox.InterpolationDelay * 1000f).ToString(), "ms");
|
||||
DrawText(6, "Resims", Sandbox.Monitor.Resimulations.Average.ToString(), "Ticks");
|
||||
DrawText(7, "Srv Tick Time", (Sandbox.Monitor.ServerTickTime.Max * 1000f).ToString(), "ms");
|
||||
DrawText(8, "Delta time", (Time.deltaTime * 1000f).ToString(), "ms");
|
||||
|
||||
DrawIcons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Draw(int offset, string title, string content, string unit)
|
||||
private void DrawText(int offset, string title, string content, string unit)
|
||||
{
|
||||
GUI.Label(new Rect(10, 10 + (15 * offset), 200, 50), $"{title}: ");
|
||||
GUI.Label(new Rect(130, 10 + (15 * offset), 200, 50), $"{content} {unit}");
|
||||
GUI.Label(new Rect(Offset.x + 10, Offset.y + 10 + (15 * offset), 200, 50), $"{title}: ");
|
||||
GUI.Label(new Rect(Offset.x + 130, Offset.y + 10 + (15 * offset), 200, 50), $"{content} {unit}");
|
||||
}
|
||||
|
||||
public void DrawIcons()
|
||||
{
|
||||
var pktLossIconPos = Icon1Offset + (Screen.width * Vector2.right);
|
||||
var latencyIconPos = Icon2Offset + (Screen.width * Vector2.right);
|
||||
var serverLagIconPos = Icon3Offset + (Screen.width * Vector2.right);
|
||||
|
||||
var pktLoss = Mathf.Max(Sandbox.InPacketLoss, Sandbox.OutPacketLoss) * 100; // multiplying by 100 to convert from a decimal to a percentage.
|
||||
var rtt = Sandbox.RTT * 1000f; // multiplying by 1000 to convert from seconds to milliseconds.
|
||||
|
||||
if (pktLoss >= MediumPacketLossThreshold)
|
||||
{
|
||||
Color color = pktLoss < HighPacketLossThreshold ? Color.yellow : Color.red;
|
||||
GUI.DrawTexture(new Rect(pktLossIconPos, Vector2.one * IconSize), _packetLossIcon, ScaleMode.ScaleToFit, true, 1f, color, 0f, 0f);
|
||||
}
|
||||
|
||||
if (rtt >= MediumLatencyThreshold)
|
||||
{
|
||||
Color color = rtt >= HighLatencyThreshold ? Color.red : Color.yellow;
|
||||
GUI.DrawTexture(new Rect(latencyIconPos, Vector2.one * IconSize), _latencyIcon, ScaleMode.ScaleToFit, true, 1f, color, 0f, 0f);
|
||||
}
|
||||
|
||||
if (Sandbox.Monitor.ServerTickTime.Max >= Sandbox.FixedDeltaTime)
|
||||
{
|
||||
Color color = Sandbox.Monitor.ServerTickTime.Average >= Sandbox.FixedDeltaTime ? Color.red : Color.yellow;
|
||||
GUI.DrawTexture(new Rect(serverLagIconPos, Vector2.one * IconSize), _serverLagIcon, ScaleMode.ScaleToFit, true, 1f, color, 0f, 0f);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.karrar.netick",
|
||||
"version": "0.12.20",
|
||||
"version": "0.12.21",
|
||||
"displayName": "Netick",
|
||||
"description": "A networking solution for Unity",
|
||||
"unity": "2021.3",
|
||||
|
||||
Reference in New Issue
Block a user