This commit is contained in:
2025-06-16 15:14:23 +02:00
commit 074e590073
3174 changed files with 428263 additions and 0 deletions

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 StinkySteak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 449c20116b4724976879aadb9b214c25
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/LICENSE.md
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f29a212f88aa64554ace6bf12e0a6349
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8d1a99d840d22d84c9531fc200edf547
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b345aa8c625f48c42b128a3818160fa1, type: 3}
m_Name: DefaultBehaviourConfig
m_EditorClassIdentifier:
_moveBehaviour:
SinYMove:
_minSpeed: 0.5
_maxSpeed: 1
_minAmplitude: 0.5
_maxAmplitude: 1
_positionMaxRandom: 100
SinAllAxisMove:
_minSpeed: 0.5
_maxSpeed: 1
_amplitude: 50
WanderMove:
_circleRadius: 35
_turnChance: 0.05
_maxRadius: 2000
_mass: 15
_maxSpeed: 3
_maxForce: 15
_maxSpawnPositionRadius: 100

View File

@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: c840c2115726fe44a9fea3d815aa2a44
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Config/DefaultBehaviourConfig.asset
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 402a222d39bcec04c9a4a579f7f34d00
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 6e6b75e5db829b54ba9287ce8d21b551
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Prefabs/BaseGUIGame.prefab
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6298f96b397ee4445b27e31637dd916b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,45 @@
using UnityEngine;
namespace StinkySteak.NetcodeBenchmark
{
[CreateAssetMenu(fileName = nameof(BehaviourConfig), menuName = "Netcode Benchmark/Behaviour Config")]
public class BehaviourConfig : ScriptableObject
{
[SerializeField] private MoveBehaviour _moveBehaviour;
[System.Serializable]
public struct MoveBehaviour
{
public SinMoveYWrapper SinYMove;
public SinRandomMoveWrapper SinAllAxisMove;
public WanderMoveWrapper WanderMove;
public void CreateDefault()
{
SinYMove = SinMoveYWrapper.CreateDefault();
SinAllAxisMove = SinRandomMoveWrapper.CreateDefault();
WanderMove = WanderMoveWrapper.CreateDefault();
}
}
private void Reset()
{
_moveBehaviour.CreateDefault();
}
public void ApplyConfig(ref SinMoveYWrapper wrapper)
{
wrapper = _moveBehaviour.SinYMove;
}
public void ApplyConfig(ref SinRandomMoveWrapper wrapper)
{
wrapper = _moveBehaviour.SinAllAxisMove;
}
public void ApplyConfig(ref WanderMoveWrapper wrapper)
{
wrapper = _moveBehaviour.WanderMove;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b345aa8c625f48c42b128a3818160fa1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Scripts/BehaviourConfig.cs
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6dc3396f4b66601449c872b2527234f7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
using UnityEngine;
namespace StinkySteak.NetcodeBenchmark
{
public interface IMoveWrapper
{
void NetworkStart(Transform transform);
void NetworkUpdate(Transform transform);
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 62941d180260d4743b36d0b3214ca3b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Scripts/BehaviourWrapper/IMoveWrapper.cs
uploadId: 736421

View File

@ -0,0 +1,45 @@
using UnityEngine;
namespace StinkySteak.NetcodeBenchmark
{
[System.Serializable]
public struct SinMoveYWrapper : IMoveWrapper
{
[SerializeField] private float _minSpeed;
[SerializeField] private float _maxSpeed;
[SerializeField] private float _minAmplitude;
[SerializeField] private float _maxAmplitude;
[SerializeField] private float _positionMaxRandom;
private Vector3 _initialPosition;
private float _speed;
private float _amplitude;
public static SinMoveYWrapper CreateDefault()
{
SinMoveYWrapper wrapper = new SinMoveYWrapper();
wrapper._minSpeed = 0.5f;
wrapper._maxSpeed = 1f;
wrapper._minAmplitude = 0.5f;
wrapper._maxAmplitude = 1f;
wrapper._positionMaxRandom = 5f;
return wrapper;
}
public void NetworkStart(Transform transform)
{
_speed = Random.Range(_minSpeed, _maxSpeed);
_amplitude = Random.Range(_minAmplitude, _maxAmplitude);
_initialPosition = RandomVector3.Get(_positionMaxRandom);
}
public void NetworkUpdate(Transform transform)
{
float sin = Mathf.Sin(Time.time * _speed) * _amplitude;
transform.position = _initialPosition + (Vector3.up * sin);
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2a8c50aebdfe1ad42bfa887f78c8892f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Scripts/BehaviourWrapper/SinMoveYWrapper.cs
uploadId: 736421

View File

@ -0,0 +1,40 @@
using UnityEngine;
namespace StinkySteak.NetcodeBenchmark
{
[System.Serializable]
public struct SinRandomMoveWrapper : IMoveWrapper
{
[SerializeField] private float _minSpeed;
[SerializeField] private float _maxSpeed;
[SerializeField] private float _amplitude;
private Vector3 _targetPosition;
private Vector3 _initialPosition;
private float _speed;
public static SinRandomMoveWrapper CreateDefault()
{
SinRandomMoveWrapper wrapper = new SinRandomMoveWrapper();
wrapper._minSpeed = 1f;
wrapper._maxSpeed = 1f;
wrapper._amplitude = 1f;
return wrapper;
}
public void NetworkStart(Transform transform)
{
_speed = Random.Range(_minSpeed, _maxSpeed);
_targetPosition = RandomVector3.Get(1f);
}
public void NetworkUpdate(Transform transform)
{
float sin = Mathf.Sin(Time.time * _speed) * _amplitude;
transform.position = _initialPosition + (_targetPosition * sin);
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3584eba3ddc985c409f283d204fea105
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Scripts/BehaviourWrapper/SinRandomMoveWrapper.cs
uploadId: 736421

View File

@ -0,0 +1,86 @@
using UnityEngine;
namespace StinkySteak.NetcodeBenchmark
{
[System.Serializable]
public struct WanderMoveWrapper : IMoveWrapper
{
[SerializeField] private float _circleRadius;
[SerializeField] private float _turnChance;
[SerializeField] private float _maxRadius;
[SerializeField] private float _mass;
[SerializeField] private float _maxSpeed;
[SerializeField] private float _maxForce;
[SerializeField] private float _maxSpawnPositionRadius;
private Vector3 _velocity;
private Vector3 _wanderForce;
private Vector3 _target;
public static WanderMoveWrapper CreateDefault()
{
WanderMoveWrapper data = new WanderMoveWrapper();
data._circleRadius = 1;
data._turnChance = 0.05f;
data._maxRadius = 5;
data._mass = 15;
data._maxSpeed = 3;
data._maxForce = 15;
return data;
}
public void NetworkStart(Transform transform)
{
_velocity = Random.onUnitSphere;
_wanderForce = GetRandomWanderForce();
transform.position = RandomVector3.Get(_maxSpawnPositionRadius);
}
public void NetworkUpdate(Transform transform)
{
var desiredVelocity = GetWanderForce(transform);
desiredVelocity = desiredVelocity.normalized * _maxSpeed;
var steeringForce = desiredVelocity - _velocity;
steeringForce = Vector3.ClampMagnitude(steeringForce, _maxForce);
steeringForce /= _mass;
_velocity = Vector3.ClampMagnitude(_velocity + steeringForce, _maxSpeed);
transform.position += _velocity * Time.deltaTime;
transform.forward = _velocity.normalized;
Debug.DrawRay(transform.position, _velocity.normalized * 2, Color.green);
Debug.DrawRay(transform.position, desiredVelocity.normalized * 2, Color.magenta);
}
private Vector3 GetWanderForce(Transform transform)
{
if (transform.position.magnitude > _maxRadius)
{
var directionToCenter = (_target - transform.position).normalized;
_wanderForce = _velocity.normalized + directionToCenter;
}
else if (Random.value < _turnChance)
{
_wanderForce = GetRandomWanderForce();
}
return _wanderForce;
}
private Vector3 GetRandomWanderForce()
{
var circleCenter = _velocity.normalized;
var randomPoint = Random.insideUnitCircle;
var displacement = new Vector3(randomPoint.x, randomPoint.y) * _circleRadius;
displacement = Quaternion.LookRotation(_velocity) * displacement;
var wanderForce = circleCenter + displacement;
return wanderForce;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 5e236bbe49894bf4f972fe81f2081c8a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Scripts/BehaviourWrapper/WanderMoveWrapper.cs
uploadId: 736421

View File

@ -0,0 +1,16 @@
using UnityEngine;
namespace StinkySteak.NetcodeBenchmark
{
public static class RandomVector3
{
public static Vector3 Get(float max)
{
float x = Random.Range(-max, max);
float y = Random.Range(-max, max);
float z = Random.Range(-max, max);
return new Vector3(x, y, z);
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 17d9458a0ed386d4281f9c5085b42118
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Scripts/RandomVector3.cs
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ae950d5124e344a46a2f1aa4dc532bc8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,94 @@
// using TMPro; // MIRROR CHANGE
using UnityEngine;
using UnityEngine.UI;
namespace StinkySteak.NetcodeBenchmark
{
public class BaseGUIGame : MonoBehaviour
{
// [SerializeField] private Button _buttonStartServer; // MIRROR CHANGE: Canvas + TextMeshPro -> OnGUI
// [SerializeField] private Button _buttonStartClient; // MIRROR CHANGE: Canvas + TextMeshPro -> OnGUI
[Space]
// MIRROR CHANGE
protected string _textLatency = ""; // [SerializeField] protected TextMesh _textLatency; // MIRROR CHANGE: Canvas + TextMeshPro -> OnGUI
[SerializeField] private float _updateLatencyTextInterval = 1f;
private SimulationTimer.SimulationTimer _timerUpdateLatencyText;
[Header("Stress Test 1: Move Y")]
[SerializeField] protected StressTestEssential _test_1;
[Header("Stress Test 2: Move All Axis")]
[SerializeField] protected StressTestEssential _test_2;
[Header("Stress Test 3: Move Wander")]
[SerializeField] protected StressTestEssential _test_3;
[System.Serializable]
public struct StressTestEssential
{
// public Button ButtonExecute; // MIRROR CHANGE: Canvas + TextMeshPro -> OnGUI
public int SpawnCount;
public GameObject Prefab;
}
private void Start()
{
Initialize();
}
// MIRROR CHANGE: OnGUI instead of Canvas + TextMeshPro
protected virtual void Initialize()
{
// _test_1.ButtonExecute.onClick.AddListener(StressTest_1);
// _test_2.ButtonExecute.onClick.AddListener(StressTest_2);
// _test_3.ButtonExecute.onClick.AddListener(StressTest_3);
//
// _buttonStartServer.onClick.AddListener(StartServer);
// _buttonStartClient.onClick.AddListener(StartClient);
}
protected virtual void OnCustomGUI() {}
protected virtual void OnGUI()
{
GUILayout.BeginArea(new Rect(100, 100, 300, 400));
if (GUILayout.Button("Stress Test 1"))
{
StressTest_1();
}
if (GUILayout.Button("Stress Test 2"))
{
StressTest_2();
}
if (GUILayout.Button("Stress Test 3"))
{
StressTest_3();
}
OnCustomGUI();
GUILayout.Label(_textLatency);
GUILayout.EndArea();
}
// END MIRROR CHANGE
protected virtual void StartClient() { }
protected virtual void StartServer() { }
private void StressTest_1() => StressTest(_test_1);
private void StressTest_2() => StressTest(_test_2);
private void StressTest_3() => StressTest(_test_3);
protected virtual void StressTest(StressTestEssential stressTest) { }
private void LateUpdate()
{
if (!_timerUpdateLatencyText.IsExpiredOrNotRunning()) return;
UpdateNetworkStats();
_timerUpdateLatencyText = SimulationTimer.SimulationTimer.CreateFromSeconds(_updateLatencyTextInterval);
}
protected virtual void UpdateNetworkStats() { }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0f64aeea8d696ff4fbb80a37fad8ebd8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Scripts/UI/BaseGUIGame.cs
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 65744866da2028e4fab6871830543ca5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,28 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Unlit
m_Shader: {fileID: 4800000, guid: 2126a83145dd7bc48959270850637c77, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 0
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats:
- __dirty: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: aa7b0f2a00af4ef4bac3c70fb2c798eb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Shaders/Unlit.mat
uploadId: 736421

View File

@ -0,0 +1,37 @@
Shader "Unlit"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
[HideInInspector] __dirty( "", Int ) = 1
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IsEmissive" = "true" }
Cull Back
CGPROGRAM
#pragma target 3.0
#pragma surface surf Unlit keepalpha addshadow fullforwardshadows
struct Input
{
half filler;
};
uniform float4 _Color;
inline half4 LightingUnlit( SurfaceOutput s, half3 lightDir, half atten )
{
return half4 ( 0, 0, 0, s.Alpha );
}
void surf( Input i , inout SurfaceOutput o )
{
o.Emission = _Color.rgb;
o.Alpha = 1;
}
ENDCG
}
Fallback "Diffuse"
}

View File

@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 2126a83145dd7bc48959270850637c77
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Examples/BenchmarkStinkySteak/Dependencies/netcode-benchmarker-util/Runtime/Shaders/Unlit.shader
uploadId: 736421