mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-12 02:18:04 +08:00
lots...
* Created a TMP AssetBundle for games which don't have the default TextMeshPro Resources package. This also allows us to use a custom monospace font for the Console and Debug window. * Unstripped the AssetBundle class (just the stuff we need) * Finished Search Page * Finished Options Page (very simple) * Various refactoring and restructuring of the project * cleanups
This commit is contained in:
1 parent
2efc3f6578
commit
d038d13867
25 files changed
+1604
-947
No files matched your search
+67
-30
@@ -2,6 +2,14 @@
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.Inspectors;
|
||||
using UnityExplorer.UI.PageModel;
|
||||
using System.IO;
|
||||
using TMPro;
|
||||
using System.Reflection;
|
||||
using UnityExplorer.Helpers;
|
||||
#if CPP
|
||||
using UnityExplorer.Unstrip.AssetBundle;
|
||||
#endif
|
||||
|
||||
namespace UnityExplorer.UI
|
||||
{
|
||||
@@ -11,19 +19,48 @@ namespace UnityExplorer.UI
|
||||
public static EventSystem EventSys { get; private set; }
|
||||
public static StandaloneInputModule InputModule { get; private set; }
|
||||
|
||||
public static TMP_FontAsset ConsoleFont { get; private set; }
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
var bundlePath = ExplorerCore.EXPLORER_FOLDER + @"\tmp.bundle";
|
||||
if (File.Exists(bundlePath))
|
||||
{
|
||||
var bundle = AssetBundle.LoadFromFile(bundlePath);
|
||||
|
||||
bundle.LoadAllAssets();
|
||||
ExplorerCore.Log("Loaded TMP bundle");
|
||||
|
||||
if (TMP_Settings.instance == null)
|
||||
{
|
||||
var settings = bundle.LoadAsset<TMP_Settings>("TMP Settings");
|
||||
|
||||
#if MONO
|
||||
typeof(TMP_Settings)
|
||||
.GetField("s_Instance", ReflectionHelpers.CommonFlags)
|
||||
.SetValue(null, settings);
|
||||
#else
|
||||
TMP_Settings.s_Instance = settings;
|
||||
#endif
|
||||
}
|
||||
|
||||
ConsoleFont = bundle.LoadAsset<TMP_FontAsset>("CONSOLA SDF");
|
||||
}
|
||||
else if (TMP_Settings.instance == null)
|
||||
{
|
||||
ExplorerCore.LogWarning(@"This game does not seem to have the TMP Resources package, and the TMP AssetBundle was not found at 'Mods\UnityExplorer\tmp.bundle\'!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create core UI Canvas and Event System handler
|
||||
CreateRootCanvas();
|
||||
|
||||
// Create submodules
|
||||
new MainMenu();
|
||||
|
||||
MouseInspector.ConstructUI();
|
||||
|
||||
// Force refresh of anchors
|
||||
Canvas.ForceUpdateCanvases();
|
||||
|
||||
CanvasRoot.SetActive(false);
|
||||
CanvasRoot.SetActive(true);
|
||||
}
|
||||
@@ -34,32 +71,10 @@ namespace UnityExplorer.UI
|
||||
InputModule.ActivateModule();
|
||||
}
|
||||
|
||||
private static GameObject CreateRootCanvas()
|
||||
public static void OnSceneChange()
|
||||
{
|
||||
GameObject rootObj = new GameObject("ExplorerCanvas");
|
||||
UnityEngine.Object.DontDestroyOnLoad(rootObj);
|
||||
rootObj.layer = 5;
|
||||
|
||||
CanvasRoot = rootObj;
|
||||
CanvasRoot.transform.position = new Vector3(0f, 0f, 1f);
|
||||
|
||||
EventSys = rootObj.AddComponent<EventSystem>();
|
||||
InputModule = rootObj.AddComponent<StandaloneInputModule>();
|
||||
InputModule.ActivateModule();
|
||||
|
||||
Canvas canvas = rootObj.AddComponent<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
canvas.referencePixelsPerUnit = 100;
|
||||
canvas.sortingOrder = 999;
|
||||
canvas.pixelPerfect = false;
|
||||
|
||||
CanvasScaler scaler = rootObj.AddComponent<CanvasScaler>();
|
||||
scaler.referenceResolution = new Vector2(1920, 1080);
|
||||
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand;
|
||||
|
||||
rootObj.AddComponent<GraphicRaycaster>();
|
||||
|
||||
return rootObj;
|
||||
SceneExplorer.Instance?.OnSceneChange();
|
||||
SearchPage.Instance?.OnSceneChange();
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
@@ -101,10 +116,32 @@ namespace UnityExplorer.UI
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnSceneChange()
|
||||
private static GameObject CreateRootCanvas()
|
||||
{
|
||||
// todo
|
||||
SceneExplorer.Instance?.OnSceneChange();
|
||||
GameObject rootObj = new GameObject("ExplorerCanvas");
|
||||
UnityEngine.Object.DontDestroyOnLoad(rootObj);
|
||||
rootObj.layer = 5;
|
||||
|
||||
CanvasRoot = rootObj;
|
||||
CanvasRoot.transform.position = new Vector3(0f, 0f, 1f);
|
||||
|
||||
EventSys = rootObj.AddComponent<EventSystem>();
|
||||
InputModule = rootObj.AddComponent<StandaloneInputModule>();
|
||||
InputModule.ActivateModule();
|
||||
|
||||
Canvas canvas = rootObj.AddComponent<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
canvas.referencePixelsPerUnit = 100;
|
||||
canvas.sortingOrder = 999;
|
||||
canvas.pixelPerfect = false;
|
||||
|
||||
CanvasScaler scaler = rootObj.AddComponent<CanvasScaler>();
|
||||
scaler.referenceResolution = new Vector2(1920, 1080);
|
||||
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand;
|
||||
|
||||
rootObj.AddComponent<GraphicRaycaster>();
|
||||
|
||||
return rootObj;
|
||||
}
|
||||
|
||||
public static Sprite CreateSprite(Texture2D tex, Rect size = default)
|
||||
|
||||
Reference in new issue
Block a user