mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
GUI
This commit is contained in:
parent
868f261612
commit
f1a86ee66e
@ -1639,5 +1639,28 @@ public static void Shutdown()
|
|||||||
OnDisconnectedEvent = null;
|
OnDisconnectedEvent = null;
|
||||||
OnErrorEvent = null;
|
OnErrorEvent = null;
|
||||||
}
|
}
|
||||||
|
// GUI /////////////////////////////////////////////////////////////////
|
||||||
|
// called from NetworkManager to display timeline interpolation status.
|
||||||
|
// useful to indicate catchup / slowdown / dynamic adjustment etc.
|
||||||
|
internal static void OnGUI()
|
||||||
|
{
|
||||||
|
// only if in world
|
||||||
|
if (!ready) return;
|
||||||
|
|
||||||
|
GUILayout.BeginArea(new Rect(10, 5, 400, 50));
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal("Box");
|
||||||
|
GUILayout.Label("Snapshot Interp.:");
|
||||||
|
// color while catching up / slowing down
|
||||||
|
if (localTimescale > 1) GUI.color = Color.green; // green traffic light = go fast
|
||||||
|
else if (localTimescale < 1) GUI.color = Color.red; // red traffic light = go slow
|
||||||
|
else GUI.color = Color.white;
|
||||||
|
GUILayout.Box($"timeline: {localTimeline:F2}");
|
||||||
|
GUILayout.Box($"buffer: {snapshots.Count}");
|
||||||
|
GUILayout.Box($"timescale: {localTimescale:F2}");
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.EndArea();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,9 @@ public class NetworkManager : MonoBehaviour
|
|||||||
public static List<Transform> startPositions = new List<Transform>();
|
public static List<Transform> startPositions = new List<Transform>();
|
||||||
public static int startPositionIndex;
|
public static int startPositionIndex;
|
||||||
|
|
||||||
|
[Header("Debug")]
|
||||||
|
public bool timeInterpolationGui = false;
|
||||||
|
|
||||||
/// <summary>The one and only NetworkManager</summary>
|
/// <summary>The one and only NetworkManager</summary>
|
||||||
public static NetworkManager singleton { get; internal set; }
|
public static NetworkManager singleton { get; internal set; }
|
||||||
|
|
||||||
@ -1342,5 +1345,12 @@ public virtual void OnStopClient() {}
|
|||||||
|
|
||||||
/// <summary>This is called when a host is stopped.</summary>
|
/// <summary>This is called when a host is stopped.</summary>
|
||||||
public virtual void OnStopHost() {}
|
public virtual void OnStopHost() {}
|
||||||
|
|
||||||
|
// GUI /////////////////////////////////////////////////////////////////
|
||||||
|
void OnGUI()
|
||||||
|
{
|
||||||
|
if (!timeInterpolationGui) return;
|
||||||
|
NetworkClient.OnGUI();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user