/// <summary> /// Adds a global variable to the watchlist. /// </summary> /// <param name="name">Name of the global variable.</param> public static void Watch(string name) { Watchlist.Add(name, null, true); }
/// <summary> /// Adds a value to watchlist under the specified display name. /// </summary> /// <param name="name">Display name of the variable.</param> /// <param name="value">Variable value to be reported.</param> public static void Watch(string name, object value) { Watchlist.Add(name, value); }
private void DoMainWindow(int id) { var oldColor = GUI.backgroundColor; // Draw close button if (GUI.Button(new Rect(_mainWindowRect.width - 38, 8, 30, 30), "×", Elements.Buttons.Red)) { Handler.Visible = false; } // Draw clear button if (GUI.Button(new Rect(_mainWindowRect.width - 76, 8, 30, 30), _tex, Elements.Buttons.Red)) { Watchlist.Clear(); } var toBeRemoved = new List <VariableWatch>(); _newVariableName = GUI.TextField(new Rect(68, 48, 248, 20), _newVariableName, Elements.InputFields.ComponentField); if (GUI.Button(new Rect(4, 48, 60, 20), "Add", Elements.Buttons.Default) && Regex.Replace(_newVariableName, @"\s+", "") != "") { _newVariableName = Regex.Replace(_newVariableName, @"\s+", ""); Watchlist.Add(_newVariableName, null, true); _newVariableName = ""; } GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.7f); _scrollPosition = GUI.BeginScrollView( new Rect(4, 72, 312, 424), _scrollPosition, new Rect(0, 0, 296, 4 + Watchlist.Watched.Count * 24)); GUI.backgroundColor = oldColor; var i = 0; foreach (var v in Watchlist.Watched) { // Button for removing line if (GUI.Button(new Rect(4, 4 + i * 24, 20, 20), "×", Elements.Buttons.Red)) { toBeRemoved.Add(v); } // Color of labels GUI.backgroundColor = Color.black; // Variable name: button for global, label for local if (v.Global) { if (GUI.Button(new Rect(28, 4 + i * 24, 130, 20), v.GetName(), Elements.Buttons.Default)) { _editing = true; _editingVariable = v; _newVariableValue = v.GetEditString(); _editWindowRect = new Rect( _mainWindowRect.x + 24, _mainWindowRect.y + 60 + i * 24, EditWindowWidth, EditWindowHeight); } } else { GUI.Label(new Rect(28, 4 + i * 24, 130, 20), v.GetName(), Elements.InputFields.ComponentField); } // Label for variable value GUI.Label(new Rect(162, 4 + i * 24, 136, 20), v.GetValue(), Elements.InputFields.ComponentField); GUI.backgroundColor = oldColor; i++; } // Remove variables foreach (var v in toBeRemoved) { Watchlist.Watched.Remove(v); } GUI.EndScrollView(); GUI.DragWindow(new Rect(0, 0, _mainWindowRect.width, GUI.skin.window.padding.top)); }