// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; namespace UltimateXR.Editor.Utilities { /// /// Simple log window. /// public class UxrLogWindow : EditorWindow { #region Inspector Properties/Serialized Fields [SerializeField] private List _infoLines = new List(); [SerializeField] private Vector2 _scrollPos; #endregion #region Public Types & Data public const int DefaultWindowWidth = 1400; public const int DefaultWindowHeight = 600; #endregion #region Public Methods /// /// Shows the window with the log. /// /// public static void ShowLog(IEnumerable infoLines, int windowWidth = DefaultWindowWidth, int windowHeight = DefaultWindowHeight) { UxrLogWindow window = (UxrLogWindow)GetWindow(typeof(UxrLogWindow)); int x = (Screen.currentResolution.width - windowWidth) / 2; int y = (Screen.currentResolution.height - windowHeight) / 2; window.position = new Rect(x, y, windowWidth, windowHeight); window._infoLines = infoLines.ToList(); window.Show(); } #endregion #region Unity /// /// Draws the window. /// private void OnGUI() { EditorGUILayout.BeginVertical(); _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - EditorGUIUtility.singleLineHeight * 2)); foreach (string line in _infoLines) { GUILayout.Label(line); } EditorGUILayout.EndScrollView(); if (UxrEditorUtils.CenteredButton(new GUIContent("Close"))) { Close(); } EditorGUILayout.EndVertical(); } #endregion } }