Created
February 17, 2017 19:27
-
-
Save SnugglePilot/3a7de1055e9a2d08b6447e088b7b344a to your computer and use it in GitHub Desktop.
NetworkDebugUI for Photon/Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class NetworkDebugUI : MonoBehaviour { | |
public UnityEngine.Events.UnityEvent onOnline; | |
public UnityEngine.Events.UnityEvent onOffline; | |
protected bool isOnline = false; | |
protected bool showMic = false; | |
protected bool echoMic = false; | |
void OnGUI() { | |
int width = 100; | |
int height = 25; | |
int left = 10; | |
int top = Screen.height - height -10; | |
int spacing = 10; | |
string text = (isOnline) ? "Go Offline" : "Go Online"; | |
if (GUI.Button(new Rect(left, top, width, height), text)) { | |
isOnline = !isOnline; | |
if (isOnline) { | |
onOnline.Invoke(); | |
} else { | |
onOffline.Invoke(); | |
} | |
} | |
//#if PHOTON_VOICE // doesnn't appear to work, I think the define is only in edit mode? see accountservice.cs | |
text = (showMic) ? "[-] Mics" : "[+] Mics"; | |
top = 10; | |
if (GUI.Button(new Rect(10, top, width, height), text)) { | |
showMic = !showMic; | |
} | |
top += height + spacing; | |
if (showMic) { | |
foreach (var x in Microphone.devices) { | |
if (GUI.Button(new Rect(left, top, width*4, height) , (PhotonVoiceNetwork.MicrophoneDevice == x ? "[X] " : "[ ] ") + x)) { | |
PhotonVoiceNetwork.MicrophoneDevice = x; | |
} | |
top += height + spacing; | |
} | |
} | |
text = (echoMic) ? "Disable Echo" : "Enable Echo"; | |
if (GUI.Button(new Rect(10, top, width, height), text)) { | |
echoMic = !echoMic; | |
PhotonVoiceNetwork.Client.DebugEchoMode = echoMic; | |
} | |
top += height + spacing; | |
//#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment