draw in-game windows in edit mode

This commit is contained in:
in0finite 2022-01-26 20:33:29 +01:00
parent 941ec06be1
commit c791aec4b8
4 changed files with 115 additions and 0 deletions

View file

@ -2313,6 +2313,7 @@ MonoBehaviour:
windowName: Console
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2342,6 +2343,7 @@ MonoBehaviour:
windowName: Utilities
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 1
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2369,6 +2371,7 @@ MonoBehaviour:
windowName: Controls
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2396,6 +2399,7 @@ MonoBehaviour:
windowName: Teleport
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 1
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2423,6 +2427,7 @@ MonoBehaviour:
windowName: DayTime
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2451,6 +2456,7 @@ MonoBehaviour:
windowName: Options
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 0
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2478,6 +2484,7 @@ MonoBehaviour:
windowName: Vehicle Spawner
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2505,6 +2512,7 @@ MonoBehaviour:
windowName: Map
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2532,6 +2540,7 @@ MonoBehaviour:
windowName: Animations
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2559,6 +2568,7 @@ MonoBehaviour:
windowName: Weapons
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2586,6 +2596,7 @@ MonoBehaviour:
windowName: Peds
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2626,6 +2637,7 @@ MonoBehaviour:
windowName: Change path to GTA
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 0
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2653,6 +2665,7 @@ MonoBehaviour:
windowName: Audio
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2683,6 +2696,7 @@ MonoBehaviour:
windowName: Start Game
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 0
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2719,6 +2733,7 @@ MonoBehaviour:
windowName: Join Game
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 0
m_destroyOnClose: 0
windowRect:
serializedVersion: 2
@ -2747,6 +2762,7 @@ MonoBehaviour:
windowName: Stats
m_isOpenedByDefaultInMainMenu: 0
m_isOpenedByDefaultInPauseMenu: 0
m_drawInEditMode: 1
m_destroyOnClose: 0
windowRect:
serializedVersion: 2

View file

@ -0,0 +1,85 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using SanAndreasUnity.UI;
using System.Linq;
using System;
using SanAndreasUnity.Utilities;
namespace SanAndreasUnity.Editor
{
public class InGameWindowDrawer : EditorWindowBase
{
private bool m_searchedForWindows = false;
private List<PauseMenuWindow> m_pauseMenuWindows = new List<PauseMenuWindow>();
private int m_selectedWindowIndex = -1;
private Vector2 m_scrollViewPosition = Vector2.zero;
public InGameWindowDrawer()
{
this.titleContent = new GUIContent("In-game window drawer");
this.minSize = new Vector2(450, 300);
}
[MenuItem(EditorCore.MenuName + "/" + "In-game window drawer")]
static void Init()
{
var window = GetWindow<InGameWindowDrawer>();
window.Show();
}
void SearchForWindows()
{
if (m_searchedForWindows)
return;
if (Behaviours.UIManager.Singleton != null)
{
m_searchedForWindows = true;
m_pauseMenuWindows = Behaviours.UIManager.Singleton
.GetComponentsInChildren<PauseMenuWindow>()
.Where(w => w.DrawInEditMode)
.ToList();
}
}
void OnGUI()
{
this.SearchForWindows();
int tabsAreaWidth = 120;
GUILayout.BeginArea(new Rect(0, 0, tabsAreaWidth, this.position.height));
m_scrollViewPosition = GUILayout.BeginScrollView(m_scrollViewPosition);
for (int i = 0; i < m_pauseMenuWindows.Count; i++)
{
if (null == m_pauseMenuWindows[i])
continue;
GUI.enabled = m_selectedWindowIndex != i;
if (GUILayout.Button(m_pauseMenuWindows[i].windowName, GUILayout.Width(tabsAreaWidth - 10)))
m_selectedWindowIndex = i;
GUI.enabled = true;
}
GUILayout.EndScrollView();
GUILayout.EndArea();
GUILayout.BeginArea(new Rect(tabsAreaWidth, 0, this.position.width - tabsAreaWidth, this.position.height));
if (m_selectedWindowIndex >= 0)
{
var window = m_pauseMenuWindows[m_selectedWindowIndex];
if (window != null)
{
window.DrawWindowContent();
}
}
GUILayout.EndArea();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2edc0ec53411ad24888a9134287167a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -10,6 +10,9 @@ namespace SanAndreasUnity.UI {
[SerializeField] private bool m_isOpenedByDefaultInMainMenu = false;
[SerializeField] private bool m_isOpenedByDefaultInPauseMenu = false;
[SerializeField] private bool m_drawInEditMode = true;
public bool DrawInEditMode => m_drawInEditMode;
private bool m_isOpened = false;
public bool IsOpened {
get { return this.m_isOpened; }