A game about forced loneliness, made by TACStudios
1#if UNITY_EDITOR
2using System;
3using System.Collections.Generic;
4using UnityEditor;
5
6////TODO: survive domain reload properly
7
8namespace UnityEngine.InputSystem.Editor
9{
10 internal class InputActionDebuggerWindow : EditorWindow
11 {
12 [NonSerialized] private InputAction m_Action = null;
13
14 public static void CreateOrShowExisting(InputAction action)
15 {
16 if (action == null)
17 throw new System.ArgumentNullException(nameof(action));
18
19 // See if we have an existing window for the action and if so pop it in front.
20 if (s_OpenDebuggerWindows != null)
21 {
22 for (var i = 0; i < s_OpenDebuggerWindows.Count; ++i)
23 {
24 var existingWindow = s_OpenDebuggerWindows[i];
25 if (ReferenceEquals(existingWindow.m_Action, action))
26 {
27 existingWindow.Show();
28 existingWindow.Focus();
29 return;
30 }
31 }
32 }
33
34 // No, so create a new one.
35 var window = CreateInstance<InputActionDebuggerWindow>();
36 window.Show();
37 window.titleContent = new GUIContent(action.name);
38 window.AddToList();
39 }
40
41 public void OnGUI()
42 {
43 }
44
45 private static List<InputActionDebuggerWindow> s_OpenDebuggerWindows;
46
47 private void AddToList()
48 {
49 if (s_OpenDebuggerWindows == null)
50 s_OpenDebuggerWindows = new List<InputActionDebuggerWindow>();
51 if (!s_OpenDebuggerWindows.Contains(this))
52 s_OpenDebuggerWindows.Add(this);
53 }
54
55 private void RemoveFromList()
56 {
57 if (s_OpenDebuggerWindows != null)
58 s_OpenDebuggerWindows.Remove(this);
59 }
60 }
61}
62#endif // UNITY_EDITOR