private void DrawEncounter(Rect rect, IList list, int index) { var encounter = _table.GetValue(index); var weight = _table.GetWeight(index); var percent = _table.GetPercentageWeight(index); var control = GetControl(index, encounter); var creatureHeight = control.GetHeight(null); var creatureRect = RectHelper.TakeHeight(ref rect, creatureHeight); control.Draw(creatureRect, null); RectHelper.TakeVerticalSpace(ref rect); RectHelper.TakeWidth(ref rect, rect.width * 0.25f); var percentRect = RectHelper.TakeTrailingWidth(ref rect, rect.width * 0.25f); var sliderRect = RectHelper.TakeWidth(ref rect, rect.width - RectHelper.HorizontalSpace); EditorGUI.LabelField(percentRect, string.Format("({0:f1}%)", percent)); var selectedWeight = EditorGUI.IntSlider(sliderRect, weight, 1, _table.TotalWeight); if (weight != selectedWeight) { _table.ChangeWeight(index, selectedWeight); } }
public override void OnGUI(Rect rect) { rect = RectHelper.Inset(rect, _padding); var add = false; var addRect = RectHelper.TakeTrailingWidth(ref rect, 32.0f); RectHelper.TakeTrailingWidth(ref rect, RectHelper.HorizontalSpace); using (new InvalidScope(_valid)) { using (var changes = new EditorGUI.ChangeCheckScope()) { add = EnterField.DrawString("AddWatchVariable", rect, GUIContent.none, ref _variable); if (changes.changed) { _valid = true; } } } if (GUI.Button(addRect, _addButton.Content)) { add = true; } if (add) { _valid = Window.AddWatch(_variable); if (_valid) { _variable = string.Empty; editorWindow.Close(); } else { editorWindow.Repaint(); } } }
private void DrawPrompt() { var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, GUILayout.ExpandWidth(true)); var execute = false; var executeRect = RectHelper.TakeTrailingWidth(ref rect, 32.0f); RectHelper.TakeTrailingWidth(ref rect, RectHelper.HorizontalSpace); using (new EditorGUI.DisabledScope(!Application.isPlaying)) { using (new InvalidScope(_promptValid)) { using (var changes = new EditorGUI.ChangeCheckScope()) { execute = EnterField.DrawString("PromptEntry", rect, GUIContent.none, ref _promptText); if (changes.changed) { _promptValid = true; } } } if (GUI.Button(executeRect, _executeButton.Content)) { execute = true; } if (execute) { _promptValid = ExecuteExpression(_promptText); if (_promptValid) { _promptText = string.Empty; } } } }