2021-03-30 19:50:04 +11:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using UnityEngine;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
using UnityEngine.UI;
|
2021-03-18 17:17:29 +11:00
|
|
|
|
using UnityExplorer.Core.Config;
|
2021-03-30 19:50:04 +11:00
|
|
|
|
using UnityExplorer.Core.Input;
|
2021-05-12 20:48:56 +10:00
|
|
|
|
using UnityExplorer.UI.CSConsole;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
using UnityExplorer.UI.Models;
|
|
|
|
|
using UnityExplorer.UI.Panels;
|
2021-03-18 17:17:29 +11:00
|
|
|
|
using UnityExplorer.UI.Utility;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
using UnityExplorer.UI.Widgets;
|
2021-04-23 21:50:58 +10:00
|
|
|
|
using UnityExplorer.UI.Widgets.AutoComplete;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
namespace UnityExplorer.UI
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
|
|
|
|
public static class UIManager
|
|
|
|
|
{
|
2021-04-23 21:50:58 +10:00
|
|
|
|
public enum Panels
|
|
|
|
|
{
|
|
|
|
|
ObjectExplorer,
|
|
|
|
|
Inspector,
|
|
|
|
|
CSConsole,
|
|
|
|
|
Options,
|
|
|
|
|
ConsoleLog,
|
2021-04-24 04:03:33 +10:00
|
|
|
|
AutoCompleter
|
2021-04-23 21:50:58 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 21:01:08 +10:00
|
|
|
|
public static bool Initializing { get; private set; } = true;
|
|
|
|
|
|
2020-10-23 01:50:33 +11:00
|
|
|
|
public static GameObject CanvasRoot { get; private set; }
|
2021-04-23 21:50:58 +10:00
|
|
|
|
public static Canvas Canvas { get; private set; }
|
2020-10-23 01:50:33 +11:00
|
|
|
|
public static EventSystem EventSys { get; private set; }
|
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
internal static GameObject PoolHolder { get; private set; }
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
// panels
|
2021-04-23 21:50:58 +10:00
|
|
|
|
internal static GameObject PanelHolder { get; private set; }
|
2021-05-13 03:55:08 +10:00
|
|
|
|
|
2021-05-09 20:18:33 +10:00
|
|
|
|
public static ObjectExplorerPanel Explorer { get; private set; }
|
2021-04-25 00:21:12 +10:00
|
|
|
|
public static InspectorPanel Inspector { get; private set; }
|
2021-05-09 20:18:33 +10:00
|
|
|
|
public static CSConsolePanel CSharpConsole { get; private set; }
|
2021-05-13 03:55:08 +10:00
|
|
|
|
public static OptionsPanel Options { get; private set; }
|
|
|
|
|
public static ConsoleLogPanel ConsoleLog { get; private set; }
|
2021-04-30 21:34:50 +10:00
|
|
|
|
|
2021-05-11 19:18:27 +10:00
|
|
|
|
public static AutoCompleteModal AutoCompleter { get; private set; }
|
2021-04-24 04:03:33 +10:00
|
|
|
|
|
2021-05-03 21:02:01 +10:00
|
|
|
|
// assets
|
2020-11-10 20:18:14 +11:00
|
|
|
|
internal static Font ConsoleFont { get; private set; }
|
2020-11-25 16:40:36 +11:00
|
|
|
|
internal static Shader BackupShader { get; private set; }
|
|
|
|
|
|
2021-05-03 21:02:01 +10:00
|
|
|
|
// Main Navbar UI
|
|
|
|
|
public static RectTransform NavBarRect;
|
|
|
|
|
public static GameObject NavbarButtonHolder;
|
|
|
|
|
|
2021-05-04 20:10:46 +10:00
|
|
|
|
internal static readonly Color enabledButtonColor = new Color(0.2f, 0.4f, 0.28f);
|
|
|
|
|
internal static readonly Color disabledButtonColor = new Color(0.25f, 0.25f, 0.25f);
|
2021-04-28 23:58:13 +10:00
|
|
|
|
|
2021-05-03 01:29:02 +10:00
|
|
|
|
public const int MAX_INPUTFIELD_CHARS = 16000;
|
2021-05-10 21:07:27 +10:00
|
|
|
|
public const int MAX_TEXT_VERTS = 65000;
|
2021-05-03 01:29:02 +10:00
|
|
|
|
|
2021-04-30 21:34:50 +10:00
|
|
|
|
public static UIPanel GetPanel(Panels panel)
|
|
|
|
|
{
|
|
|
|
|
switch (panel)
|
|
|
|
|
{
|
|
|
|
|
case Panels.ObjectExplorer:
|
|
|
|
|
return Explorer;
|
|
|
|
|
case Panels.Inspector:
|
|
|
|
|
return Inspector;
|
|
|
|
|
case Panels.AutoCompleter:
|
|
|
|
|
return AutoCompleter;
|
|
|
|
|
case Panels.CSConsole:
|
2021-05-09 20:18:33 +10:00
|
|
|
|
return CSharpConsole;
|
2021-04-30 21:34:50 +10:00
|
|
|
|
default:
|
|
|
|
|
throw new NotImplementedException($"TODO GetPanel: {panel}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-24 04:03:33 +10:00
|
|
|
|
// main menu toggle
|
2021-03-11 17:57:58 +11:00
|
|
|
|
public static bool ShowMenu
|
|
|
|
|
{
|
|
|
|
|
get => s_showMenu;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
set
|
2021-03-11 17:57:58 +11:00
|
|
|
|
{
|
2021-03-30 19:50:04 +11:00
|
|
|
|
if (s_showMenu == value || !CanvasRoot)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
s_showMenu = value;
|
|
|
|
|
CanvasRoot.SetActive(value);
|
|
|
|
|
CursorUnlocker.UpdateCursorControl();
|
2021-03-11 17:57:58 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-30 19:50:04 +11:00
|
|
|
|
public static bool s_showMenu = true;
|
2021-03-11 17:57:58 +11:00
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
public static void Update()
|
2021-03-11 17:57:58 +11:00
|
|
|
|
{
|
2021-04-29 21:01:08 +10:00
|
|
|
|
if (!CanvasRoot || Initializing)
|
2021-03-11 17:57:58 +11:00
|
|
|
|
return;
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
//if (InspectUnderMouse.Inspecting)
|
|
|
|
|
//{
|
|
|
|
|
// InspectUnderMouse.UpdateInspect();
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
2021-03-11 17:57:58 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
if (InputManager.GetKeyDown(ConfigManager.Main_Menu_Toggle.Value))
|
2021-03-11 17:57:58 +11:00
|
|
|
|
ShowMenu = !ShowMenu;
|
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
if (!ShowMenu)
|
2021-03-11 17:57:58 +11:00
|
|
|
|
return;
|
|
|
|
|
|
2021-05-06 04:02:42 +10:00
|
|
|
|
gcLabel.text = "GC : " + (GC.GetTotalMemory(false) / 1024 / 1024) + "MB";
|
|
|
|
|
|
2021-04-16 18:24:31 +10:00
|
|
|
|
if (InputManager.GetKeyDown(ConfigManager.Force_Unlock_Keybind.Value))
|
|
|
|
|
CursorUnlocker.Unlock = !CursorUnlocker.Unlock;
|
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
if (EventSystem.current != EventSys)
|
|
|
|
|
CursorUnlocker.SetEventSystem();
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
UIPanel.UpdateFocus();
|
2021-04-15 20:18:03 +10:00
|
|
|
|
PanelDragger.UpdateInstances();
|
2021-04-23 21:50:58 +10:00
|
|
|
|
UIBehaviourModel.UpdateInstances();
|
2021-03-30 19:50:04 +11:00
|
|
|
|
}
|
2020-11-11 20:16:43 +11:00
|
|
|
|
|
2021-04-24 04:03:33 +10:00
|
|
|
|
public static void TogglePanel(Panels panel)
|
|
|
|
|
{
|
|
|
|
|
var uiPanel = GetPanel(panel);
|
|
|
|
|
SetPanelActive(panel, !uiPanel.Enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetPanelActive(Panels panel, bool active)
|
|
|
|
|
{
|
2021-04-25 00:21:12 +10:00
|
|
|
|
var obj = GetPanel(panel);
|
2021-04-28 23:58:13 +10:00
|
|
|
|
SetPanelActive(obj, active);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetPanelActive(UIPanel panel, bool active)
|
|
|
|
|
{
|
|
|
|
|
panel.SetActive(active);
|
2021-04-25 00:21:12 +10:00
|
|
|
|
if (active)
|
|
|
|
|
{
|
2021-04-28 23:58:13 +10:00
|
|
|
|
panel.UIRoot.transform.SetAsLastSibling();
|
2021-04-25 00:21:12 +10:00
|
|
|
|
UIPanel.InvokeOnPanelsReordered();
|
|
|
|
|
}
|
2021-04-28 23:58:13 +10:00
|
|
|
|
}
|
2021-04-24 04:03:33 +10:00
|
|
|
|
|
2021-04-28 23:58:13 +10:00
|
|
|
|
internal static void SetPanelActive(Transform transform, bool value)
|
|
|
|
|
{
|
|
|
|
|
if (UIPanel.transformToPanelDict.TryGetValue(transform.GetInstanceID(), out UIPanel panel))
|
|
|
|
|
SetPanelActive(panel, value);
|
2021-04-24 04:03:33 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static void InitUI()
|
|
|
|
|
{
|
|
|
|
|
LoadBundle();
|
|
|
|
|
|
|
|
|
|
UIFactory.Init();
|
|
|
|
|
|
|
|
|
|
CreateRootCanvas();
|
2021-04-26 19:56:21 +10:00
|
|
|
|
|
|
|
|
|
PoolHolder = new GameObject("PoolHolder");
|
|
|
|
|
PoolHolder.transform.parent = CanvasRoot.transform;
|
|
|
|
|
PoolHolder.SetActive(false);
|
|
|
|
|
|
2021-04-24 04:03:33 +10:00
|
|
|
|
CreateTopNavBar();
|
|
|
|
|
|
2021-04-30 21:34:50 +10:00
|
|
|
|
//InspectUnderMouse.ConstructUI();
|
|
|
|
|
|
2021-05-11 19:18:27 +10:00
|
|
|
|
AutoCompleter = new AutoCompleteModal();
|
2021-04-24 04:03:33 +10:00
|
|
|
|
AutoCompleter.ConstructUI();
|
|
|
|
|
|
2021-05-09 20:18:33 +10:00
|
|
|
|
Explorer = new ObjectExplorerPanel();
|
2021-04-24 04:03:33 +10:00
|
|
|
|
Explorer.ConstructUI();
|
|
|
|
|
|
2021-04-25 00:21:12 +10:00
|
|
|
|
Inspector = new InspectorPanel();
|
2021-04-24 04:03:33 +10:00
|
|
|
|
Inspector.ConstructUI();
|
|
|
|
|
|
2021-05-09 20:18:33 +10:00
|
|
|
|
CSharpConsole = new CSConsolePanel();
|
|
|
|
|
CSharpConsole.ConstructUI();
|
2021-05-12 20:48:56 +10:00
|
|
|
|
ConsoleController.Init();
|
2021-04-30 21:34:50 +10:00
|
|
|
|
|
2021-05-13 03:55:08 +10:00
|
|
|
|
Options = new OptionsPanel();
|
|
|
|
|
Options.ConstructUI();
|
|
|
|
|
|
|
|
|
|
ConsoleLog = new ConsoleLogPanel();
|
|
|
|
|
ConsoleLog.ConstructUI();
|
|
|
|
|
|
2021-04-24 04:03:33 +10:00
|
|
|
|
ShowMenu = !ConfigManager.Hide_On_Startup.Value;
|
|
|
|
|
|
|
|
|
|
ExplorerCore.Log("UI initialized.");
|
2021-04-29 21:01:08 +10:00
|
|
|
|
Initializing = false;
|
2021-04-24 04:03:33 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
private static void CreateRootCanvas()
|
|
|
|
|
{
|
|
|
|
|
CanvasRoot = new GameObject("ExplorerCanvas");
|
|
|
|
|
UnityEngine.Object.DontDestroyOnLoad(CanvasRoot);
|
|
|
|
|
CanvasRoot.hideFlags |= HideFlags.HideAndDontSave;
|
|
|
|
|
CanvasRoot.layer = 5;
|
|
|
|
|
CanvasRoot.transform.position = new Vector3(0f, 0f, 1f);
|
2020-11-11 20:16:43 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
EventSys = CanvasRoot.AddComponent<EventSystem>();
|
|
|
|
|
InputManager.AddUIModule();
|
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
Canvas = CanvasRoot.AddComponent<Canvas>();
|
|
|
|
|
Canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
|
|
|
|
Canvas.referencePixelsPerUnit = 100;
|
|
|
|
|
Canvas.sortingOrder = 999;
|
2021-03-30 19:50:04 +11:00
|
|
|
|
|
|
|
|
|
CanvasScaler scaler = CanvasRoot.AddComponent<CanvasScaler>();
|
|
|
|
|
scaler.referenceResolution = new Vector2(1920, 1080);
|
|
|
|
|
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand;
|
|
|
|
|
|
|
|
|
|
CanvasRoot.AddComponent<GraphicRaycaster>();
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
|
|
|
|
PanelHolder = new GameObject("PanelHolder");
|
|
|
|
|
PanelHolder.transform.SetParent(CanvasRoot.transform, false);
|
|
|
|
|
PanelHolder.layer = 5;
|
|
|
|
|
var rect = PanelHolder.AddComponent<RectTransform>();
|
|
|
|
|
rect.sizeDelta = Vector2.zero;
|
|
|
|
|
rect.anchoredPosition = Vector2.zero;
|
|
|
|
|
rect.pivot = new Vector2(0.5f, 0.5f);
|
|
|
|
|
rect.anchorMin = Vector2.zero;
|
|
|
|
|
rect.anchorMax = Vector2.one;
|
|
|
|
|
PanelHolder.transform.SetAsFirstSibling();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-03 21:02:01 +10:00
|
|
|
|
//// temp
|
|
|
|
|
//private static float lastTimeSpeed;
|
|
|
|
|
//private static bool pausing;
|
2021-04-28 23:58:13 +10:00
|
|
|
|
|
2021-05-06 04:02:42 +10:00
|
|
|
|
private static Text gcLabel;
|
|
|
|
|
|
2021-04-28 23:58:13 +10:00
|
|
|
|
private static void CreateTopNavBar()
|
2021-04-23 21:50:58 +10:00
|
|
|
|
{
|
2021-04-28 23:58:13 +10:00
|
|
|
|
var navbarPanel = UIFactory.CreateUIObject("MainNavbar", CanvasRoot);
|
|
|
|
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(navbarPanel, false, true, true, true, 5, 4, 4, 4, 4, TextAnchor.MiddleCenter);
|
|
|
|
|
navbarPanel.AddComponent<Image>().color = new Color(0.1f, 0.1f, 0.1f);
|
2021-05-03 21:02:01 +10:00
|
|
|
|
NavBarRect = navbarPanel.GetComponent<RectTransform>();
|
|
|
|
|
NavBarRect.pivot = new Vector2(0.5f, 1f);
|
|
|
|
|
NavBarRect.anchorMin = new Vector2(0.5f, 1f);
|
|
|
|
|
NavBarRect.anchorMax = new Vector2(0.5f, 1f);
|
|
|
|
|
NavBarRect.sizeDelta = new Vector2(900f, 35f);
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
2021-04-28 23:58:13 +10:00
|
|
|
|
// UnityExplorer title
|
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
string titleTxt = $"{ExplorerCore.NAME} <i><color=grey>{ExplorerCore.VERSION}</color></i>";
|
2021-04-28 23:58:13 +10:00
|
|
|
|
var title = UIFactory.CreateLabel(navbarPanel, "Title", titleTxt, TextAnchor.MiddleLeft, default, true, 18);
|
2021-05-03 21:02:01 +10:00
|
|
|
|
UIFactory.SetLayoutElement(title.gameObject, minWidth: 240, flexibleWidth: 0);
|
|
|
|
|
|
2021-05-06 04:02:42 +10:00
|
|
|
|
// temp debug
|
|
|
|
|
|
|
|
|
|
gcLabel = UIFactory.CreateLabel(navbarPanel, "GCLabel", "GC: ", TextAnchor.MiddleLeft);
|
|
|
|
|
UIFactory.SetLayoutElement(gcLabel.gameObject, minWidth: 150, minHeight: 25, flexibleWidth: 0);
|
|
|
|
|
|
2021-05-03 21:02:01 +10:00
|
|
|
|
// TODO something nicer for this, maybe a 'Tools' dropout below the main navbar with a few helpers like this.
|
|
|
|
|
|
|
|
|
|
//var btn = UIFactory.CreateButton(navbarPanel, "Button", "pause", new Color(0.2f, 0.2f, 0.2f));
|
|
|
|
|
//UIFactory.SetLayoutElement(btn.Button.gameObject, minWidth: 30, flexibleWidth: 0, minHeight: 25);
|
|
|
|
|
//btn.OnClick += () =>
|
|
|
|
|
//{
|
|
|
|
|
// if (!pausing)
|
|
|
|
|
// {
|
|
|
|
|
// lastTimeSpeed = Time.timeScale;
|
|
|
|
|
// Time.timeScale = 0;
|
|
|
|
|
// pausing = true;
|
|
|
|
|
// btn.ButtonText.text = "resume";
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// Time.timeScale = lastTimeSpeed;
|
|
|
|
|
// pausing = false;
|
|
|
|
|
// btn.ButtonText.text = "pause";
|
|
|
|
|
// }
|
|
|
|
|
//};
|
2021-04-28 23:58:13 +10:00
|
|
|
|
|
|
|
|
|
// Navbar
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
2021-05-03 21:02:01 +10:00
|
|
|
|
NavbarButtonHolder = UIFactory.CreateUIObject("NavButtonHolder", navbarPanel);
|
|
|
|
|
UIFactory.SetLayoutElement(NavbarButtonHolder, flexibleHeight: 999, flexibleWidth: 999);
|
|
|
|
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(NavbarButtonHolder, true, true, true, true, 4, 2, 2, 2, 2);
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
2021-04-28 23:58:13 +10:00
|
|
|
|
// Hide menu button
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
2021-04-28 23:58:13 +10:00
|
|
|
|
var closeBtn = UIFactory.CreateButton(navbarPanel, "CloseButton", ConfigManager.Main_Menu_Toggle.Value.ToString());
|
2021-05-11 19:18:27 +10:00
|
|
|
|
UIFactory.SetLayoutElement(closeBtn.Component.gameObject, minHeight: 25, minWidth: 80, flexibleWidth: 0);
|
|
|
|
|
RuntimeProvider.Instance.SetColorBlock(closeBtn.Component, new Color(0.63f, 0.32f, 0.31f),
|
2021-04-23 21:50:58 +10:00
|
|
|
|
new Color(0.81f, 0.25f, 0.2f), new Color(0.6f, 0.18f, 0.16f));
|
2021-04-26 19:56:21 +10:00
|
|
|
|
|
2021-04-28 23:58:13 +10:00
|
|
|
|
ConfigManager.Main_Menu_Toggle.OnValueChanged += (KeyCode val) => { closeBtn.ButtonText.text = val.ToString(); };
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
2021-04-28 23:58:13 +10:00
|
|
|
|
closeBtn.OnClick += () => { ShowMenu = false; };
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
#region UI AssetBundle
|
|
|
|
|
|
2021-01-02 19:38:01 +01:00
|
|
|
|
private static void LoadBundle()
|
|
|
|
|
{
|
|
|
|
|
AssetBundle bundle = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
bundle = LoadBundle("modern");
|
2021-03-26 19:49:53 +11:00
|
|
|
|
if (bundle == null)
|
2021-04-15 20:18:03 +10:00
|
|
|
|
bundle = LoadBundle("legacy");
|
2021-01-02 19:38:01 +01:00
|
|
|
|
}
|
2021-04-15 20:18:03 +10:00
|
|
|
|
catch { }
|
2020-11-20 17:12:40 +11:00
|
|
|
|
|
2021-01-02 19:38:01 +01:00
|
|
|
|
if (bundle == null)
|
|
|
|
|
{
|
|
|
|
|
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
|
2021-03-26 19:49:53 +11:00
|
|
|
|
ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
2021-01-02 19:38:01 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2020-11-20 17:12:40 +11:00
|
|
|
|
|
2021-01-02 19:38:01 +01:00
|
|
|
|
BackupShader = bundle.LoadAsset<Shader>("DefaultUI");
|
2020-11-20 17:12:40 +11:00
|
|
|
|
|
2021-01-02 19:38:01 +01:00
|
|
|
|
// Fix for games which don't ship with 'UI/Default' shader.
|
|
|
|
|
if (Graphic.defaultGraphicMaterial.shader?.name != "UI/Default")
|
2020-11-20 17:12:40 +11:00
|
|
|
|
{
|
2021-01-02 19:38:01 +01:00
|
|
|
|
ExplorerCore.Log("This game does not ship with the 'UI/Default' shader, using manual Default Shader...");
|
|
|
|
|
Graphic.defaultGraphicMaterial.shader = BackupShader;
|
2020-11-20 17:12:40 +11:00
|
|
|
|
}
|
2021-04-05 16:28:30 +10:00
|
|
|
|
else
|
|
|
|
|
BackupShader = Graphic.defaultGraphicMaterial.shader;
|
2021-01-02 19:38:01 +01:00
|
|
|
|
|
|
|
|
|
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
|
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
ExplorerCore.Log("Loaded UI AssetBundle");
|
2020-11-20 17:12:40 +11:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
private static AssetBundle LoadBundle(string id)
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
var stream = typeof(ExplorerCore).Assembly
|
2021-04-05 16:28:30 +10:00
|
|
|
|
.GetManifestResourceStream($"UnityExplorer.Resources.explorerui.{id}.bundle");
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
return AssetBundle.LoadFromMemory(ReadFully(stream));
|
2021-03-26 19:49:53 +11:00
|
|
|
|
}
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
private static byte[] ReadFully(Stream input)
|
2021-03-26 19:49:53 +11:00
|
|
|
|
{
|
|
|
|
|
using (var ms = new MemoryStream())
|
|
|
|
|
{
|
|
|
|
|
byte[] buffer = new byte[81920];
|
|
|
|
|
int read;
|
|
|
|
|
while ((read = input.Read(buffer, 0, buffer.Length)) != 0)
|
|
|
|
|
ms.Write(buffer, 0, read);
|
|
|
|
|
return ms.ToArray();
|
|
|
|
|
}
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
|
|
|
|
#endregion
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
}
|