Skip to content
Snippets Groups Projects
Commit c75f882e authored by Dr. phil. Stephen James Tobin's avatar Dr. phil. Stephen James Tobin
Browse files

WebCommunication capitalization fixed.

Files temporarily renamed.
parent 63e4b813
No related branches found
No related tags found
No related merge requests found
Showing
with 287 additions and 2 deletions
......@@ -16,7 +16,7 @@ namespace TeachR.WebCommunication
[SerializeField] private GameObject impulseController;
//[SerializeField] private GameObject behaviourController;
[SerializeField] private GameObject scenarioController;
[SerializeField] private GameObject speechToolsPLACEHOLDER;
[SerializeField] private GameObject speechToolsController;
[SerializeField] private GameObject labController;
[SerializeField] private GameObject ToAddMoreScriptsController;
......@@ -43,7 +43,7 @@ namespace TeachR.WebCommunication
controllerGameObjects.Add(new ControllerScriptEntry("ImpulseController", impulseController));
//controllerGameObjects.Add(new ControllerScriptEntry("BehaviourController", behaviourController));
controllerGameObjects.Add(new ControllerScriptEntry("ScenarioController", scenarioController));
controllerGameObjects.Add(new ControllerScriptEntry("speechtoolsPLACEHOLDER", speechToolsPLACEHOLDER));
controllerGameObjects.Add(new ControllerScriptEntry("SpeechToolsController", speechToolsController));
controllerGameObjects.Add(new ControllerScriptEntry("LabController", labController));
//controllerGameObjects.Add(new ControllerScriptEntry(" ", ToAddMoreScriptsController));
......
fileFormatVersion: 2
guid: 91090d6cd37d5304db34f4e0a94f2c54
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
#if UNITY_EDITOR
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace TeachR.WebCommunication {
public class CoachInfo : EditorWindow
{
private struct MsgJson
{
public string Type;
public string Json;
}
// TODO: Allow setting this when not in play mode
private static readonly string[] IgnoreList =
{
"syncTeacher"
};
private static bool _persistentFoldout, _transientFoldout, _incomingFoldout, _outgoingFoldout;
private static readonly Dictionary<string, int> Calls = new();
private static readonly LimitQueue<MsgJson> Incoming = new(10);
private static readonly LimitQueue<MsgJson> Outgoing = new(10);
[MenuItem("Window/TeachR/Coach RTC Info")]
public static void ShowWindow()
{
ListenToMessages(IgnoreList);
GetWindow(typeof(CoachInfo));
}
private static void ListenToMessages(string[] ignoreMessages)
{
SocketServer.OnIncomingMessage += (type, content) =>
{
Calls[type] = Calls.TryGetValue(type, out int numCalls) ? numCalls + 1 : 1;
if (ignoreMessages.Contains(type)) return;
Incoming.Enqueue(new MsgJson { Type = type, Json = content });
};
SocketServer.OnOutgoingMessage += (type, content) =>
{
if (ignoreMessages.Contains(type)) return;
Outgoing.Enqueue(new MsgJson { Type = type, Json = JsonConvert.SerializeObject(content) });
};
}
private void OnGUI()
{
if (!Application.isPlaying) return;
_persistentFoldout = DrawEventFoldout("Persistent Events", CoachRtc.Persistent, _persistentFoldout);
EditorGUILayout.Space();
_transientFoldout = DrawEventFoldout("Transient Events", CoachRtc.Transient, _transientFoldout);
EditorGUILayout.Space();
_incomingFoldout = DrawMessageQueue("Incoming Messages", Incoming, _incomingFoldout);
EditorGUILayout.Space();
_outgoingFoldout = DrawMessageQueue("Outgoing Messages", Outgoing, _outgoingFoldout);
EditorGUILayout.Space();
}
private static bool DrawEventFoldout(string label, RtcEvents events, bool state)
{
state = EditorGUILayout.BeginFoldoutHeaderGroup(state, $"{label} ({events.Registered.Count()} events)");
if (state)
{
foreach (string p in events.Registered)
{
// TODO: Use grid layout?
int numCalls = Calls.TryGetValue(p, out int num) ? num : 0;
EditorGUILayout.BeginHorizontal();
GUILayout.Label(p);
GUILayout.Label($"{events.Count(p)} listeners");
GUILayout.Label($"{numCalls} calls");
EditorGUILayout.EndHorizontal();
}
}
EditorGUILayout.EndFoldoutHeaderGroup();
return state;
}
private static bool DrawMessageQueue(string label, LimitQueue<MsgJson> queue, bool state)
{
state = EditorGUILayout.BeginFoldoutHeaderGroup(state, $"{label}");
if (state)
{
foreach (MsgJson msg in queue.ToArray())
{
EditorGUILayout.BeginHorizontal();
GUILayout.Label(msg.Type);
if (GUILayout.Button("Copy Content"))
{
object json = JsonConvert.DeserializeObject(msg.Json);
string text = JsonConvert.SerializeObject(json, Formatting.Indented);
TextPopup.Init(text);
GUIUtility.systemCopyBuffer = text;
}
EditorGUILayout.EndHorizontal();
}
}
EditorGUILayout.EndFoldoutHeaderGroup();
return state;
}
}
}
#endif
\ No newline at end of file
fileFormatVersion: 2
guid: 181ba8533ad6bfc4ab37ec4535c75dc8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections.Generic;
namespace TeachR.WebCommunication
{
public class LimitQueue<T>
{
private readonly Queue<T> _queue = new();
private readonly int _limit;
public LimitQueue(int limit)
{
_limit = limit;
}
public void Enqueue(T item)
{
if (_queue.Count >= _limit) _queue.Dequeue();
_queue.Enqueue(item);
}
public T[] ToArray() => _queue.ToArray();
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: a6e6968ef982d4d47a0717b5b3527a12
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
public class TextPopup : EditorWindow
{
private string _text;
[SerializeField] private VisualTreeAsset uiAsset;
public static void Init(string content)
{
TextPopup window = CreateInstance<TextPopup>();
window._text = content;
window.Show();
}
private void CreateGUI()
{
uiAsset.CloneTree(rootVisualElement);
Button button = rootVisualElement.Q<Button>();
button.clicked += () => GUIUtility.systemCopyBuffer = _text;
Label label = rootVisualElement.Q<Label>();
label.text = _text;
}
}
#endif
\ No newline at end of file
fileFormatVersion: 2
guid: c9e72c6a03e064f4cbcaf41abeae8518
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- m_ViewDataDictionary: {instanceID: 0}
- uiAsset: {fileID: 9197481963319205126, guid: 7e71e9ad6a99fa54e910328d83199f2a,
type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b0f9c95a57db21840a4d213deba52933
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d90ac941cb4488943aa3be3d7cd59c49
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
[Serializable]
public class QuestionJson
{
public string[] students;
public int[] questions;
}
fileFormatVersion: 2
guid: a7a6800fd7dcf324e86759287dfea916
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
public class Behave
{
public string id;
public string behaviour;
public Behave(string id, string behaviour)
{
this.id = id; this.behaviour = behaviour;
}
}
fileFormatVersion: 2
guid: e8fd039bd978f9c408c6d318e00df5c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
public class Disruption
{
public string[] students;
public string behaviour;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment