Skip to content

Instantly share code, notes, and snippets.

@SnugglePilot
Created February 17, 2017 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SnugglePilot/3a7de1055e9a2d08b6447e088b7b344a to your computer and use it in GitHub Desktop.
Save SnugglePilot/3a7de1055e9a2d08b6447e088b7b344a to your computer and use it in GitHub Desktop.
NetworkDebugUI for Photon/Unity
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