private void ShowTriggers(TriggerLogger triggerLogger) { var win = Screen.width * 0.8; var w1 = win * 0.20; var w2 = win * 0.06; var centeredStyle = new GUIStyle(GUI.skin.label); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label("Triggers: " + triggerLogger.triggers.list.Sum(t => t.Total).ToString()); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Type", GUILayout.Width((float)w1)); GUILayout.Label("Total", centeredStyle, GUILayout.Width((float)w2)); EditorGUILayout.EndHorizontal(); triggerLogger.triggers.list.ForEach(bl => { if (!triggerLogger.StatsShowZero && bl.Total == 0) { return; } DrawUILine(Color.gray); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(bl.Type.ToString(), GUILayout.Width((float)w1)); EditorGUILayout.LabelField(bl.Total.ToString(), centeredStyle, GUILayout.Width((float)w2)); EditorGUILayout.EndHorizontal(); }); }
private void ShowBroadcasts(TriggerLogger triggerLogger) { var win = Screen.width * 0.8; var w1 = win * 0.17; var w2 = win * 0.06; var centeredStyle = new GUIStyle(GUI.skin.label); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label("Broadcasts: " + triggerLogger.broadcasts.list.Where(t => t.Type != VRC_EventHandler.VrcBroadcastType.Local).Sum(t => t.Total).ToString() + " - Non-local"); GUILayout.Label("Network: " + triggerLogger.broadcasts.list.Sum(t => t.RPC).ToString()); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Type", GUILayout.Width((float)w1)); GUILayout.Label("Total", centeredStyle, GUILayout.Width((float)w2)); GUILayout.Label("RPC", centeredStyle, GUILayout.Width((float)w2)); EditorGUILayout.EndHorizontal(); triggerLogger.broadcasts.list.ForEach(bl => { if (!triggerLogger.StatsShowZero && bl.Total == 0) { return; } DrawUILine(Color.gray); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(bl.Type.ToString(), GUILayout.Width((float)w1)); EditorGUILayout.LabelField(bl.Total.ToString(), centeredStyle, GUILayout.Width((float)w2)); EditorGUILayout.LabelField(bl.RPC.ToString(), centeredStyle, GUILayout.Width((float)w2)); EditorGUILayout.EndHorizontal(); }); }
public void drawWindow(TriggerLogger triggerLogger) { GUILayout.Space(5); dropdown = (StatsType)EditorGUILayout.EnumPopup(dropdown); triggerLogger.StatsShowZero = GUILayout.Toggle(triggerLogger.StatsShowZero, "Show with zero"); scrollLocation = EditorGUILayout.BeginScrollView(scrollLocation); switch (dropdown) { case StatsType.Broadcasts: ShowBroadcasts(triggerLogger); break; case StatsType.Triggers: ShowTriggers(triggerLogger); break; case StatsType.Actions: ShowActions(triggerLogger); break; } EditorGUILayout.EndScrollView(); }
public void drawWindow(TriggerLogger triggerLogger) { var guicolor = GUI.backgroundColor; UILabel("Help"); GUI.backgroundColor = Color.gray; GUILayout.BeginHorizontal("helpbox"); GUILayout.Label("Disabled"); GUILayout.EndHorizontal(); GUI.backgroundColor = Color.yellow; GUILayout.BeginHorizontal("helpbox"); GUILayout.Label("Warning"); GUILayout.EndHorizontal(); GUI.backgroundColor = Color.red; GUILayout.BeginHorizontal("helpbox"); GUILayout.Label("Error"); GUILayout.EndHorizontal(); GUI.backgroundColor = Color.cyan; GUILayout.BeginHorizontal("helpbox"); GUILayout.Label("Prefab"); GUILayout.EndHorizontal(); GUI.backgroundColor = guicolor; GUILayout.Space(10); UILabel("Author: PhaxeNor"); GUILayout.BeginHorizontal(); if (GUILayout.Button("Twitter")) { Application.OpenURL("https://twitter.com/phaxenor"); } if (GUILayout.Button("Github")) { Application.OpenURL("https://github.com/PhaxeNor/Trigger-Logger"); } GUILayout.EndHorizontal(); GUILayout.Space(10); UILabel("VRC Prefabs"); if (GUILayout.Button("Twitter")) { Application.OpenURL("https://twitter.com/VRCPrefabs"); } if (GUILayout.Button("Github")) { Application.OpenURL("https://github.com/vrc-prefabs"); } if (GUILayout.Button("Website")) { Application.OpenURL("https://vrcprefabs.com"); } if (GUILayout.Button("Unofficial Wiki")) { Application.OpenURL("https://vrchat.wikidot.com"); } }
public void drawWindow(TriggerLogger tl) { GUILayout.Space(5); tl.query = EditorGUILayout.TextField("GameObject Search", tl.query); GUILayout.Space(5); UILabel("VRC Trigger"); var oldTFalgs = tl.triggerFlags; tl.triggerFlags = EditorGUILayout.MaskField("Triggers", tl.triggerFlags, tl.triggerTypes.ToArray()); if (tl.triggerFlags != oldTFalgs) { tl.triggerFilter.Clear(); for (int i = 0; i < tl.triggerTypes.ToArray().Length; i++) { if ((tl.triggerFlags & (1 << i)) == (1 << i)) { tl.triggerFilter.Add(tl.triggerTypes.ToArray()[i]); } } } var oldBFalgs = tl.broadcastFlags; tl.broadcastFlags = EditorGUILayout.MaskField("Broadcasts", tl.broadcastFlags, tl.broadcasTypes.ToArray()); if (tl.broadcastFlags != oldBFalgs) { tl.broadcastFilter.Clear(); for (int i = 0; i < tl.broadcasTypes.ToArray().Length; i++) { if ((tl.broadcastFlags & (1 << i)) == (1 << i)) { tl.broadcastFilter.Add(tl.broadcasTypes.ToArray()[i]); } } } var oldAFalgs = tl.actionsFlags; tl.actionsFlags = EditorGUILayout.MaskField("Actions", tl.actionsFlags, tl.actionsTypes.ToArray()); if (tl.actionsFlags != oldAFalgs) { tl.actionFilter.Clear(); for (int i = 0; i < tl.actionsTypes.ToArray().Length; i++) { if ((tl.actionsFlags & (1 << i)) == (1 << i)) { tl.actionFilter.Add(tl.actionsTypes.ToArray()[i]); } } } GUILayout.Space(5); if (tl.sendRpcMethods.Count > 0) { var oldRPCFalgs = tl.RpcMethodsFlags; tl.RpcMethodsFlags = EditorGUILayout.MaskField("SendRPC Methods", tl.RpcMethodsFlags, tl.sendRpcMethods.ToArray()); if (tl.RpcMethodsFlags != oldRPCFalgs) { tl.RpcMethodsFilter.Clear(); for (int i = 0; i < tl.sendRpcMethods.ToArray().Length; i++) { if ((tl.RpcMethodsFlags & (1 << i)) == (1 << i)) { tl.RpcMethodsFilter.Add(tl.sendRpcMethods.ToArray()[i]); } } } GUILayout.Space(5); } UILabel("Advanced"); tl.ShowPrefabs = EditorGUILayout.Toggle("Show Prefabs", tl.ShowPrefabs); tl.ShowEmpty = EditorGUILayout.Toggle("Show Empty", tl.ShowEmpty); tl.ShowErrors = EditorGUILayout.Toggle("Show Errors/Warnings", tl.ShowErrors); GUILayout.Space(5); tl.HideNonErrors = EditorGUILayout.Toggle("Hide Non Error/Warning", tl.HideNonErrors); GUILayout.Space(10); }
public void drawWindow(TriggerLogger tl) { GUILayout.Space(5); var win = Screen.width * 0.8; var w1 = win * 0.35; var w2 = win * 0.10; var w3 = win * 0.10; var w4 = win * 0.10; var centeredStyle = new GUIStyle(GUI.skin.label); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.BeginHorizontal("helpbox"); GUILayout.Label("GameObject", GUILayout.Width((float)w1)); GUILayout.Label("Triggers", centeredStyle, GUILayout.Width((float)w2)); GUILayout.Label("Actions", centeredStyle, GUILayout.Width((float)w2)); GUILayout.Label("Broadcasts", centeredStyle, GUILayout.Width((float)w2)); GUILayout.Label("Empty", centeredStyle, GUILayout.Width((float)w2)); GUILayout.EndHorizontal(); scrollLocation = EditorGUILayout.BeginScrollView(scrollLocation); if (tl.triggerList.Count > 0) { var guiColor = GUI.backgroundColor; for (var i = 0; i < tl.triggerList.Count; i++) { var trigger = tl.triggerList[i]; List <string> errors = new List <string>(); if (trigger == null) { continue; } if (!tl.ShowPrefabs && trigger.gameObject.scene.name == null) { continue; } if (tl.query != "" && !trigger.gameObject.name.ToLower().Contains(tl.query.ToLower())) { continue; } var empty = trigger.Triggers.Sum(t => t.Events.Count(e => e.ParameterObjects.Count() > 0)); if (tl.SendRPCquery != "" && !trigger.Triggers.Exists(t => { return(t.Events.Exists(e => e.ParameterString.ToLower().Contains(tl.SendRPCquery.ToLower()))); })) { continue; } if (!tl.ShowEmpty && empty == 0) { continue; } if (tl.triggerFlags == 0 || tl.broadcastFlags == 0 || tl.actionsFlags == 0) { continue; } if (tl.triggerFlags != 0 || tl.broadcastFlags != 0 || tl.actionsFlags != 0) { if (tl.triggerFlags != 0 && tl.triggerFlags != -1 && !trigger.Triggers.Exists(t => { return(tl.triggerFilter.Exists(o => t.TriggerType.ToString() == o)); })) { continue; } if (tl.broadcastFlags != 0 && tl.broadcastFlags != -1 && !trigger.Triggers.Exists(t => { return(tl.broadcastFilter.Exists(o => t.BroadcastType.ToString() == o)); })) { continue; } if (tl.actionsFlags != 0 && tl.actionsFlags != -1 && !trigger.Triggers.Exists(t => { return(t.Events.Exists(e => tl.actionFilter.Exists(o => e.EventType.ToString() == o))); })) { continue; } if (tl.RpcMethodsFlags != 0 && tl.RpcMethodsFlags != -1 && !trigger.Triggers.Exists(t => { return(t.Events.Exists(e => tl.RpcMethodsFilter.Exists(o => e.ParameterString.ToString() == o))); })) { continue; } } var triggers = trigger.Triggers.Count(); var events = trigger.Triggers.Sum(t => t.Events.Count); var broadcasts = trigger.Triggers.Where(t => t.BroadcastType != VRC_EventHandler.VrcBroadcastType.Local).Count(); if (i % 2 == 1) { GUI.backgroundColor = new Color(0.80f, 0.80f, 0.80f, 1f); } if (triggers == 0) { errors.Add("Object has the VRC_Trigger componet, but no triggers"); GUI.backgroundColor = Color.red; } if (!trigger.gameObject.activeInHierarchy || !trigger.isActiveAndEnabled) { if (trigger.gameObject.scene.name != null) { errors.Add("Trigger is disabled"); } GUI.backgroundColor = Color.yellow; } if (missingTeleportTo(trigger)) { errors.Add("TeleportTo target is empty"); GUI.backgroundColor = Color.yellow; } if (empty == 0) { errors.Add("Trigger doesn't have any actions."); GUI.backgroundColor = Color.red; } if (trigger.gameObject.scene.name == null) { GUI.backgroundColor = Color.cyan; } if (Selection.objects.Contains(trigger.gameObject)) { GUI.backgroundColor = new Color(0.047f, 0.564f, 0.929f, 1); } if (errors.Count > 0 && !tl.ShowErrors) { GUI.backgroundColor = guiColor; continue; } if (errors.Count == 0 && tl.HideNonErrors) { GUI.backgroundColor = guiColor; continue; } GUILayout.BeginVertical("helpbox"); GUILayout.BeginHorizontal(); EditorGUILayout.ObjectField(trigger.gameObject, typeof(GameObject), true, GUILayout.Width((float)w1)); GUILayout.Label(triggers.ToString(), centeredStyle, GUILayout.Width((float)w2)); GUILayout.Label(events.ToString(), centeredStyle, GUILayout.Width((float)w2)); GUILayout.Label(broadcasts.ToString(), centeredStyle, GUILayout.Width((float)w2)); GUILayout.Label((empty > 0) ? "No" : "Yes", centeredStyle, GUILayout.Width((float)w2)); GUILayout.EndHorizontal(); if (errors.Count > 0) { GUILayout.BeginVertical(); errors.ForEach(e => { GUILayout.Label(e); }); GUILayout.EndVertical(); } GUILayout.EndVertical(); if (Event.current.type == EventType.MouseDown && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { GameObject[] selected = new GameObject[1]; selected[0] = trigger.gameObject; Selection.objects = selected; tl.Repaint(); } GUI.backgroundColor = guiColor; } } EditorGUILayout.EndScrollView(); }