forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiplayerWindow.cs
More file actions
60 lines (49 loc) · 1.63 KB
/
MultiplayerWindow.cs
File metadata and controls
60 lines (49 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using UnityEditor;
using UnityEngine;
namespace Unity.Netcode.Editor
{
public class MultiplayerWindow : EditorWindow
{
private const string k_PrefsKeyPrefix = "NetcodeGameObjects";
[MenuItem("Netcode/Simulator Tools")]
public static void ShowWindow()
{
GetWindow<MultiplayerWindow>(false, "Simulator Tools", true);
}
private void OnGUI()
{
EditorInt("Client send/recv delay (ms)", "ClientDelay", 0, 2000);
EditorInt("Client send/recv jitter (ms)", "ClientJitter", 0, 200);
EditorInt("Client packet drop (percentage)", "ClientDropRate", 0, 100);
}
private static string GetKey(string subKey)
{
return k_PrefsKeyPrefix + "_" + Application.productName + "_" + subKey;
}
private int EditorInt(string label, string key = null, int minValue = int.MinValue, int maxValue = int.MaxValue)
{
string prefsKey = (string.IsNullOrEmpty(key) ? GetKey(label) : GetKey(key));
int value;
value = EditorPrefs.GetInt(prefsKey);
if (value < minValue)
{
value = minValue;
}
if (value > maxValue)
{
value = maxValue;
}
value = EditorGUILayout.IntField(label, value);
if (value < minValue)
{
value = minValue;
}
if (value > maxValue)
{
value = maxValue;
}
EditorPrefs.SetInt(prefsKey, value);
return value;
}
}
}