-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Photon.Bolt; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class BoltFrameController : MonoBehaviour | ||
{ | ||
[SerializeField] private Text Label; | ||
[SerializeField] private Text ValuePing; | ||
[SerializeField] private Text ValueBitsInt; | ||
[SerializeField] private Text ValueBitsOut; | ||
|
||
public void SetLabel(BoltConnection connection) | ||
{ | ||
this.Label.text = string.Format("[{0}] {1}", connection.ConnectionType, connection.RemoteEndPoint.ToString()); | ||
} | ||
|
||
public void SetValue(float ping, float bitsIn, float bitsOut) | ||
{ | ||
this.ValuePing.text = ping.ToString(); | ||
this.ValueBitsInt.text = bitsIn.ToString(); | ||
this.ValueBitsOut.text = bitsOut.ToString(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Photon.Bolt; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class BoltStatsController : GlobalEventListener | ||
{ | ||
[SerializeField] private GameObject RemoteConnectionHolder; | ||
[SerializeField] private GameObject FrameStatPrefab; | ||
|
||
private Dictionary<BoltConnection, BoltFrameController> remoteFrameStateMap; | ||
|
||
void Start() | ||
{ | ||
remoteFrameStateMap = new Dictionary<BoltConnection, BoltFrameController>(); | ||
} | ||
|
||
void FixedUpdate() | ||
{ | ||
if (BoltNetwork.IsRunning) | ||
{ | ||
foreach (var conn in BoltNetwork.Connections) | ||
{ | ||
if (remoteFrameStateMap.TryGetValue(conn, out var frameController) == false) | ||
{ | ||
var frameControllerGO = Instantiate(FrameStatPrefab); | ||
frameControllerGO.transform.parent = RemoteConnectionHolder.transform; | ||
|
||
frameController = frameControllerGO.GetComponent<BoltFrameController>(); | ||
frameController.SetLabel(conn); | ||
|
||
remoteFrameStateMap.Add(conn, frameController); | ||
} | ||
|
||
frameController.SetValue(conn.PingNetwork * 1000, conn.BitsPerSecondIn, conn.BitsPerSecondOut); | ||
} | ||
} | ||
} | ||
|
||
public override void Disconnected(BoltConnection connection) | ||
{ | ||
if (remoteFrameStateMap.TryGetValue(connection, out var frameController)) | ||
{ | ||
Destroy(frameController.gameObject); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.