mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 13:57:31 +08:00
A little bit of work on Inspectors, fixed a few issues in Mono/BepInEx builds
This commit is contained in:
parent
b61ac481b9
commit
b5b3e90b09
@ -28,15 +28,15 @@
|
||||
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
|
||||
<MLCppGameFolder>D:\Steam\steamapps\common\VRChat</MLCppGameFolder>
|
||||
<!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. -->
|
||||
<MLMonoGameFolder>D:\Steam\steamapps\common\Outward</MLMonoGameFolder>
|
||||
<MLMonoGameFolder>D:\source\Unity Projects\Test\_BUILD_MONO</MLMonoGameFolder>
|
||||
<!-- Set this to the Mono Managed folder, without the ending '\' character. -->
|
||||
<MLMonoManagedFolder>D:\Steam\steamapps\common\Outward\Outward_Data\Managed</MLMonoManagedFolder>
|
||||
<MLMonoManagedFolder>D:\source\Unity Projects\Test\_BUILD_MONO\Test_Data\Managed</MLMonoManagedFolder>
|
||||
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->
|
||||
<BIECppGameFolder>D:\Steam\steamapps\common\Outward_Il2Cpp</BIECppGameFolder>
|
||||
<!-- Set this to the BepInEx Mono Game folder, without the ending '\' character. -->
|
||||
<BIEMonoGameFolder>D:\Steam\steamapps\common\Outward</BIEMonoGameFolder>
|
||||
<BIEMonoGameFolder>D:\source\Unity Projects\Test\_BUILD_MONO</BIEMonoGameFolder>
|
||||
<!-- Set this to the BepInEx Managed folder, without the ending '\' character. -->
|
||||
<BIEMonoManagedFolder>D:\Steam\steamapps\common\Outward\Outward_Data\Managed</BIEMonoManagedFolder>
|
||||
<BIEMonoManagedFolder>D:\source\Unity Projects\Test\_BUILD_MONO\Test_Data\Managed</BIEMonoManagedFolder>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
@ -49,7 +49,7 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_ML_Mono|AnyCPU' ">
|
||||
<!-- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> -->
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<OutputPath>..\Release\Explorer.MelonLoader.Mono\</OutputPath>
|
||||
<DefineConstants>MONO,ML</DefineConstants>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
@ -66,7 +66,7 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_BIE_Mono|AnyCPU' ">
|
||||
<!-- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> -->
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<OutputPath>..\Release\Explorer.BepInEx.Mono\</OutputPath>
|
||||
<DefineConstants>MONO,BIE</DefineConstants>
|
||||
<IsCpp>false</IsCpp>
|
||||
@ -108,6 +108,10 @@
|
||||
<HintPath>$(MLMonoGameFolder)\MelonLoader\MelonLoader.ModHandler.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<!--<Reference Include="netstandard">
|
||||
<HintPath>$(MLMonoManagedFolder)\netstandard.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>-->
|
||||
<Reference Include="Unity.TextMeshPro">
|
||||
<HintPath>$(MLMonoManagedFolder)\Unity.TextMeshPro.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
@ -159,6 +163,10 @@
|
||||
<HintPath>$(BIEMonoGameFolder)\BepInEx\core\0Harmony.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<!--<Reference Include="netstandard">
|
||||
<HintPath>$(BIEMonoManagedFolder)\netstandard.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>-->
|
||||
<Reference Include="Unity.TextMeshPro">
|
||||
<HintPath>$(BIEMonoManagedFolder)\Unity.TextMeshPro.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
|
@ -12,9 +12,9 @@ using UnhollowerRuntimeLib;
|
||||
using BepInEx.IL2CPP;
|
||||
#endif
|
||||
|
||||
namespace Explorer
|
||||
namespace ExplorerBeta
|
||||
{
|
||||
[BepInPlugin(ExplorerCore.GUID, "Explorer", ExplorerCore.VERSION)]
|
||||
[BepInPlugin(ExplorerCore.GUID, "ExplorerBeta", ExplorerCore.VERSION)]
|
||||
#if CPP
|
||||
public class ExplorerBepInPlugin : BasePlugin
|
||||
#else
|
||||
@ -64,7 +64,7 @@ namespace Explorer
|
||||
|
||||
new ExplorerCore();
|
||||
|
||||
//HarmonyInstance.PatchAll();
|
||||
// HarmonyInstance.PatchAll();
|
||||
}
|
||||
|
||||
internal static void DoSceneChange(Scene arg0, Scene arg1)
|
||||
@ -96,11 +96,6 @@ namespace Explorer
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
ExplorerCore.OnGUI();
|
||||
}
|
||||
#if CPP
|
||||
}
|
||||
#endif
|
||||
|
@ -10,9 +10,9 @@ namespace ExplorerBeta
|
||||
public class ExplorerCore
|
||||
{
|
||||
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
|
||||
public const string VERSION = "3.0.0b";
|
||||
public const string VERSION = "3.0.0";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.explorer";
|
||||
public const string GUID = "com.sinai.explorerBETA";
|
||||
|
||||
public const string PLATFORM =
|
||||
#if CPP
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
#if CPP
|
||||
using ExplorerBeta.Unstrip.ImageConversion;
|
||||
#endif
|
||||
|
@ -38,47 +38,5 @@ namespace ExplorerBeta.Input
|
||||
|
||||
public static bool GetMouseButtonDown(int btn) => m_inputModule.GetMouseButtonDown(btn);
|
||||
public static bool GetMouseButton(int btn) => m_inputModule.GetMouseButton(btn);
|
||||
|
||||
#if CPP
|
||||
internal delegate void d_ResetInputAxes();
|
||||
public static void ResetInputAxes() => ICallHelper.GetICall<d_ResetInputAxes>("UnityEngine.Input::ResetInputAxes").Invoke();
|
||||
#else
|
||||
public static void ResetInputAxes() => UnityEngine.Input.ResetInputAxes();
|
||||
#endif
|
||||
|
||||
#if CPP
|
||||
// public extern static string compositionString { get; }
|
||||
|
||||
internal delegate IntPtr d_get_compositionString();
|
||||
|
||||
public static string compositionString
|
||||
{
|
||||
get
|
||||
{
|
||||
var iCall = ICallHelper.GetICall<d_get_compositionString>("UnityEngine.Input::get_compositionString");
|
||||
return IL2CPP.Il2CppStringToManaged(iCall.Invoke());
|
||||
}
|
||||
}
|
||||
|
||||
// public extern static Vector2 compositionCursorPos { get; set; }
|
||||
|
||||
internal delegate void d_get_compositionCursorPos(out Vector2 ret);
|
||||
internal delegate void d_set_compositionCursorPos(ref Vector2 value);
|
||||
|
||||
public static Vector2 compositionCursorPos
|
||||
{
|
||||
get
|
||||
{
|
||||
var iCall = ICallHelper.GetICall<d_get_compositionCursorPos>("UnityEngine.Input::get_compositionCursorPos_Injected");
|
||||
iCall.Invoke(out Vector2 ret);
|
||||
return ret;
|
||||
}
|
||||
set
|
||||
{
|
||||
var iCall = ICallHelper.GetICall<d_set_compositionCursorPos>("UnityEngine.Input::set_compositionCursorPos_Injected");
|
||||
iCall.Invoke(ref value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@ -82,7 +82,7 @@ namespace ExplorerBeta.UI
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance harmony =
|
||||
var harmony =
|
||||
#if ML
|
||||
ExplorerMelonMod.Instance.harmonyInstance;
|
||||
#else
|
||||
@ -103,10 +103,10 @@ namespace ExplorerBeta.UI
|
||||
harmony.Patch(prop.GetGetMethod(), postfix: patch);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch // (Exception e)
|
||||
{
|
||||
string suf = setter ? "set_" : "get_";
|
||||
ExplorerCore.Log($"Unable to patch {type.Name}.{suf}{property}: {e.Message}");
|
||||
//string suf = setter ? "set_" : "get_";
|
||||
//ExplorerCore.Log($"Unable to patch {type.Name}.{suf}{property}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,8 @@ namespace ExplorerBeta.UI.Main.Console
|
||||
throw new Exception("References are missing!");
|
||||
}
|
||||
|
||||
InputField.restoreOriginalTextOnEscape = false;
|
||||
|
||||
inputTextTransform = inputText.GetComponent<RectTransform>();
|
||||
lineHighlightTransform = lineHighlight.GetComponent<RectTransform>();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using ExplorerBeta.UI.Main.Console;
|
||||
using ExplorerBeta.Unstrip.Resources;
|
||||
|
@ -237,7 +237,7 @@ namespace ExplorerBeta.UI.Main
|
||||
#if CPP
|
||||
unityToggle.onValueChanged.AddListener(new Action<bool>((bool val) => { LogUnity = val; }));
|
||||
#else
|
||||
unityToggle.onValueChanged.AddListener((bool val) => { LogUnity = val; }));
|
||||
unityToggle.onValueChanged.AddListener((bool val) => { LogUnity = val; });
|
||||
#endif
|
||||
unityToggleText.text = "Print Unity Debug?";
|
||||
unityToggleText.alignment = TextAnchor.MiddleLeft;
|
||||
|
@ -18,6 +18,10 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
ConstructMenu();
|
||||
|
||||
new SceneExplorer();
|
||||
|
||||
new InspectorManager();
|
||||
|
||||
SceneExplorer.Instance.Init();
|
||||
}
|
||||
|
||||
@ -42,12 +46,6 @@ namespace ExplorerBeta.UI.Main
|
||||
mainGroup.childForceExpandWidth = true;
|
||||
mainGroup.childControlHeight = true;
|
||||
mainGroup.childControlWidth = true;
|
||||
|
||||
new SceneExplorer();
|
||||
SceneExplorer.Instance.ConstructScenePane();
|
||||
|
||||
new InspectorManager();
|
||||
InspectorManager.Instance.ConstructInspectorPane();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,11 @@ namespace ExplorerBeta.UI.Main
|
||||
{
|
||||
public static InspectorManager Instance { get; private set; }
|
||||
|
||||
public InspectorManager() { Instance = this; }
|
||||
public InspectorManager()
|
||||
{
|
||||
Instance = this;
|
||||
ConstructInspectorPane();
|
||||
}
|
||||
|
||||
public InspectorBase m_activeInspector;
|
||||
public readonly List<InspectorBase> m_currentInspectors = new List<InspectorBase>();
|
||||
@ -76,7 +80,7 @@ namespace ExplorerBeta.UI.Main
|
||||
}
|
||||
|
||||
m_currentInspectors.Add(inspector);
|
||||
inspector.inspectorContent?.SetActive(false);
|
||||
inspector.Content?.SetActive(false);
|
||||
|
||||
SetInspectorTab(inspector);
|
||||
}
|
||||
@ -92,7 +96,7 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
m_activeInspector = inspector;
|
||||
|
||||
m_activeInspector.inspectorContent?.SetActive(true);
|
||||
m_activeInspector.Content?.SetActive(true);
|
||||
|
||||
Color activeColor = new Color(0, 0.25f, 0, 1);
|
||||
ColorBlock colors = inspector.tabButton.colors;
|
||||
@ -108,7 +112,7 @@ namespace ExplorerBeta.UI.Main
|
||||
return;
|
||||
}
|
||||
|
||||
m_activeInspector.inspectorContent?.SetActive(false);
|
||||
m_activeInspector.Content?.SetActive(false);
|
||||
|
||||
ColorBlock colors = m_activeInspector.tabButton.colors;
|
||||
colors.normalColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Inspectors
|
||||
{
|
||||
@ -15,6 +16,12 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
{
|
||||
TargetGO = target;
|
||||
|
||||
if (!TargetGO)
|
||||
{
|
||||
ExplorerCore.LogWarning("GameObjectInspector cctor: Target GameObject is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
ConstructUI();
|
||||
}
|
||||
|
||||
@ -34,7 +41,36 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
|
||||
private void ConstructUI()
|
||||
{
|
||||
// todo create gameobject inspector pane
|
||||
var parent = InspectorManager.Instance.m_inspectorContent;
|
||||
|
||||
this.Content = UIFactory.CreateScrollView(parent, out GameObject scrollContent, new Color(0.1f, 0.1f, 0.1f, 1));
|
||||
|
||||
var nameObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||
var nameText = nameObj.GetComponent<Text>();
|
||||
nameText.text = TargetGO.name;
|
||||
nameText.fontSize = 18;
|
||||
|
||||
var childListObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||
var childListText = childListObj.GetComponent<Text>();
|
||||
childListText.text = "Children:";
|
||||
|
||||
foreach (Transform child in TargetGO.transform)
|
||||
{
|
||||
var childLabelObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||
var childLabelText = childLabelObj.GetComponent<Text>();
|
||||
childLabelText.text = " - " + child.name;
|
||||
}
|
||||
|
||||
var compListObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||
var compListText = compListObj.GetComponent<Text>();
|
||||
compListText.text = "Components:";
|
||||
|
||||
foreach (var comp in TargetGO.GetComponents<Component>())
|
||||
{
|
||||
var compLabelObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||
var compText = compLabelObj.GetComponent<Text>();
|
||||
compText.text = " - " + comp.GetType().Name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
|
||||
public abstract string TabLabel { get; }
|
||||
|
||||
public GameObject inspectorContent;
|
||||
public GameObject Content;
|
||||
public Button tabButton;
|
||||
public Text tabText;
|
||||
|
||||
@ -54,9 +54,9 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
GameObject.Destroy(tabGroup);
|
||||
}
|
||||
|
||||
if (inspectorContent)
|
||||
if (Content)
|
||||
{
|
||||
GameObject.Destroy(inspectorContent);
|
||||
GameObject.Destroy(Content);
|
||||
}
|
||||
|
||||
if (ReferenceEquals(InspectorManager.Instance.m_activeInspector, this))
|
||||
@ -121,8 +121,11 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
tabText.alignment = TextAnchor.MiddleLeft;
|
||||
|
||||
tabButton = targetButtonObj.GetComponent<Button>();
|
||||
#if CPP
|
||||
tabButton.onClick.AddListener(new Action(() => { InspectorManager.Instance.SetInspectorTab(this); }));
|
||||
|
||||
#else
|
||||
tabButton.onClick.AddListener(() => { InspectorManager.Instance.SetInspectorTab(this); });
|
||||
#endif
|
||||
var closeBtnObj = UIFactory.CreateButton(tabGroupObj);
|
||||
var closeBtnLayout = closeBtnObj.AddComponent<LayoutElement>();
|
||||
closeBtnLayout.minWidth = 20;
|
||||
@ -132,12 +135,17 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
closeBtnText.color = new Color(1, 0, 0, 1);
|
||||
|
||||
var closeBtn = closeBtnObj.GetComponent<Button>();
|
||||
#if CPP
|
||||
closeBtn.onClick.AddListener(new Action(() => { Destroy(); }));
|
||||
#else
|
||||
closeBtn.onClick.AddListener(() => { Destroy(); });
|
||||
#endif
|
||||
|
||||
var closeColors = closeBtn.colors;
|
||||
closeColors.normalColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
||||
closeBtn.colors = closeColors;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
// Navbar buttons
|
||||
private Button m_lastNavButtonPressed;
|
||||
private readonly Color m_navButtonNormal = new Color(65f / 255f, 66f / 255f, 66f / 255f);
|
||||
private readonly Color m_navButtonHighlight = new Color(50f / 255f, 195f / 255f, 50f / 255f);
|
||||
private readonly Color m_navButtonSelected = new Color(60f / 255f, 120f / 255f, 60f / 255f);
|
||||
private readonly Color m_navButtonNormal = new Color(0.3f, 0.3f, 0.3f, 1);
|
||||
private readonly Color m_navButtonHighlight = new Color(0.3f, 0.6f, 0.3f);
|
||||
private readonly Color m_navButtonSelected = new Color(0.2f, 0.5f, 0.2f, 1);
|
||||
|
||||
public MainMenu()
|
||||
{
|
||||
@ -84,7 +84,7 @@ namespace ExplorerBeta.UI.Main
|
||||
m_activePage?.Content?.SetActive(false);
|
||||
if (m_activePage is ConsolePage)
|
||||
{
|
||||
AutoCompleter.m_mainObj.SetActive(false);
|
||||
AutoCompleter.m_mainObj?.SetActive(false);
|
||||
}
|
||||
|
||||
m_activePage = page;
|
||||
@ -109,12 +109,6 @@ namespace ExplorerBeta.UI.Main
|
||||
m_lastNavButtonPressed = button;
|
||||
}
|
||||
|
||||
#region UI Interaction Callbacks
|
||||
|
||||
// ... none needed yet
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI Construction
|
||||
|
||||
private void ConstructMenu()
|
||||
|
@ -18,6 +18,8 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
public RectTransform Panel { get; set; }
|
||||
|
||||
private static bool s_loadedCursorImage;
|
||||
|
||||
public PanelDragger(RectTransform dragArea, RectTransform panelToDrag)
|
||||
{
|
||||
Instance = this;
|
||||
@ -25,15 +27,6 @@ namespace ExplorerBeta.UI.Main
|
||||
Panel = panelToDrag;
|
||||
|
||||
UpdateResizeCache();
|
||||
|
||||
try
|
||||
{
|
||||
LoadCursorImage();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ExplorerCore.Log("Exception loading resize cursor: " + e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
@ -44,7 +37,7 @@ namespace ExplorerBeta.UI.Main
|
||||
Vector3 resizePos = Panel.InverseTransformPoint(rawMousePos);
|
||||
Vector3 dragPos = DragableArea.InverseTransformPoint(rawMousePos);
|
||||
|
||||
if (WasHoveringResize)
|
||||
if (WasHoveringResize && m_resizeCursorImage)
|
||||
{
|
||||
UpdateHoverImagePos();
|
||||
}
|
||||
@ -144,7 +137,7 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
private bool WasHoveringResize { get; set; }
|
||||
private ResizeTypes m_lastResizeHoverType;
|
||||
private GameObject m_resizeCursorImage;
|
||||
public GameObject m_resizeCursorImage;
|
||||
|
||||
private Rect m_resizeRect;
|
||||
|
||||
@ -238,12 +231,16 @@ namespace ExplorerBeta.UI.Main
|
||||
return;
|
||||
}
|
||||
|
||||
if (!s_loadedCursorImage)
|
||||
LoadCursorImage();
|
||||
|
||||
// we are entering resize, or the resize type has changed.
|
||||
|
||||
WasHoveringResize = true;
|
||||
m_lastResizeHoverType = resizeType;
|
||||
|
||||
m_resizeCursorImage.SetActive(true);
|
||||
ExplorerCore.Log("Set image active.");
|
||||
|
||||
// set the rotation for the resize icon
|
||||
float iconRotation = 0f;
|
||||
@ -270,11 +267,6 @@ namespace ExplorerBeta.UI.Main
|
||||
// update the resize icon position to be above the mouse
|
||||
private void UpdateHoverImagePos()
|
||||
{
|
||||
if (!m_resizeCursorImage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RectTransform t = UIManager.CanvasRoot.GetComponent<RectTransform>();
|
||||
m_resizeCursorImage.transform.localPosition = t.InverseTransformPoint(InputManager.MousePosition);
|
||||
}
|
||||
@ -336,26 +328,35 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
private void LoadCursorImage()
|
||||
{
|
||||
string path = @"Mods\Explorer\cursor.png";
|
||||
byte[] data = File.ReadAllBytes(path);
|
||||
try
|
||||
{
|
||||
string path = @"Mods\Explorer\cursor.png";
|
||||
byte[] data = File.ReadAllBytes(path);
|
||||
|
||||
Texture2D tex = new Texture2D(32, 32);
|
||||
tex.LoadImage(data, false);
|
||||
UnityEngine.Object.DontDestroyOnLoad(tex);
|
||||
Texture2D tex = new Texture2D(32, 32);
|
||||
tex.LoadImage(data, false);
|
||||
UnityEngine.Object.DontDestroyOnLoad(tex);
|
||||
|
||||
Sprite sprite = UIManager.CreateSprite(tex);
|
||||
UnityEngine.Object.DontDestroyOnLoad(sprite);
|
||||
Sprite sprite = UIManager.CreateSprite(tex, new Rect(0, 0, 32, 32));
|
||||
UnityEngine.Object.DontDestroyOnLoad(sprite);
|
||||
|
||||
m_resizeCursorImage = new GameObject("ResizeCursorImage");
|
||||
m_resizeCursorImage.transform.SetParent(UIManager.CanvasRoot.transform);
|
||||
m_resizeCursorImage = new GameObject("ResizeCursorImage");
|
||||
m_resizeCursorImage.transform.SetParent(UIManager.CanvasRoot.transform);
|
||||
|
||||
Image image = m_resizeCursorImage.AddComponent<Image>();
|
||||
image.sprite = sprite;
|
||||
RectTransform rect = image.transform.GetComponent<RectTransform>();
|
||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 32);
|
||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 32);
|
||||
Image image = m_resizeCursorImage.AddComponent<Image>();
|
||||
image.sprite = sprite;
|
||||
RectTransform rect = image.transform.GetComponent<RectTransform>();
|
||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 32);
|
||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 32);
|
||||
|
||||
m_resizeCursorImage.SetActive(false);
|
||||
//m_resizeCursorImage.SetActive(false);
|
||||
|
||||
s_loadedCursorImage = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ExplorerCore.LogWarning("Exception loading cursor image!\r\n" + e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -4,10 +4,10 @@ using System.Linq;
|
||||
using ExplorerBeta.Helpers;
|
||||
using ExplorerBeta.UI.Main.Inspectors;
|
||||
using ExplorerBeta.UI.Shared;
|
||||
using ExplorerBeta.Unstrip.Scenes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using ExplorerBeta.Unstrip.Scenes;
|
||||
|
||||
namespace ExplorerBeta.UI.Main
|
||||
{
|
||||
@ -15,14 +15,17 @@ namespace ExplorerBeta.UI.Main
|
||||
{
|
||||
public static SceneExplorer Instance;
|
||||
|
||||
public SceneExplorer() { Instance = this; }
|
||||
public SceneExplorer()
|
||||
{
|
||||
Instance = this;
|
||||
ConstructScenePane();
|
||||
}
|
||||
|
||||
private const float UPDATE_INTERVAL = 1f;
|
||||
private float m_timeOfLastSceneUpdate;
|
||||
|
||||
private bool m_doneFirstSceneRefresh;
|
||||
private GameObject m_selectedSceneObject;
|
||||
private int m_currentSceneHandle;
|
||||
private int m_currentSceneHandle = -1;
|
||||
private int m_lastCount;
|
||||
|
||||
public PageHandler m_sceneListPageHandler;
|
||||
@ -30,22 +33,23 @@ namespace ExplorerBeta.UI.Main
|
||||
private GameObject[] m_allSceneListObjects = new GameObject[0];
|
||||
private readonly List<GameObject> m_sceneShortList = new List<GameObject>();
|
||||
private readonly List<Text> m_sceneListTexts = new List<Text>();
|
||||
private readonly List<bool> m_sceneListActiveStates = new List<bool>();
|
||||
|
||||
public static int DontDestroyHandle;
|
||||
|
||||
private GameObject m_sceneListCanvas;
|
||||
private Dropdown m_sceneDropdown;
|
||||
private Text m_scenePathText;
|
||||
private GameObject m_mainInspectBtn;
|
||||
private GameObject m_backButtonObj;
|
||||
|
||||
private readonly Dictionary<string, int> m_sceneHandles = new Dictionary<string, int>();
|
||||
//private readonly Dictionary<string, int> m_sceneHandles = new Dictionary<string, int>();
|
||||
|
||||
public void Init()
|
||||
{
|
||||
// Get DontDestroyOnLoad scene handle. I think it's always -12, but best to be safe.
|
||||
GameObject test = new GameObject();
|
||||
GameObject.DontDestroyOnLoad(test);
|
||||
StoreScenehandle(test.scene);
|
||||
DontDestroyHandle = test.scene.handle;
|
||||
GameObject.Destroy(test);
|
||||
|
||||
RefreshActiveScenes();
|
||||
@ -73,70 +77,62 @@ namespace ExplorerBeta.UI.Main
|
||||
}
|
||||
}
|
||||
|
||||
private int StoreScenehandle(Scene scene)
|
||||
{
|
||||
if (!m_sceneHandles.ContainsKey(scene.name))
|
||||
{
|
||||
m_sceneHandles.Add(scene.name, scene.handle);
|
||||
}
|
||||
return scene.handle;
|
||||
}
|
||||
//private int StoreScenehandle(Scene scene)
|
||||
//{
|
||||
// if (scene == null || scene.handle == -1)
|
||||
// return -1;
|
||||
|
||||
private int GetSceneHandle(string sceneName)
|
||||
// if (!m_sceneHandles.ContainsKey(scene.name))
|
||||
// {
|
||||
// m_sceneHandles.Add(scene.name, scene.handle);
|
||||
// }
|
||||
// return scene.handle;
|
||||
//}
|
||||
|
||||
public int GetSceneHandle(string sceneName)
|
||||
{
|
||||
if (!m_sceneHandles.ContainsKey(sceneName))
|
||||
if (sceneName == "DontDestroyOnLoad")
|
||||
return DontDestroyHandle;
|
||||
|
||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_sceneHandles[sceneName];
|
||||
var scene = SceneManager.GetSceneAt(i);
|
||||
if (scene.name == sceneName)
|
||||
return scene.handle;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
internal void OnSceneChange()
|
||||
{
|
||||
m_doneFirstSceneRefresh = false;
|
||||
m_sceneDropdown.OnCancel(null);
|
||||
RefreshActiveScenes();
|
||||
}
|
||||
|
||||
private void RefreshActiveScenes()
|
||||
{
|
||||
string mainActiveScene = SceneManager.GetActiveScene().name;
|
||||
List<string> otherScenes = new List<string>();
|
||||
List<int> validHandles = new List<int>();
|
||||
var names = new List<string>();
|
||||
var handles = new List<int>();
|
||||
|
||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||
{
|
||||
Scene scene = SceneManager.GetSceneAt(i);
|
||||
|
||||
if (scene == null || string.IsNullOrEmpty(scene.name))
|
||||
{
|
||||
int handle = scene.handle;
|
||||
|
||||
if (scene == null || handle == -1 || string.IsNullOrEmpty(scene.name))
|
||||
continue;
|
||||
}
|
||||
|
||||
StoreScenehandle(scene);
|
||||
validHandles.Add(scene.handle);
|
||||
|
||||
if (m_doneFirstSceneRefresh || scene.name != mainActiveScene)
|
||||
{
|
||||
otherScenes.Add(scene.name);
|
||||
}
|
||||
handles.Add(handle);
|
||||
names.Add(scene.name);
|
||||
}
|
||||
otherScenes.Add("DontDestroyOnLoad");
|
||||
validHandles.Add(GetSceneHandle("DontDestroyOnLoad"));
|
||||
|
||||
names.Add("DontDestroyOnLoad");
|
||||
handles.Add(DontDestroyHandle);
|
||||
|
||||
m_sceneDropdown.options.Clear();
|
||||
|
||||
if (!m_doneFirstSceneRefresh)
|
||||
{
|
||||
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
||||
{
|
||||
text = mainActiveScene
|
||||
});
|
||||
}
|
||||
|
||||
foreach (string scene in otherScenes)
|
||||
foreach (string scene in names)
|
||||
{
|
||||
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
||||
{
|
||||
@ -144,12 +140,12 @@ namespace ExplorerBeta.UI.Main
|
||||
});
|
||||
}
|
||||
|
||||
if (!m_doneFirstSceneRefresh || !validHandles.Contains(m_currentSceneHandle))
|
||||
if (!handles.Contains(m_currentSceneHandle))
|
||||
{
|
||||
SetScene(mainActiveScene);
|
||||
ExplorerCore.Log("Reverting to default scene");
|
||||
m_sceneDropdown.transform.Find("Label").GetComponent<Text>().text = names[0];
|
||||
SetScene(handles[0]);
|
||||
}
|
||||
|
||||
m_doneFirstSceneRefresh = true;
|
||||
}
|
||||
|
||||
public void SetScene(string name) => SetScene(GetSceneHandle(name));
|
||||
@ -157,9 +153,7 @@ namespace ExplorerBeta.UI.Main
|
||||
public void SetScene(int handle)
|
||||
{
|
||||
if (handle == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_currentSceneHandle = handle;
|
||||
|
||||
@ -235,24 +229,14 @@ namespace ExplorerBeta.UI.Main
|
||||
{
|
||||
newCount++;
|
||||
|
||||
// still updating from gameobject list.
|
||||
// check first if the reference has changed for this index.
|
||||
|
||||
if (i + startIndex >= objects.Length)
|
||||
{
|
||||
// execeeded actual list, but not yet reached previous limit.
|
||||
// disable remaining buttons.
|
||||
|
||||
if (i > m_lastCount || i >= m_sceneListTexts.Count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
GameObject obj = m_sceneListTexts[i].transform.parent.parent.gameObject;
|
||||
if (obj.activeSelf)
|
||||
{
|
||||
obj.SetActive(false);
|
||||
}
|
||||
GameObject label = m_sceneListTexts[i].transform.parent.parent.gameObject;
|
||||
if (label.activeSelf)
|
||||
label.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -261,24 +245,27 @@ namespace ExplorerBeta.UI.Main
|
||||
if (i >= m_sceneShortList.Count)
|
||||
{
|
||||
m_sceneShortList.Add(obj);
|
||||
if (i >= m_sceneListTexts.Count)
|
||||
{
|
||||
AddSceneButton();
|
||||
m_sceneListActiveStates.Add(obj.activeSelf);
|
||||
}
|
||||
AddSceneButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sceneShortList[i] = obj;
|
||||
}
|
||||
|
||||
m_sceneListTexts[i].text = obj.name;
|
||||
m_sceneListTexts[i].color = obj.activeSelf ? Color.green : Color.red;
|
||||
var text = m_sceneListTexts[i];
|
||||
|
||||
GameObject parent = m_sceneListTexts[i].transform.parent.parent.gameObject;
|
||||
if (!parent.activeSelf)
|
||||
var name = obj.name;
|
||||
|
||||
if (obj.transform.childCount > 0)
|
||||
name = $"<color=grey>[{obj.transform.childCount}]</color> {name}";
|
||||
|
||||
text.text = name;
|
||||
text.color = obj.activeSelf ? Color.green : Color.red;
|
||||
|
||||
var label = text.transform.parent.parent.gameObject;
|
||||
if (!label.activeSelf)
|
||||
{
|
||||
parent.SetActive(true);
|
||||
label.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -401,8 +388,12 @@ namespace ExplorerBeta.UI.Main
|
||||
inspectButtonLayout.minWidth = 65;
|
||||
inspectButtonLayout.flexibleWidth = 0;
|
||||
Button inspectButton = m_mainInspectBtn.GetComponent<Button>();
|
||||
#if CPP
|
||||
inspectButton.onClick.AddListener(new Action(() => { InspectorManager.Instance.Inspect(m_selectedSceneObject); }));
|
||||
|
||||
#else
|
||||
inspectButton.onClick.AddListener(() => { InspectorManager.Instance.Inspect(m_selectedSceneObject); });
|
||||
#endif
|
||||
GameObject scrollObj = UIFactory.CreateScrollView(leftPane, out m_sceneListCanvas, new Color(0.1f, 0.1f, 0.1f));
|
||||
Scrollbar scroll = scrollObj.transform.Find("Scrollbar Vertical").GetComponent<Scrollbar>();
|
||||
ColorBlock colors = scroll.colors;
|
||||
@ -448,7 +439,7 @@ namespace ExplorerBeta.UI.Main
|
||||
#if CPP
|
||||
mainBtn.onClick.AddListener(new Action(() => { SceneListObjectClicked(thisIndex); }));
|
||||
#else
|
||||
btn.onClick.AddListener(() => { SceneButtonClicked(thisIndex); });
|
||||
mainBtn.onClick.AddListener(() => { SceneListObjectClicked(thisIndex); });
|
||||
#endif
|
||||
|
||||
Text mainText = mainButtonObj.GetComponentInChildren<Text>();
|
||||
@ -470,9 +461,13 @@ namespace ExplorerBeta.UI.Main
|
||||
inspectColors.normalColor = new Color(0.15f, 0.15f, 0.15f);
|
||||
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 0.5f);
|
||||
inspectBtn.colors = inspectColors;
|
||||
#if CPP
|
||||
inspectBtn.onClick.AddListener(new Action(() => { InspectorManager.Instance.Inspect(m_sceneShortList[thisIndex]); }));
|
||||
#else
|
||||
inspectBtn.onClick.AddListener(() => { InspectorManager.Instance.Inspect(m_sceneShortList[thisIndex]); });
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -547,14 +547,14 @@ namespace ExplorerBeta.UI
|
||||
itemLabelText.alignment = TextAnchor.MiddleLeft;
|
||||
|
||||
Image itemBgImage = itemBgObj.AddComponent<Image>();
|
||||
itemBgImage.color = new Color(0.35f, 0.35f, 0.35f, 1.0f);
|
||||
itemBgImage.color = new Color(0.25f, 0.45f, 0.25f, 1.0f);
|
||||
|
||||
Toggle itemToggle = itemObj.AddComponent<Toggle>();
|
||||
itemToggle.targetGraphic = itemBgImage;
|
||||
itemToggle.isOn = true;
|
||||
ColorBlock colors = itemToggle.colors;
|
||||
colors.normalColor = new Color(0.35f, 0.35f, 0.35f, 1.0f);
|
||||
colors.highlightedColor = new Color(0.35f, 0.65f, 0.35f, 1.0f);
|
||||
colors.highlightedColor = new Color(0.25f, 0.45f, 0.25f, 1.0f);
|
||||
itemToggle.colors = colors;
|
||||
|
||||
#if CPP
|
||||
@ -609,7 +609,7 @@ namespace ExplorerBeta.UI
|
||||
labelRect.anchorMin = Vector2.zero;
|
||||
labelRect.anchorMax = Vector2.one;
|
||||
labelRect.offsetMin = new Vector2(10f, 6f);
|
||||
labelRect.offsetMax = new Vector2(-25f, -7f);
|
||||
labelRect.offsetMax = new Vector2(-28f, -7f);
|
||||
|
||||
RectTransform templateRect = templateObj.GetComponent<RectTransform>();
|
||||
templateRect.anchorMin = new Vector2(0f, 0f);
|
||||
@ -634,7 +634,7 @@ namespace ExplorerBeta.UI
|
||||
RectTransform itemRect = itemObj.GetComponent<RectTransform>();
|
||||
itemRect.anchorMin = new Vector2(0f, 0.5f);
|
||||
itemRect.anchorMax = new Vector2(1f, 0.5f);
|
||||
itemRect.sizeDelta = new Vector2(0f, 20f);
|
||||
itemRect.sizeDelta = new Vector2(0f, 25f);
|
||||
|
||||
RectTransform itemBgRect = itemBgObj.GetComponent<RectTransform>();
|
||||
itemBgRect.anchorMin = Vector2.zero;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityEngine;
|
||||
#if CPP
|
||||
using UnhollowerBaseLib;
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
#if CPP
|
||||
using System;
|
||||
using System;
|
||||
using ExplorerBeta.Helpers;
|
||||
using ExplorerBeta.UI.Main;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@ -8,8 +8,22 @@ namespace ExplorerBeta.Unstrip.Scenes
|
||||
{
|
||||
public class SceneUnstrip
|
||||
{
|
||||
public static GameObject[] GetRootGameObjects(Scene scene) => scene.GetRootGameObjects();
|
||||
|
||||
public static GameObject[] GetRootGameObjects(int handle)
|
||||
{
|
||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||
{
|
||||
var scene = SceneManager.GetSceneAt(i);
|
||||
if (scene.handle == handle)
|
||||
return scene.GetRootGameObjects();
|
||||
}
|
||||
return new GameObject[0];
|
||||
}
|
||||
|
||||
//Scene.GetRootGameObjects();
|
||||
|
||||
#if CPP
|
||||
internal delegate void d_GetRootGameObjects(int handle, IntPtr list);
|
||||
|
||||
public static GameObject[] GetRootGameObjects(Scene scene) => GetRootGameObjects(scene.handle);
|
||||
@ -41,6 +55,6 @@ namespace ExplorerBeta.Unstrip.Scenes
|
||||
GetRootCountInternal_delegate iCall = ICallHelper.GetICall<GetRootCountInternal_delegate>("UnityEngine.SceneManagement.Scene::GetRootCountInternal");
|
||||
return iCall.Invoke(handle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user