mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-24 01:12:41 +08:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
8f025622b4 | |||
89f137680e | |||
f280b45ed3 | |||
456e15020f | |||
d33d46927d | |||
7a872cecf9 |
23
README.md
23
README.md
@ -5,25 +5,16 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
An in-game explorer and a suite of debugging tools for <a href="https://docs.unity3d.com/Manual/IL2CPP.html">IL2CPP</a> and <b>Mono</b> Unity games, to aid with modding development.
|
An in-game explorer and a suite of debugging tools for <a href="https://docs.unity3d.com/Manual/IL2CPP.html">IL2CPP</a> and <b>Mono</b> Unity games, to aid with modding development.
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
|
||||||
<a href="../../releases/latest">
|
|
||||||
<img src="https://img.shields.io/github/release/sinai-dev/Explorer.svg" />
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<img src="https://img.shields.io/github/downloads/sinai-dev/Explorer/total.svg" />
|
## Releases [](../../releases/latest) []() []()
|
||||||
</p>
|
|
||||||
|
|
||||||
## Releases
|
|
||||||
|
|
||||||
| Mod Loader | IL2CPP | Mono |
|
| Mod Loader | IL2CPP | Mono |
|
||||||
| ----------- | ------ | ---- |
|
| ----------- | ------ | ---- |
|
||||||
| [BepInEx](https://github.com/BepInEx/BepInEx) 6.X | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx.Il2Cpp.zip) | ❔* [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx6.Mono.zip) |
|
| [BepInEx](https://github.com/BepInEx/BepInEx) 6.X | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx6.Mono.zip) |
|
||||||
| [BepInEx](https://github.com/BepInEx/BepInEx) 5.X | ❌ n/a | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx5.Mono.zip) |
|
| [BepInEx](https://github.com/BepInEx/BepInEx) 5.X | ✖️ n/a | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx5.Mono.zip) |
|
||||||
| [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) 0.3 | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader.Mono.zip) |
|
| [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) 0.3 | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader.Mono.zip) |
|
||||||
| Standalone | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Mono.zip) |
|
| Standalone | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Mono.zip) |
|
||||||
|
|
||||||
\* BepInEx 6.X Mono release may not work on all games yet.
|
|
||||||
|
|
||||||
## How to install
|
## How to install
|
||||||
|
|
||||||
### BepInEx
|
### BepInEx
|
||||||
@ -139,10 +130,10 @@ Building the project should be straight-forward, the references are all inside t
|
|||||||
|
|
||||||
## Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
* [ManlyMarco](https://github.com/ManlyMarco) for [Runtime Unity Editor](https://github.com/ManlyMarco/RuntimeUnityEditor) (GPL), snippets from the REPL Console were used for UnityExplorer's C# Console.
|
* [ManlyMarco](https://github.com/ManlyMarco) for [Runtime Unity Editor](https://github.com/ManlyMarco/RuntimeUnityEditor), snippets from the REPL Console were used for UnityExplorer's C# Console.
|
||||||
* [denikson](https://github.com/denikson) (aka Horse) for [mcs-unity](https://github.com/denikson/mcs-unity) (MIT), used as the `Mono.CSharp` reference for the C# Console.
|
* [denikson](https://github.com/denikson) (aka Horse) for [mcs-unity](https://github.com/denikson/mcs-unity), used as the `Mono.CSharp` reference for the C# Console.
|
||||||
* [HerpDerpenstine](https://github.com/HerpDerpinstine) for [MelonCoroutines](https://github.com/LavaGang/MelonLoader/blob/master/MelonLoader.Support.Il2Cpp/MelonCoroutines.cs) (Apache), they were included for standalone Il2CPP coroutine support.
|
* [HerpDerpenstine](https://github.com/HerpDerpinstine) for [MelonCoroutines](https://github.com/LavaGang/MelonLoader/blob/master/MelonLoader.Support.Il2Cpp/MelonCoroutines.cs), they were included for standalone IL2CPP coroutine support.
|
||||||
* [InGameCodeEditor](https://assetstore.unity.com/packages/tools/gui/ingame-code-editor-144254) (Apache) was used as the base for the syntax highlighting for UnityExplorer's C# console (`UnityExplorer.UI.Main.CSConsole.Lexer`).
|
* [InGameCodeEditor](https://assetstore.unity.com/packages/tools/gui/ingame-code-editor-144254) was used as the base for the syntax highlighting for UnityExplorer's C# console (`UnityExplorer.UI.Main.CSConsole.Lexer`).
|
||||||
|
|
||||||
### Disclaimer
|
### Disclaimer
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ namespace UnityExplorer.Core.Config
|
|||||||
public Action<T> OnValueChanged;
|
public Action<T> OnValueChanged;
|
||||||
public Action OnValueChangedNotify { get; set; }
|
public Action OnValueChangedNotify { get; set; }
|
||||||
|
|
||||||
|
public object DefaultValue { get; }
|
||||||
|
|
||||||
public T Value
|
public T Value
|
||||||
{
|
{
|
||||||
get => m_value;
|
get => m_value;
|
||||||
@ -29,12 +31,13 @@ namespace UnityExplorer.Core.Config
|
|||||||
set => SetValue((T)value);
|
set => SetValue((T)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigElement(string name, string description, T defaultValue, bool isInternal)
|
public ConfigElement(string name, string description, T defaultValue, bool isInternal = false)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Description = description;
|
Description = description;
|
||||||
|
|
||||||
m_value = defaultValue;
|
m_value = defaultValue;
|
||||||
|
DefaultValue = defaultValue;
|
||||||
|
|
||||||
IsInternal = isInternal;
|
IsInternal = isInternal;
|
||||||
|
|
||||||
@ -52,6 +55,8 @@ namespace UnityExplorer.Core.Config
|
|||||||
|
|
||||||
OnValueChanged?.Invoke(value);
|
OnValueChanged?.Invoke(value);
|
||||||
OnValueChangedNotify?.Invoke();
|
OnValueChangedNotify?.Invoke();
|
||||||
|
|
||||||
|
ConfigManager.Handler.OnAnyConfigChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
object IConfigElement.GetLoaderConfigValue() => GetLoaderConfigValue();
|
object IConfigElement.GetLoaderConfigValue() => GetLoaderConfigValue();
|
||||||
@ -60,5 +65,10 @@ namespace UnityExplorer.Core.Config
|
|||||||
{
|
{
|
||||||
return ConfigManager.Handler.GetConfigValue(this);
|
return ConfigManager.Handler.GetConfigValue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RevertToDefaultValue()
|
||||||
|
{
|
||||||
|
Value = (T)DefaultValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ namespace UnityExplorer.Core.Config
|
|||||||
public static ConfigElement<bool> Hide_On_Startup;
|
public static ConfigElement<bool> Hide_On_Startup;
|
||||||
|
|
||||||
public static ConfigElement<string> Last_Window_Anchors;
|
public static ConfigElement<string> Last_Window_Anchors;
|
||||||
|
public static ConfigElement<string> Last_Window_Position;
|
||||||
public static ConfigElement<int> Last_Active_Tab;
|
public static ConfigElement<int> Last_Active_Tab;
|
||||||
public static ConfigElement<bool> Last_DebugConsole_State;
|
public static ConfigElement<bool> Last_DebugConsole_State;
|
||||||
public static ConfigElement<bool> Last_SceneExplorer_State;
|
public static ConfigElement<bool> Last_SceneExplorer_State;
|
||||||
@ -41,6 +42,7 @@ namespace UnityExplorer.Core.Config
|
|||||||
|
|
||||||
SceneExplorer.OnToggleShow += SceneExplorer_OnToggleShow;
|
SceneExplorer.OnToggleShow += SceneExplorer_OnToggleShow;
|
||||||
PanelDragger.OnFinishResize += PanelDragger_OnFinishResize;
|
PanelDragger.OnFinishResize += PanelDragger_OnFinishResize;
|
||||||
|
PanelDragger.OnFinishDrag += PanelDragger_OnFinishDrag;
|
||||||
MainMenu.OnActiveTabChanged += MainMenu_OnActiveTabChanged;
|
MainMenu.OnActiveTabChanged += MainMenu_OnActiveTabChanged;
|
||||||
DebugConsole.OnToggleShow += DebugConsole_OnToggleShow;
|
DebugConsole.OnToggleShow += DebugConsole_OnToggleShow;
|
||||||
}
|
}
|
||||||
@ -55,39 +57,40 @@ namespace UnityExplorer.Core.Config
|
|||||||
{
|
{
|
||||||
Main_Menu_Toggle = new ConfigElement<KeyCode>("Main Menu Toggle",
|
Main_Menu_Toggle = new ConfigElement<KeyCode>("Main Menu Toggle",
|
||||||
"The UnityEngine.KeyCode to toggle the UnityExplorer Menu.",
|
"The UnityEngine.KeyCode to toggle the UnityExplorer Menu.",
|
||||||
KeyCode.F7,
|
KeyCode.F7);
|
||||||
false);
|
|
||||||
|
|
||||||
Force_Unlock_Mouse = new ConfigElement<bool>("Force Unlock Mouse",
|
Hide_On_Startup = new ConfigElement<bool>("Hide On Startup",
|
||||||
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
"Should UnityExplorer be hidden on startup?",
|
||||||
true,
|
|
||||||
false);
|
|
||||||
|
|
||||||
Default_Page_Limit = new ConfigElement<int>("Default Page Limit",
|
|
||||||
"The default maximum number of elements per 'page' in UnityExplorer.",
|
|
||||||
25,
|
|
||||||
false);
|
|
||||||
|
|
||||||
Default_Output_Path = new ConfigElement<string>("Default Output Path",
|
|
||||||
"The default output path when exporting things from UnityExplorer.",
|
|
||||||
Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Output"),
|
|
||||||
false);
|
false);
|
||||||
|
|
||||||
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
||||||
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
||||||
false,
|
|
||||||
false);
|
false);
|
||||||
|
|
||||||
Hide_On_Startup = new ConfigElement<bool>("Hide On Startup",
|
Force_Unlock_Mouse = new ConfigElement<bool>("Force Unlock Mouse",
|
||||||
"Should UnityExplorer be hidden on startup?",
|
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
||||||
false,
|
true);
|
||||||
false);
|
|
||||||
|
Default_Page_Limit = new ConfigElement<int>("Default Page Limit",
|
||||||
|
"The default maximum number of elements per 'page' in UnityExplorer.",
|
||||||
|
25);
|
||||||
|
|
||||||
|
Default_Output_Path = new ConfigElement<string>("Default Output Path",
|
||||||
|
"The default output path when exporting things from UnityExplorer.",
|
||||||
|
Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Output"));
|
||||||
|
|
||||||
|
// Internal configs
|
||||||
|
|
||||||
Last_Window_Anchors = new ConfigElement<string>("Last_Window_Anchors",
|
Last_Window_Anchors = new ConfigElement<string>("Last_Window_Anchors",
|
||||||
"For internal use, the last anchors of the UnityExplorer window.",
|
"For internal use, the last anchors of the UnityExplorer window.",
|
||||||
DEFAULT_WINDOW_ANCHORS,
|
DEFAULT_WINDOW_ANCHORS,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
Last_Window_Position = new ConfigElement<string>("Last_Window_Position",
|
||||||
|
"For internal use, the last position of the UnityExplorer window.",
|
||||||
|
DEFAULT_WINDOW_POSITION,
|
||||||
|
true);
|
||||||
|
|
||||||
Last_Active_Tab = new ConfigElement<int>("Last_Active_Tab",
|
Last_Active_Tab = new ConfigElement<int>("Last_Active_Tab",
|
||||||
"For internal use, the last active tab index.",
|
"For internal use, the last active tab index.",
|
||||||
0,
|
0,
|
||||||
@ -108,31 +111,33 @@ namespace UnityExplorer.Core.Config
|
|||||||
|
|
||||||
private static void PanelDragger_OnFinishResize(RectTransform rect)
|
private static void PanelDragger_OnFinishResize(RectTransform rect)
|
||||||
{
|
{
|
||||||
Last_Window_Anchors.Value = RectAnchorsToString(rect);
|
Last_Window_Anchors.Value = rect.RectAnchorsToString();
|
||||||
Handler.OnAnyConfigChanged();
|
}
|
||||||
|
|
||||||
|
private static void PanelDragger_OnFinishDrag(RectTransform rect)
|
||||||
|
{
|
||||||
|
Last_Window_Position.Value = rect.RectPositionToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MainMenu_OnActiveTabChanged(int page)
|
private static void MainMenu_OnActiveTabChanged(int page)
|
||||||
{
|
{
|
||||||
Last_Active_Tab.Value = page;
|
Last_Active_Tab.Value = page;
|
||||||
Handler.OnAnyConfigChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DebugConsole_OnToggleShow(bool showing)
|
private static void DebugConsole_OnToggleShow(bool showing)
|
||||||
{
|
{
|
||||||
Last_DebugConsole_State.Value = showing;
|
Last_DebugConsole_State.Value = showing;
|
||||||
Handler.OnAnyConfigChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SceneExplorer_OnToggleShow(bool showing)
|
private static void SceneExplorer_OnToggleShow(bool showing)
|
||||||
{
|
{
|
||||||
Last_SceneExplorer_State.Value = showing;
|
Last_SceneExplorer_State.Value = showing;
|
||||||
Handler.OnAnyConfigChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window Anchors helpers
|
// Window Anchors helpers
|
||||||
|
|
||||||
private const string DEFAULT_WINDOW_ANCHORS = "0.25,0.10,0.78,0.95";
|
private const string DEFAULT_WINDOW_ANCHORS = "0.25,0.10,0.78,0.95";
|
||||||
|
private const string DEFAULT_WINDOW_POSITION = "0,0";
|
||||||
|
|
||||||
internal static CultureInfo _enCulture = new CultureInfo("en-US");
|
internal static CultureInfo _enCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
@ -177,5 +182,33 @@ namespace UnityExplorer.Core.Config
|
|||||||
panel.anchorMin = new Vector2(anchors.x, anchors.y);
|
panel.anchorMin = new Vector2(anchors.x, anchors.y);
|
||||||
panel.anchorMax = new Vector2(anchors.z, anchors.w);
|
panel.anchorMax = new Vector2(anchors.z, anchors.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string RectPositionToString(this RectTransform rect)
|
||||||
|
{
|
||||||
|
return string.Format(_enCulture, "{0},{1}", new object[]
|
||||||
|
{
|
||||||
|
rect.localPosition.x, rect.localPosition.y
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void SetPositionFromString(this RectTransform rect, string stringPosition)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var split = stringPosition.Split(',');
|
||||||
|
|
||||||
|
if (split.Length != 2)
|
||||||
|
throw new Exception();
|
||||||
|
|
||||||
|
Vector3 vector = rect.localPosition;
|
||||||
|
vector.x = float.Parse(split[0], _enCulture);
|
||||||
|
vector.y = float.Parse(split[1], _enCulture);
|
||||||
|
rect.localPosition = vector;
|
||||||
|
}
|
||||||
|
catch //(Exception ex)
|
||||||
|
{
|
||||||
|
//ExplorerCore.LogWarning("Exception setting window position: " + ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,12 @@ namespace UnityExplorer.Core.Config
|
|||||||
Type ElementType { get; }
|
Type ElementType { get; }
|
||||||
|
|
||||||
object BoxedValue { get; set; }
|
object BoxedValue { get; set; }
|
||||||
|
object DefaultValue { get; }
|
||||||
|
|
||||||
object GetLoaderConfigValue();
|
object GetLoaderConfigValue();
|
||||||
|
|
||||||
|
void RevertToDefaultValue();
|
||||||
|
|
||||||
Action OnValueChangedNotify { get; set; }
|
Action OnValueChangedNotify { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace UnityExplorer.Core
|
|||||||
{
|
{
|
||||||
public static class ReflectionUtility
|
public static class ReflectionUtility
|
||||||
{
|
{
|
||||||
public const BF CommonFlags = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
|
public const BF AllFlags = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper for IL2CPP to get the underlying true Type (Unhollowed) of the object.
|
/// Helper for IL2CPP to get the underlying true Type (Unhollowed) of the object.
|
||||||
@ -163,6 +163,32 @@ namespace UnityExplorer.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static Dictionary<Type, Dictionary<string, FieldInfo>> s_cachedFieldInfos = new Dictionary<Type, Dictionary<string, FieldInfo>>();
|
||||||
|
|
||||||
|
public static FieldInfo GetFieldInfo(Type type, string fieldName)
|
||||||
|
{
|
||||||
|
if (!s_cachedFieldInfos.ContainsKey(type))
|
||||||
|
s_cachedFieldInfos.Add(type, new Dictionary<string, FieldInfo>());
|
||||||
|
|
||||||
|
if (!s_cachedFieldInfos[type].ContainsKey(fieldName))
|
||||||
|
s_cachedFieldInfos[type].Add(fieldName, type.GetField(fieldName, AllFlags));
|
||||||
|
|
||||||
|
return s_cachedFieldInfos[type][fieldName];
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static Dictionary<Type, Dictionary<string, PropertyInfo>> s_cachedPropInfos = new Dictionary<Type, Dictionary<string, PropertyInfo>>();
|
||||||
|
|
||||||
|
public static PropertyInfo GetPropertyInfo(Type type, string propertyName)
|
||||||
|
{
|
||||||
|
if (!s_cachedPropInfos.ContainsKey(type))
|
||||||
|
s_cachedPropInfos.Add(type, new Dictionary<string, PropertyInfo>());
|
||||||
|
|
||||||
|
if (!s_cachedPropInfos[type].ContainsKey(propertyName))
|
||||||
|
s_cachedPropInfos[type].Add(propertyName, type.GetProperty(propertyName, AllFlags));
|
||||||
|
|
||||||
|
return s_cachedPropInfos[type][propertyName];
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper to display a simple "{ExceptionType}: {Message}" of the exception, and optionally use the inner-most exception.
|
/// Helper to display a simple "{ExceptionType}: {Message}" of the exception, and optionally use the inner-most exception.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -13,6 +13,7 @@ using UnityEngine.SceneManagement;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace UnityExplorer.Core.Runtime.Il2Cpp
|
namespace UnityExplorer.Core.Runtime.Il2Cpp
|
||||||
{
|
{
|
||||||
@ -121,17 +122,42 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
.Invoke(handle);
|
.Invoke(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom check for il2cpp input pointer event
|
internal static bool? s_doPropertiesExist;
|
||||||
|
|
||||||
public override void CheckInputPointerEvent()
|
public override ColorBlock SetColorBlock(ColorBlock colors, Color? normal = null, Color? highlighted = null, Color? pressed = null)
|
||||||
{
|
{
|
||||||
// Some IL2CPP games behave weird with multiple UI Input Systems, some fixes for them.
|
if (s_doPropertiesExist == null)
|
||||||
var evt = InputManager.InputPointerEvent;
|
|
||||||
if (evt != null)
|
|
||||||
{
|
{
|
||||||
if (!evt.eligibleForClick && evt.selectedObject)
|
var prop = ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "normalColor") as PropertyInfo;
|
||||||
evt.eligibleForClick = true;
|
s_doPropertiesExist = prop != null && prop.CanWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
colors.colorMultiplier = 1;
|
||||||
|
|
||||||
|
object boxed = (object)colors;
|
||||||
|
|
||||||
|
if (s_doPropertiesExist == true)
|
||||||
|
{
|
||||||
|
if (normal != null)
|
||||||
|
ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "normalColor").SetValue(boxed, (Color)normal);
|
||||||
|
if (pressed != null)
|
||||||
|
ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "pressedColor").SetValue(boxed, (Color)pressed);
|
||||||
|
if (highlighted != null)
|
||||||
|
ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "highlightedColor").SetValue(boxed, (Color)highlighted);
|
||||||
|
}
|
||||||
|
else if (s_doPropertiesExist == false)
|
||||||
|
{
|
||||||
|
if (normal != null)
|
||||||
|
ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_NormalColor").SetValue(boxed, (Color)normal);
|
||||||
|
if (pressed != null)
|
||||||
|
ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_PressedColor").SetValue(boxed, (Color)pressed);
|
||||||
|
if (highlighted != null)
|
||||||
|
ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_HighlightedColor").SetValue(boxed, (Color)highlighted);
|
||||||
|
}
|
||||||
|
|
||||||
|
colors = (ColorBlock)boxed;
|
||||||
|
|
||||||
|
return colors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
public override UnityEngine.Object[] FindObjectsOfTypeAll(Type type)
|
public override UnityEngine.Object[] FindObjectsOfTypeAll(Type type)
|
||||||
=> Resources.FindObjectsOfTypeAll(type);
|
=> Resources.FindObjectsOfTypeAll(type);
|
||||||
|
|
||||||
private static readonly FieldInfo fi_Scene_handle = typeof(Scene).GetField("m_Handle", ReflectionUtility.CommonFlags);
|
private static readonly FieldInfo fi_Scene_handle = typeof(Scene).GetField("m_Handle", ReflectionUtility.AllFlags);
|
||||||
|
|
||||||
public override int GetSceneHandle(Scene scene)
|
public override int GetSceneHandle(Scene scene)
|
||||||
{
|
{
|
||||||
@ -60,9 +60,18 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
return scene.rootCount;
|
return scene.rootCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CheckInputPointerEvent()
|
public override ColorBlock SetColorBlock(ColorBlock colors, Color? normal = null, Color? highlighted = null, Color? pressed = null)
|
||||||
{
|
{
|
||||||
// Not necessary afaik
|
if (normal != null)
|
||||||
|
colors.normalColor = (Color)normal;
|
||||||
|
|
||||||
|
if (highlighted != null)
|
||||||
|
colors.highlightedColor = (Color)highlighted;
|
||||||
|
|
||||||
|
if (pressed != null)
|
||||||
|
colors.pressedColor = (Color)pressed;
|
||||||
|
|
||||||
|
return colors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
private static MethodInfo GetEncodeToPNGMethod()
|
private static MethodInfo GetEncodeToPNGMethod()
|
||||||
{
|
{
|
||||||
if (ReflectionUtility.GetTypeByName("UnityEngine.ImageConversion") is Type imageConversion)
|
if (ReflectionUtility.GetTypeByName("UnityEngine.ImageConversion") is Type imageConversion)
|
||||||
return m_encodeToPNGMethod = imageConversion.GetMethod("EncodeToPNG", ReflectionUtility.CommonFlags);
|
return m_encodeToPNGMethod = imageConversion.GetMethod("EncodeToPNG", ReflectionUtility.AllFlags);
|
||||||
|
|
||||||
var method = typeof(Texture2D).GetMethod("EncodeToPNG", ReflectionUtility.CommonFlags);
|
var method = typeof(Texture2D).GetMethod("EncodeToPNG", ReflectionUtility.AllFlags);
|
||||||
if (method != null)
|
if (method != null)
|
||||||
return m_encodeToPNGMethod = method;
|
return m_encodeToPNGMethod = method;
|
||||||
|
|
||||||
|
@ -52,6 +52,6 @@ namespace UnityExplorer.Core.Runtime
|
|||||||
|
|
||||||
public abstract int GetRootCount(Scene scene);
|
public abstract int GetRootCount(Scene scene);
|
||||||
|
|
||||||
public abstract void CheckInputPointerEvent();
|
public abstract ColorBlock SetColorBlock(ColorBlock colors, Color? normal = null, Color? highlighted = null, Color? pressed = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace UnityExplorer
|
|||||||
public class ExplorerCore
|
public class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
public const string NAME = "UnityExplorer";
|
||||||
public const string VERSION = "3.3.0";
|
public const string VERSION = "3.3.2";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityExplorer.Core;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
|
|
||||||
namespace UnityExplorer.Loader.ML
|
namespace UnityExplorer.Loader.ML
|
||||||
@ -66,6 +67,11 @@ namespace UnityExplorer.Loader.ML
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnAnyConfigChanged()
|
||||||
|
{
|
||||||
|
MelonPreferences.Save();
|
||||||
|
}
|
||||||
|
|
||||||
public override void SaveConfig()
|
public override void SaveConfig()
|
||||||
{
|
{
|
||||||
MelonPreferences.Save();
|
MelonPreferences.Save();
|
||||||
|
@ -35,7 +35,7 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
{
|
{
|
||||||
IValue = InteractiveValue.Create(value, fallbackType);
|
IValue = InteractiveValue.Create(value, fallbackType);
|
||||||
IValue.Owner = this;
|
IValue.Owner = this;
|
||||||
IValue.m_mainContentParent = m_rightGroup;
|
IValue.m_mainContentParent = m_mainGroup;
|
||||||
IValue.m_subContentParent = this.m_subContent;
|
IValue.m_subContentParent = this.m_subContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,29 +49,22 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
public override void SetValue()
|
public override void SetValue()
|
||||||
{
|
{
|
||||||
RefConfig.BoxedValue = IValue.Value;
|
RefConfig.BoxedValue = IValue.Value;
|
||||||
ConfigManager.Handler.OnAnyConfigChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal GameObject m_leftGroup;
|
internal GameObject m_mainGroup;
|
||||||
internal GameObject m_rightGroup;
|
|
||||||
|
|
||||||
internal override void ConstructUI()
|
internal override void ConstructUI()
|
||||||
{
|
{
|
||||||
base.ConstructUI();
|
base.ConstructUI();
|
||||||
|
|
||||||
var vertGroup = UIFactory.CreateVerticalGroup(m_mainContent, "ConfigHolder", true, false, true, true, 5, new Vector4(2, 2, 2, 2));
|
m_mainGroup = UIFactory.CreateVerticalGroup(m_mainContent, "ConfigHolder", true, false, true, true, 5, new Vector4(2, 2, 2, 2));
|
||||||
|
|
||||||
var horiGroup = UIFactory.CreateHorizontalGroup(vertGroup, "ConfigEntryHolder", true, false, true, true);
|
var horiGroup = UIFactory.CreateHorizontalGroup(m_mainGroup, "ConfigEntryHolder", false, false, true, true, childAlignment: TextAnchor.MiddleLeft);
|
||||||
UIFactory.SetLayoutElement(horiGroup, minHeight: 30, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(horiGroup, minHeight: 30, flexibleHeight: 0);
|
||||||
|
|
||||||
// left group
|
|
||||||
|
|
||||||
m_leftGroup = UIFactory.CreateHorizontalGroup(horiGroup, "ConfigTitleGroup", false, false, true, true, 4, default, new Color(1, 1, 1, 0));
|
|
||||||
UIFactory.SetLayoutElement(m_leftGroup, minHeight: 25, flexibleHeight: 0, minWidth: 125, flexibleWidth: 200);
|
|
||||||
|
|
||||||
// config entry label
|
// config entry label
|
||||||
|
|
||||||
var configLabel = UIFactory.CreateLabel(m_leftGroup, "ConfigLabel", this.RefConfig.Name, TextAnchor.MiddleLeft);
|
var configLabel = UIFactory.CreateLabel(horiGroup, "ConfigLabel", this.RefConfig.Name, TextAnchor.MiddleLeft);
|
||||||
var leftRect = configLabel.GetComponent<RectTransform>();
|
var leftRect = configLabel.GetComponent<RectTransform>();
|
||||||
leftRect.anchorMin = Vector2.zero;
|
leftRect.anchorMin = Vector2.zero;
|
||||||
leftRect.anchorMax = Vector2.one;
|
leftRect.anchorMax = Vector2.one;
|
||||||
@ -80,23 +73,30 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
leftRect.sizeDelta = Vector2.zero;
|
leftRect.sizeDelta = Vector2.zero;
|
||||||
UIFactory.SetLayoutElement(configLabel.gameObject, minWidth: 250, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(configLabel.gameObject, minWidth: 250, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0);
|
||||||
|
|
||||||
// right group
|
// Default button
|
||||||
|
|
||||||
m_rightGroup = UIFactory.CreateVerticalGroup(horiGroup, "ConfigValueGroup", false, false, true, true, 2, new Vector4(4,2,0,0),
|
var defaultButton = UIFactory.CreateButton(horiGroup,
|
||||||
new Color(1, 1, 1, 0));
|
"RevertDefaultButton",
|
||||||
UIFactory.SetLayoutElement(m_rightGroup, minHeight: 25, minWidth: 150, flexibleHeight: 0, flexibleWidth: 5000);
|
"Default",
|
||||||
|
() => { RefConfig.RevertToDefaultValue(); },
|
||||||
|
new Color(0.3f, 0.3f, 0.3f));
|
||||||
|
UIFactory.SetLayoutElement(defaultButton.gameObject, minWidth: 80, minHeight: 22, flexibleWidth: 0);
|
||||||
|
|
||||||
|
// Description label
|
||||||
|
|
||||||
|
var desc = UIFactory.CreateLabel(m_mainGroup, "Description", $"<i>{RefConfig.Description}</i>", TextAnchor.MiddleLeft, Color.grey);
|
||||||
|
UIFactory.SetLayoutElement(desc.gameObject, minWidth: 250, minHeight: 20, flexibleWidth: 9999, flexibleHeight: 0);
|
||||||
|
|
||||||
|
// IValue
|
||||||
|
|
||||||
if (IValue != null)
|
if (IValue != null)
|
||||||
{
|
{
|
||||||
IValue.m_mainContentParent = m_rightGroup;
|
IValue.m_mainContentParent = m_mainGroup;
|
||||||
IValue.m_subContentParent = this.m_subContent;
|
IValue.m_subContentParent = this.m_subContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config description label
|
// makes the subcontent look nicer
|
||||||
|
m_subContent.transform.SetParent(m_mainGroup.transform, false);
|
||||||
UIFactory.CreateLabel(vertGroup, "Description", $"<i>{RefConfig.Description}</i>", TextAnchor.MiddleLeft, Color.grey);
|
|
||||||
|
|
||||||
m_subContent.transform.SetAsLastSibling();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,9 +320,8 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
UIFactory.SetLayoutElement(evalGroupObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 5000);
|
UIFactory.SetLayoutElement(evalGroupObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 5000);
|
||||||
|
|
||||||
var colors = new ColorBlock();
|
var colors = new ColorBlock();
|
||||||
colors.normalColor = new Color(0.4f, 0.4f, 0.4f);
|
colors = RuntimeProvider.Instance.SetColorBlock(colors, new Color(0.4f, 0.4f, 0.4f),
|
||||||
colors.highlightedColor = new Color(0.4f, 0.7f, 0.4f);
|
new Color(0.4f, 0.7f, 0.4f), new Color(0.3f, 0.3f, 0.3f));
|
||||||
colors.pressedColor = new Color(0.3f, 0.3f, 0.3f);
|
|
||||||
|
|
||||||
var evalButton = UIFactory.CreateButton(evalGroupObj,
|
var evalButton = UIFactory.CreateButton(evalGroupObj,
|
||||||
"EvalButton",
|
"EvalButton",
|
||||||
@ -346,9 +345,7 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
argsHolder.SetActive(true);
|
argsHolder.SetActive(true);
|
||||||
m_isEvaluating = true;
|
m_isEvaluating = true;
|
||||||
evalText.text = "Evaluate";
|
evalText.text = "Evaluate";
|
||||||
colors = evalButton.colors;
|
evalButton.colors = RuntimeProvider.Instance.SetColorBlock(evalButton.colors, new Color(0.3f, 0.6f, 0.3f));
|
||||||
colors.normalColor = new Color(0.3f, 0.6f, 0.3f);
|
|
||||||
evalButton.colors = colors;
|
|
||||||
|
|
||||||
cancelButton.gameObject.SetActive(true);
|
cancelButton.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
@ -368,9 +365,7 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
m_isEvaluating = false;
|
m_isEvaluating = false;
|
||||||
|
|
||||||
evalText.text = $"Evaluate ({ParamCount})";
|
evalText.text = $"Evaluate ({ParamCount})";
|
||||||
colors = evalButton.colors;
|
evalButton.colors = RuntimeProvider.Instance.SetColorBlock(evalButton.colors, new Color(0.4f, 0.4f, 0.4f));
|
||||||
colors.normalColor = new Color(0.4f, 0.4f, 0.4f);
|
|
||||||
evalButton.colors = colors;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (this is CacheMethod)
|
else if (this is CacheMethod)
|
||||||
@ -378,9 +373,8 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
// simple method evaluate button
|
// simple method evaluate button
|
||||||
|
|
||||||
var colors = new ColorBlock();
|
var colors = new ColorBlock();
|
||||||
colors.normalColor = new Color(0.4f, 0.4f, 0.4f);
|
colors = RuntimeProvider.Instance.SetColorBlock(colors, new Color(0.4f, 0.4f, 0.4f),
|
||||||
colors.highlightedColor = new Color(0.4f, 0.7f, 0.4f);
|
new Color(0.4f, 0.7f, 0.4f), new Color(0.3f, 0.3f, 0.3f));
|
||||||
colors.pressedColor = new Color(0.3f, 0.3f, 0.3f);
|
|
||||||
|
|
||||||
var evalButton = UIFactory.CreateButton(m_rightGroup, "EvalButton", "Evaluate", () => { (this as CacheMethod).Evaluate(); }, colors);
|
var evalButton = UIFactory.CreateButton(m_rightGroup, "EvalButton", "Evaluate", () => { (this as CacheMethod).Evaluate(); }, colors);
|
||||||
UIFactory.SetLayoutElement(evalButton.gameObject, minWidth: 100, minHeight: 22, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(evalButton.gameObject, minWidth: 100, minHeight: 22, flexibleWidth: 0);
|
||||||
|
@ -50,8 +50,12 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
{
|
{
|
||||||
base.ConstructUI();
|
base.ConstructUI();
|
||||||
|
|
||||||
|
Color bgColor = this.PairType == PairTypes.Key
|
||||||
|
? new Color(0.07f, 0.07f, 0.07f)
|
||||||
|
: new Color(0.1f, 0.1f, 0.1f);
|
||||||
|
|
||||||
var rowObj = UIFactory.CreateHorizontalGroup(m_mainContent, "PairedGroup", false, false, true, true, 0, new Vector4(0,0,5,2),
|
var rowObj = UIFactory.CreateHorizontalGroup(m_mainContent, "PairedGroup", false, false, true, true, 0, new Vector4(0,0,5,2),
|
||||||
new Color(1, 1, 1, 0));
|
bgColor);
|
||||||
|
|
||||||
var indexLabel = UIFactory.CreateLabel(rowObj, "IndexLabel", $"{this.PairType} {this.Index}:", TextAnchor.MiddleLeft);
|
var indexLabel = UIFactory.CreateLabel(rowObj, "IndexLabel", $"{this.PairType} {this.Index}:", TextAnchor.MiddleLeft);
|
||||||
UIFactory.SetLayoutElement(indexLabel.gameObject, minWidth: 80, flexibleWidth: 30, minHeight: 25);
|
UIFactory.SetLayoutElement(indexLabel.gameObject, minWidth: 80, flexibleWidth: 30, minHeight: 25);
|
||||||
|
@ -88,13 +88,13 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
|
|
||||||
if (Owner.CanWrite)
|
if (Owner.CanWrite)
|
||||||
{
|
{
|
||||||
var toggleObj = UIFactory.CreateToggle(m_valueContent, "InteractiveBoolToggle", out m_toggle, out _, new Color(0.1f, 0.1f, 0.1f));
|
var toggleObj = UIFactory.CreateToggle(m_mainContent, "InteractiveBoolToggle", out m_toggle, out _, new Color(0.1f, 0.1f, 0.1f));
|
||||||
UIFactory.SetLayoutElement(toggleObj, minWidth: 24);
|
UIFactory.SetLayoutElement(toggleObj, minWidth: 24);
|
||||||
m_toggle.onValueChanged.AddListener(OnToggleValueChanged);
|
m_toggle.onValueChanged.AddListener(OnToggleValueChanged);
|
||||||
|
|
||||||
m_baseLabel.transform.SetAsLastSibling();
|
m_baseLabel.transform.SetAsLastSibling();
|
||||||
|
|
||||||
m_applyBtn = UIFactory.CreateButton(m_valueContent,
|
m_applyBtn = UIFactory.CreateButton(m_mainContent,
|
||||||
"ApplyButton",
|
"ApplyButton",
|
||||||
"Apply",
|
"Apply",
|
||||||
() => { Owner.SetValue(); },
|
() => { Owner.SetValue(); },
|
||||||
|
168
src/UI/InteractiveValues/InteractiveColor.cs
Normal file
168
src/UI/InteractiveValues/InteractiveColor.cs
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace UnityExplorer.UI.InteractiveValues
|
||||||
|
{
|
||||||
|
public class InteractiveColor : InteractiveValue
|
||||||
|
{
|
||||||
|
//~~~~~~~~~ Instance ~~~~~~~~~~
|
||||||
|
|
||||||
|
public InteractiveColor(object value, Type valueType) : base(value, valueType) { }
|
||||||
|
|
||||||
|
public override bool HasSubContent => true;
|
||||||
|
public override bool SubContentWanted => true;
|
||||||
|
public override bool WantInspectBtn => true;
|
||||||
|
|
||||||
|
public override void RefreshUIForValue()
|
||||||
|
{
|
||||||
|
base.RefreshUIForValue();
|
||||||
|
|
||||||
|
if (m_subContentConstructed)
|
||||||
|
RefreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshUI()
|
||||||
|
{
|
||||||
|
var color = (Color)this.Value;
|
||||||
|
|
||||||
|
m_inputs[0].text = color.r.ToString();
|
||||||
|
m_inputs[1].text = color.g.ToString();
|
||||||
|
m_inputs[2].text = color.b.ToString();
|
||||||
|
m_inputs[3].text = color.a.ToString();
|
||||||
|
|
||||||
|
if (m_colorImage)
|
||||||
|
m_colorImage.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void OnToggleSubcontent(bool toggle)
|
||||||
|
{
|
||||||
|
base.OnToggleSubcontent(toggle);
|
||||||
|
|
||||||
|
RefreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region UI CONSTRUCTION
|
||||||
|
|
||||||
|
private Image m_colorImage;
|
||||||
|
|
||||||
|
private readonly InputField[] m_inputs = new InputField[4];
|
||||||
|
private readonly Slider[] m_sliders = new Slider[4];
|
||||||
|
|
||||||
|
public override void ConstructUI(GameObject parent, GameObject subGroup)
|
||||||
|
{
|
||||||
|
base.ConstructUI(parent, subGroup);
|
||||||
|
|
||||||
|
//// Limit the label width for colors, they're always about the same so make use of that space.
|
||||||
|
//UIFactory.SetLayoutElement(this.m_baseLabel.gameObject, flexibleWidth: 0, minWidth: 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ConstructSubcontent()
|
||||||
|
{
|
||||||
|
base.ConstructSubcontent();
|
||||||
|
|
||||||
|
var horiGroup = UIFactory.CreateHorizontalGroup(m_subContentParent, "ColorEditor", false, false, true, true, 5,
|
||||||
|
default, default, TextAnchor.MiddleLeft);
|
||||||
|
|
||||||
|
var editorContainer = UIFactory.CreateVerticalGroup(horiGroup, "EditorContent", false, true, true, true, 2, new Vector4(4, 4, 4, 4),
|
||||||
|
new Color(0.08f, 0.08f, 0.08f));
|
||||||
|
UIFactory.SetLayoutElement(editorContainer, minWidth: 300, flexibleWidth: 0);
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
AddEditorRow(i, editorContainer);
|
||||||
|
|
||||||
|
if (Owner.CanWrite)
|
||||||
|
{
|
||||||
|
var applyBtn = UIFactory.CreateButton(editorContainer, "ApplyButton", "Apply", OnSetValue, new Color(0.2f, 0.2f, 0.2f));
|
||||||
|
UIFactory.SetLayoutElement(applyBtn.gameObject, minWidth: 175, minHeight: 25, flexibleWidth: 0);
|
||||||
|
|
||||||
|
void OnSetValue()
|
||||||
|
{
|
||||||
|
Owner.SetValue();
|
||||||
|
RefreshUIForValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var imgHolder = UIFactory.CreateVerticalGroup(horiGroup, "ImgHolder", true, true, true, true, 0, new Vector4(1, 1, 1, 1),
|
||||||
|
new Color(0.08f, 0.08f, 0.08f));
|
||||||
|
UIFactory.SetLayoutElement(imgHolder, minWidth: 128, minHeight: 128, flexibleWidth: 0, flexibleHeight: 0);
|
||||||
|
|
||||||
|
var imgObj = UIFactory.CreateUIObject("ColorImageHelper", imgHolder, new Vector2(100, 25));
|
||||||
|
m_colorImage = imgObj.AddComponent<Image>();
|
||||||
|
m_colorImage.color = (Color)this.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly string[] s_fieldNames = new[] { "R", "G", "B", "A" };
|
||||||
|
|
||||||
|
internal void AddEditorRow(int index, GameObject groupObj)
|
||||||
|
{
|
||||||
|
var row = UIFactory.CreateHorizontalGroup(groupObj, "EditorRow_" + s_fieldNames[index],
|
||||||
|
false, true, true, true, 5, default, new Color(1, 1, 1, 0));
|
||||||
|
|
||||||
|
var label = UIFactory.CreateLabel(row, "RowLabel", $"{s_fieldNames[index]}:", TextAnchor.MiddleRight, Color.cyan);
|
||||||
|
UIFactory.SetLayoutElement(label.gameObject, minWidth: 50, flexibleWidth: 0, minHeight: 25);
|
||||||
|
|
||||||
|
var inputFieldObj = UIFactory.CreateInputField(row, "InputField", "...", 14, 3, 1);
|
||||||
|
UIFactory.SetLayoutElement(inputFieldObj, minWidth: 120, minHeight: 25, flexibleWidth: 0);
|
||||||
|
|
||||||
|
var inputField = inputFieldObj.GetComponent<InputField>();
|
||||||
|
m_inputs[index] = inputField;
|
||||||
|
inputField.characterValidation = InputField.CharacterValidation.Decimal;
|
||||||
|
|
||||||
|
inputField.onValueChanged.AddListener((string value) =>
|
||||||
|
{
|
||||||
|
float val = float.Parse(value);
|
||||||
|
SetValueToColor(val);
|
||||||
|
m_sliders[index].value = val;
|
||||||
|
});
|
||||||
|
|
||||||
|
var sliderObj = UIFactory.CreateSlider(row, "Slider", out Slider slider);
|
||||||
|
m_sliders[index] = slider;
|
||||||
|
UIFactory.SetLayoutElement(sliderObj, minWidth: 200, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0);
|
||||||
|
slider.minValue = 0;
|
||||||
|
slider.maxValue = 1;
|
||||||
|
slider.value = GetValueFromColor();
|
||||||
|
|
||||||
|
slider.onValueChanged.AddListener((float value) =>
|
||||||
|
{
|
||||||
|
inputField.text = value.ToString();
|
||||||
|
SetValueToColor(value);
|
||||||
|
m_inputs[index].text = value.ToString();
|
||||||
|
});
|
||||||
|
|
||||||
|
// methods for writing to the color for this field
|
||||||
|
|
||||||
|
void SetValueToColor(float floatValue)
|
||||||
|
{
|
||||||
|
Color _color = (Color)Value;
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 0: _color.r = floatValue; break;
|
||||||
|
case 1: _color.g = floatValue; break;
|
||||||
|
case 2: _color.b = floatValue; break;
|
||||||
|
case 3: _color.a = floatValue; break;
|
||||||
|
}
|
||||||
|
Value = _color;
|
||||||
|
m_colorImage.color = _color;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetValueFromColor()
|
||||||
|
{
|
||||||
|
Color _color = (Color)Value;
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 0: return _color.r;
|
||||||
|
case 1: return _color.g;
|
||||||
|
case 2: return _color.b;
|
||||||
|
case 3: return _color.a;
|
||||||
|
default: throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -146,7 +146,7 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
|
|
||||||
// dropdown
|
// dropdown
|
||||||
|
|
||||||
var dropdownObj = UIFactory.CreateDropdown(groupObj, out m_dropdown, "<notset>", 14, null);
|
var dropdownObj = UIFactory.CreateDropdown(groupObj, out m_dropdown, "", 14, null);
|
||||||
UIFactory.SetLayoutElement(dropdownObj, minWidth: 150, minHeight: 25, flexibleWidth: 120);
|
UIFactory.SetLayoutElement(dropdownObj, minWidth: 150, minHeight: 25, flexibleWidth: 120);
|
||||||
|
|
||||||
foreach (var kvp in m_values)
|
foreach (var kvp in m_values)
|
||||||
|
@ -102,7 +102,7 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
labelLayout.minWidth = 50;
|
labelLayout.minWidth = 50;
|
||||||
labelLayout.flexibleWidth = 0;
|
labelLayout.flexibleWidth = 0;
|
||||||
|
|
||||||
var inputObj = UIFactory.CreateInputField(m_valueContent, "InteractiveNumberInput", "...");
|
var inputObj = UIFactory.CreateInputField(m_mainContent, "InteractiveNumberInput", "...");
|
||||||
UIFactory.SetLayoutElement(inputObj, minWidth: 120, minHeight: 25, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(inputObj, minWidth: 120, minHeight: 25, flexibleWidth: 0);
|
||||||
|
|
||||||
m_valueInput = inputObj.GetComponent<InputField>();
|
m_valueInput = inputObj.GetComponent<InputField>();
|
||||||
@ -110,7 +110,7 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
|
|
||||||
if (Owner.CanWrite)
|
if (Owner.CanWrite)
|
||||||
{
|
{
|
||||||
m_applyBtn = UIFactory.CreateButton(m_valueContent, "ApplyButton", "Apply", OnApplyClicked, new Color(0.2f, 0.2f, 0.2f));
|
m_applyBtn = UIFactory.CreateButton(m_mainContent, "ApplyButton", "Apply", OnApplyClicked, new Color(0.2f, 0.2f, 0.2f));
|
||||||
UIFactory.SetLayoutElement(m_applyBtn.gameObject, minWidth: 50, minHeight: 25, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(m_applyBtn.gameObject, minWidth: 50, minHeight: 25, flexibleWidth: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
|
|
||||||
m_labelLayout = m_baseLabel.gameObject.GetComponent<LayoutElement>();
|
m_labelLayout = m_baseLabel.gameObject.GetComponent<LayoutElement>();
|
||||||
|
|
||||||
m_readonlyInput = UIFactory.CreateLabel(m_valueContent, "ReadonlyLabel", "<notset>", TextAnchor.MiddleLeft);
|
m_readonlyInput = UIFactory.CreateLabel(m_mainContent, "ReadonlyLabel", "", TextAnchor.MiddleLeft);
|
||||||
m_readonlyInput.horizontalOverflow = HorizontalWrapMode.Overflow;
|
m_readonlyInput.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||||
|
|
||||||
var testFitter = m_readonlyInput.gameObject.AddComponent<ContentSizeFitter>();
|
var testFitter = m_readonlyInput.gameObject.AddComponent<ContentSizeFitter>();
|
||||||
@ -128,7 +128,7 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
{
|
{
|
||||||
base.ConstructSubcontent();
|
base.ConstructSubcontent();
|
||||||
|
|
||||||
var groupObj = UIFactory.CreateVerticalGroup(m_subContentParent, "SubContent", true, false, true, true, 4, new Vector4(3,3,3,3),
|
var groupObj = UIFactory.CreateVerticalGroup(m_subContentParent, "SubContent", false, false, true, true, 4, new Vector4(3,3,3,3),
|
||||||
new Color(1, 1, 1, 0));
|
new Color(1, 1, 1, 0));
|
||||||
|
|
||||||
m_hiddenObj = UIFactory.CreateLabel(groupObj, "HiddenLabel", "", TextAnchor.MiddleLeft).gameObject;
|
m_hiddenObj = UIFactory.CreateLabel(groupObj, "HiddenLabel", "", TextAnchor.MiddleLeft).gameObject;
|
||||||
|
@ -183,7 +183,7 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
typeof(Vector3),
|
typeof(Vector3),
|
||||||
typeof(Vector4),
|
typeof(Vector4),
|
||||||
typeof(Rect),
|
typeof(Rect),
|
||||||
typeof(Color) // todo might make a special editor for colors
|
//typeof(Color) // todo might make a special editor for colors
|
||||||
};
|
};
|
||||||
|
|
||||||
//~~~~~~~~~ Instance ~~~~~~~~~~
|
//~~~~~~~~~ Instance ~~~~~~~~~~
|
||||||
|
@ -46,6 +46,8 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
return typeof(InteractiveEnum);
|
return typeof(InteractiveEnum);
|
||||||
}
|
}
|
||||||
// check for unity struct types
|
// check for unity struct types
|
||||||
|
else if (typeof(Color).IsAssignableFrom(type))
|
||||||
|
return typeof(InteractiveColor);
|
||||||
else if (InteractiveUnityStruct.SupportsType(type))
|
else if (InteractiveUnityStruct.SupportsType(type))
|
||||||
return typeof(InteractiveUnityStruct);
|
return typeof(InteractiveUnityStruct);
|
||||||
// check Transform, force InteractiveValue so they dont become InteractiveEnumerables.
|
// check Transform, force InteractiveValue so they dont become InteractiveEnumerables.
|
||||||
@ -95,11 +97,11 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
|
|
||||||
public virtual void OnDestroy()
|
public virtual void OnDestroy()
|
||||||
{
|
{
|
||||||
if (this.m_valueContent)
|
if (this.m_mainContent)
|
||||||
{
|
{
|
||||||
m_valueContent.transform.SetParent(null, false);
|
m_mainContent.transform.SetParent(null, false);
|
||||||
m_valueContent.SetActive(false);
|
m_mainContent.SetActive(false);
|
||||||
GameObject.Destroy(this.m_valueContent.gameObject);
|
GameObject.Destroy(this.m_mainContent.gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroySubContent();
|
DestroySubContent();
|
||||||
@ -293,7 +295,7 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
internal GameObject m_mainContentParent;
|
internal GameObject m_mainContentParent;
|
||||||
internal GameObject m_subContentParent;
|
internal GameObject m_subContentParent;
|
||||||
|
|
||||||
internal GameObject m_valueContent;
|
internal GameObject m_mainContent;
|
||||||
internal GameObject m_inspectButton;
|
internal GameObject m_inspectButton;
|
||||||
internal Text m_baseLabel;
|
internal Text m_baseLabel;
|
||||||
|
|
||||||
@ -304,24 +306,24 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
{
|
{
|
||||||
m_UIConstructed = true;
|
m_UIConstructed = true;
|
||||||
|
|
||||||
m_valueContent = UIFactory.CreateHorizontalGroup(parent, $"InteractiveValue_{this.GetType().Name}", false, false, true, true, 4, default,
|
m_mainContent = UIFactory.CreateHorizontalGroup(parent, $"InteractiveValue_{this.GetType().Name}", false, false, true, true, 4, default,
|
||||||
new Color(1, 1, 1, 0), TextAnchor.UpperLeft);
|
new Color(1, 1, 1, 0), TextAnchor.UpperLeft);
|
||||||
|
|
||||||
var mainRect = m_valueContent.GetComponent<RectTransform>();
|
var mainRect = m_mainContent.GetComponent<RectTransform>();
|
||||||
mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25);
|
mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25);
|
||||||
|
|
||||||
UIFactory.SetLayoutElement(m_valueContent, flexibleWidth: 9000, minWidth: 175, minHeight: 25, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(m_mainContent, flexibleWidth: 9000, minWidth: 175, minHeight: 25, flexibleHeight: 0);
|
||||||
|
|
||||||
// subcontent expand button
|
// subcontent expand button
|
||||||
if (HasSubContent)
|
if (HasSubContent)
|
||||||
{
|
{
|
||||||
m_subExpandBtn = UIFactory.CreateButton(m_valueContent, "ExpandSubcontentButton", "▲", ToggleSubcontent, new Color(0.3f, 0.3f, 0.3f));
|
m_subExpandBtn = UIFactory.CreateButton(m_mainContent, "ExpandSubcontentButton", "▲", ToggleSubcontent, new Color(0.3f, 0.3f, 0.3f));
|
||||||
UIFactory.SetLayoutElement(m_subExpandBtn.gameObject, minHeight: 25, minWidth: 25, flexibleWidth: 0, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(m_subExpandBtn.gameObject, minHeight: 25, minWidth: 25, flexibleWidth: 0, flexibleHeight: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// inspect button
|
// inspect button
|
||||||
|
|
||||||
var inspectBtn = UIFactory.CreateButton(m_valueContent,
|
var inspectBtn = UIFactory.CreateButton(m_mainContent,
|
||||||
"InspectButton",
|
"InspectButton",
|
||||||
"Inspect",
|
"Inspect",
|
||||||
() =>
|
() =>
|
||||||
@ -338,7 +340,7 @@ namespace UnityExplorer.UI.InteractiveValues
|
|||||||
|
|
||||||
// value label
|
// value label
|
||||||
|
|
||||||
m_baseLabel = UIFactory.CreateLabel(m_valueContent, "ValueLabel", "<not set>", TextAnchor.MiddleLeft);
|
m_baseLabel = UIFactory.CreateLabel(m_mainContent, "ValueLabel", "", TextAnchor.MiddleLeft);
|
||||||
UIFactory.SetLayoutElement(m_baseLabel.gameObject, flexibleWidth: 9000, minHeight: 25);
|
UIFactory.SetLayoutElement(m_baseLabel.gameObject, flexibleWidth: 9000, minHeight: 25);
|
||||||
|
|
||||||
m_subContentParent = subGroup;
|
m_subContentParent = subGroup;
|
||||||
|
@ -5,6 +5,8 @@ using UnityEngine;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.CSharp;
|
using UnityExplorer.Core.CSharp;
|
||||||
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.Core.Unity;
|
using UnityExplorer.Core.Unity;
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Main;
|
using UnityExplorer.UI.Main;
|
||||||
@ -41,16 +43,12 @@ namespace UnityExplorer.UI.Main.CSConsole
|
|||||||
public static void Update()
|
public static void Update()
|
||||||
{
|
{
|
||||||
if (!m_mainObj)
|
if (!m_mainObj)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!CSharpConsole.EnableAutocompletes)
|
if (!CSharpConsole.EnableAutocompletes)
|
||||||
{
|
{
|
||||||
if (m_mainObj.activeSelf)
|
if (m_mainObj.activeSelf)
|
||||||
{
|
|
||||||
m_mainObj.SetActive(false);
|
m_mainObj.SetActive(false);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -274,8 +272,7 @@ namespace UnityExplorer.UI.Main.CSConsole
|
|||||||
mainGroup.childForceExpandWidth = true;
|
mainGroup.childForceExpandWidth = true;
|
||||||
|
|
||||||
ColorBlock btnColors = new ColorBlock();
|
ColorBlock btnColors = new ColorBlock();
|
||||||
btnColors.normalColor = new Color(0f, 0f, 0f, 0f);
|
RuntimeProvider.Instance.SetColorBlock(btnColors, new Color(0, 0, 0, 0), highlighted: new Color(0.2f, 0.2f, 0.2f, 1.0f));
|
||||||
btnColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1.0f);
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_LABELS; i++)
|
for (int i = 0; i < MAX_LABELS; i++)
|
||||||
{
|
{
|
||||||
|
@ -220,8 +220,10 @@ namespace UnityExplorer.UI.Main
|
|||||||
ConfigManager.Handler.SaveConfig();
|
ConfigManager.Handler.SaveConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ConfigManager.Log_Unity_Debug.OnValueChanged += (bool val) => { unityToggle.isOn = val; };
|
||||||
|
|
||||||
unityToggle.isOn = LogUnity;
|
unityToggle.isOn = LogUnity;
|
||||||
unityToggleText.text = "Print Unity Debug?";
|
unityToggleText.text = "Log Unity Debug?";
|
||||||
unityToggleText.alignment = TextAnchor.MiddleLeft;
|
unityToggleText.alignment = TextAnchor.MiddleLeft;
|
||||||
|
|
||||||
UIFactory.SetLayoutElement(unityToggleObj, minWidth: 170, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(unityToggleObj, minWidth: 170, flexibleWidth: 0);
|
||||||
|
@ -141,18 +141,13 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
public void OnSetInspectorTab(InspectorBase inspector)
|
public void OnSetInspectorTab(InspectorBase inspector)
|
||||||
{
|
{
|
||||||
Color activeColor = new Color(0, 0.25f, 0, 1);
|
Color activeColor = new Color(0, 0.25f, 0, 1);
|
||||||
ColorBlock colors = inspector.m_tabButton.colors;
|
inspector.m_tabButton.colors = RuntimeProvider.Instance.SetColorBlock(inspector.m_tabButton.colors, activeColor, activeColor);
|
||||||
colors.normalColor = activeColor;
|
|
||||||
colors.highlightedColor = activeColor;
|
|
||||||
inspector.m_tabButton.colors = colors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnUnsetInspectorTab()
|
public void OnUnsetInspectorTab()
|
||||||
{
|
{
|
||||||
ColorBlock colors = m_activeInspector.m_tabButton.colors;
|
m_activeInspector.m_tabButton.colors = RuntimeProvider.Instance.SetColorBlock(m_activeInspector.m_tabButton.colors,
|
||||||
colors.normalColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
new Color(0.2f, 0.2f, 0.2f, 1), new Color(0.1f, 0.3f, 0.1f, 1));
|
||||||
colors.highlightedColor = new Color(0.1f, 0.3f, 0.1f, 1);
|
|
||||||
m_activeInspector.m_tabButton.colors = colors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConstructInspectorPane()
|
public void ConstructInspectorPane()
|
||||||
@ -200,15 +195,13 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
UIFactory.CreateHorizontalGroup(topRowObj, "Toolbar", false, false, true, true, 10, new Vector4(2, 2, 2, 2), new Color(1,1,1,0));
|
UIFactory.CreateHorizontalGroup(topRowObj, "Toolbar", false, false, true, true, 10, new Vector4(2, 2, 2, 2), new Color(1,1,1,0));
|
||||||
|
|
||||||
// inspect under mouse button
|
// inspect under mouse button
|
||||||
AddMouseInspectButton(topRowObj, InspectUnderMouse.MouseInspectMode.UI);
|
AddMouseInspectButton(topRowObj, "UI", InspectUnderMouse.MouseInspectMode.UI);
|
||||||
AddMouseInspectButton(topRowObj, InspectUnderMouse.MouseInspectMode.World);
|
AddMouseInspectButton(topRowObj, "3D", InspectUnderMouse.MouseInspectMode.World);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddMouseInspectButton(GameObject topRowObj, InspectUnderMouse.MouseInspectMode mode)
|
private static void AddMouseInspectButton(GameObject topRowObj, string suffix, InspectUnderMouse.MouseInspectMode mode)
|
||||||
{
|
{
|
||||||
string lbl = "Mouse Inspect";
|
string lbl = $"Mouse Inspect ({suffix})";
|
||||||
if (mode == InspectUnderMouse.MouseInspectMode.UI)
|
|
||||||
lbl += " (UI)";
|
|
||||||
|
|
||||||
var inspectObj = UIFactory.CreateButton(topRowObj,
|
var inspectObj = UIFactory.CreateButton(topRowObj,
|
||||||
lbl,
|
lbl,
|
||||||
@ -216,7 +209,7 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
() => { InspectUnderMouse.StartInspect(mode); },
|
() => { InspectUnderMouse.StartInspect(mode); },
|
||||||
new Color(0.2f, 0.2f, 0.2f));
|
new Color(0.2f, 0.2f, 0.2f));
|
||||||
|
|
||||||
UIFactory.SetLayoutElement(inspectObj.gameObject, minWidth: 120, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(inspectObj.gameObject, minWidth: 150, flexibleWidth: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.UI.Utility;
|
using UnityExplorer.UI.Utility;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
||||||
@ -168,13 +169,12 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
|||||||
toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); });
|
toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); });
|
||||||
|
|
||||||
ColorBlock mainColors = new ColorBlock();
|
ColorBlock mainColors = new ColorBlock();
|
||||||
mainColors.normalColor = new Color(0.07f, 0.07f, 0.07f);
|
RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.07f, 0.07f, 0.07f),
|
||||||
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
new Color(0.2f, 0.2f, 0.2f, 1), new Color(0.05f, 0.05f, 0.05f));
|
||||||
mainColors.pressedColor = new Color(0.05f, 0.05f, 0.05f);
|
|
||||||
|
|
||||||
var mainBtn = UIFactory.CreateButton(btnGroupObj,
|
var mainBtn = UIFactory.CreateButton(btnGroupObj,
|
||||||
"MainButton",
|
"MainButton",
|
||||||
"<notset>",
|
"",
|
||||||
() => { OnChildListObjectClicked(thisIndex); },
|
() => { OnChildListObjectClicked(thisIndex); },
|
||||||
mainColors);
|
mainColors);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.UI.Utility;
|
using UnityExplorer.UI.Utility;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
||||||
@ -175,13 +176,12 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
|||||||
// Main component button
|
// Main component button
|
||||||
|
|
||||||
ColorBlock mainColors = new ColorBlock();
|
ColorBlock mainColors = new ColorBlock();
|
||||||
mainColors.normalColor = new Color(0.07f, 0.07f, 0.07f);
|
RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.07f, 0.07f, 0.07f),
|
||||||
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
new Color(0.2f, 0.2f, 0.2f, 1), new Color(0.05f, 0.05f, 0.05f));
|
||||||
mainColors.pressedColor = new Color(0.05f, 0.05f, 0.05f);
|
|
||||||
|
|
||||||
var mainBtn = UIFactory.CreateButton(groupObj,
|
var mainBtn = UIFactory.CreateButton(groupObj,
|
||||||
"MainButton",
|
"MainButton",
|
||||||
"<notset>",
|
"",
|
||||||
() => { OnCompListObjectClicked(thisIndex); },
|
() => { OnCompListObjectClicked(thisIndex); },
|
||||||
mainColors);
|
mainColors);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.Core.Unity;
|
using UnityExplorer.Core.Unity;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
||||||
@ -380,7 +381,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
|||||||
UIFactory.SetLayoutElement(valueTitle.gameObject, minHeight: 25, flexibleHeight: 0, minWidth: 25, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(valueTitle.gameObject, minHeight: 25, flexibleHeight: 0, minWidth: 25, flexibleWidth: 0);
|
||||||
|
|
||||||
// actual value label
|
// actual value label
|
||||||
var valueLabel = UIFactory.CreateLabel(rowObject, "ValueLabel", "<notset>", TextAnchor.MiddleLeft);
|
var valueLabel = UIFactory.CreateLabel(rowObject, "ValueLabel", "", TextAnchor.MiddleLeft);
|
||||||
editor.values[(int)vectorValue] = valueLabel;
|
editor.values[(int)vectorValue] = valueLabel;
|
||||||
UIFactory.SetLayoutElement(valueLabel.gameObject, minWidth: 85, flexibleWidth: 0, minHeight: 25);
|
UIFactory.SetLayoutElement(valueLabel.gameObject, minWidth: 85, flexibleWidth: 0, minHeight: 25);
|
||||||
|
|
||||||
@ -407,9 +408,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
|||||||
var sliderObj = UIFactory.CreateSlider(rowObject, "VectorSlider", out Slider slider);
|
var sliderObj = UIFactory.CreateSlider(rowObject, "VectorSlider", out Slider slider);
|
||||||
UIFactory.SetLayoutElement(sliderObj, minHeight: 20, flexibleHeight: 0, minWidth: 200, flexibleWidth: 9000);
|
UIFactory.SetLayoutElement(sliderObj, minHeight: 20, flexibleHeight: 0, minWidth: 200, flexibleWidth: 9000);
|
||||||
sliderObj.transform.Find("Fill Area").gameObject.SetActive(false);
|
sliderObj.transform.Find("Fill Area").gameObject.SetActive(false);
|
||||||
var sliderColors = slider.colors;
|
slider.colors = RuntimeProvider.Instance.SetColorBlock(slider.colors, new Color(0.65f, 0.65f, 0.65f));
|
||||||
sliderColors.normalColor = new Color(0.65f, 0.65f, 0.65f);
|
|
||||||
slider.colors = sliderColors;
|
|
||||||
slider.minValue = -2;
|
slider.minValue = -2;
|
||||||
slider.maxValue = 2;
|
slider.maxValue = 2;
|
||||||
slider.value = 0;
|
slider.value = 0;
|
||||||
|
@ -321,7 +321,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
|||||||
var layerLabel = UIFactory.CreateLabel(sceneLayerRow, "LayerLabel", "Layer:", TextAnchor.MiddleCenter, Color.grey, true, 14);
|
var layerLabel = UIFactory.CreateLabel(sceneLayerRow, "LayerLabel", "Layer:", TextAnchor.MiddleCenter, Color.grey, true, 14);
|
||||||
UIFactory.SetLayoutElement(layerLabel.gameObject, minWidth: 55, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(layerLabel.gameObject, minWidth: 55, flexibleWidth: 0);
|
||||||
|
|
||||||
var layerDropdownObj = UIFactory.CreateDropdown(sceneLayerRow, out m_layerDropdown, "<notset>", 14, OnLayerSelected);
|
var layerDropdownObj = UIFactory.CreateDropdown(sceneLayerRow, out m_layerDropdown, "", 14, OnLayerSelected);
|
||||||
m_layerDropdown.options.Clear();
|
m_layerDropdown.options.Clear();
|
||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
@ -335,7 +335,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
|
|||||||
var sceneLabel = UIFactory.CreateLabel(sceneLayerRow, "SceneLabel", "Scene:", TextAnchor.MiddleCenter, Color.grey, true, 14);
|
var sceneLabel = UIFactory.CreateLabel(sceneLayerRow, "SceneLabel", "Scene:", TextAnchor.MiddleCenter, Color.grey, true, 14);
|
||||||
UIFactory.SetLayoutElement(sceneLabel.gameObject, minWidth: 55, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(sceneLabel.gameObject, minWidth: 55, flexibleWidth: 0);
|
||||||
|
|
||||||
m_sceneText = UIFactory.CreateLabel(sceneLayerRow, "SceneText", "<notset>", TextAnchor.MiddleLeft);
|
m_sceneText = UIFactory.CreateLabel(sceneLayerRow, "SceneText", "", TextAnchor.MiddleLeft);
|
||||||
UIFactory.SetLayoutElement(m_sceneText.gameObject, minWidth: 120, flexibleWidth: 2000);
|
UIFactory.SetLayoutElement(m_sceneText.gameObject, minWidth: 120, flexibleWidth: 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
|
|||||||
|
|
||||||
m_tabButton = UIFactory.CreateButton(tabGroupObj,
|
m_tabButton = UIFactory.CreateButton(tabGroupObj,
|
||||||
"TabButton",
|
"TabButton",
|
||||||
"<notset>",
|
"",
|
||||||
() => { InspectorManager.Instance.SetInspectorTab(parent); });
|
() => { InspectorManager.Instance.SetInspectorTab(parent); });
|
||||||
|
|
||||||
UIFactory.SetLayoutElement(m_tabButton.gameObject, minWidth: 165, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(m_tabButton.gameObject, minWidth: 165, flexibleWidth: 0);
|
||||||
|
@ -30,18 +30,12 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.Reflection
|
|||||||
internal void OnScopeFilterClicked(MemberScopes type, Button button)
|
internal void OnScopeFilterClicked(MemberScopes type, Button button)
|
||||||
{
|
{
|
||||||
if (m_lastActiveScopeButton)
|
if (m_lastActiveScopeButton)
|
||||||
{
|
m_lastActiveScopeButton.colors = RuntimeProvider.Instance.SetColorBlock(m_lastActiveScopeButton.colors, new Color(0.2f, 0.2f, 0.2f));
|
||||||
var lastColors = m_lastActiveScopeButton.colors;
|
|
||||||
lastColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
|
|
||||||
m_lastActiveScopeButton.colors = lastColors;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_scopeFilter = type;
|
m_scopeFilter = type;
|
||||||
m_lastActiveScopeButton = button;
|
m_lastActiveScopeButton = button;
|
||||||
|
|
||||||
var colors = m_lastActiveScopeButton.colors;
|
m_lastActiveScopeButton.colors = RuntimeProvider.Instance.SetColorBlock(m_lastActiveScopeButton.colors, new Color(0.2f, 0.6f, 0.2f));
|
||||||
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
|
|
||||||
m_lastActiveScopeButton.colors = colors;
|
|
||||||
|
|
||||||
FilterMembers(null, true);
|
FilterMembers(null, true);
|
||||||
m_sliderScroller.m_slider.value = 1f;
|
m_sliderScroller.m_slider.value = 1f;
|
||||||
@ -246,17 +240,14 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.Reflection
|
|||||||
|
|
||||||
btn.onClick.AddListener(() => { OnScopeFilterClicked(type, btn); });
|
btn.onClick.AddListener(() => { OnScopeFilterClicked(type, btn); });
|
||||||
|
|
||||||
var colors = btn.colors;
|
btn.colors = RuntimeProvider.Instance.SetColorBlock(btn.colors, highlighted: new Color(0.3f, 0.7f, 0.3f));
|
||||||
colors.highlightedColor = new Color(0.3f, 0.7f, 0.3f);
|
|
||||||
|
|
||||||
if (setEnabled)
|
if (setEnabled)
|
||||||
{
|
{
|
||||||
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
|
btn.colors = RuntimeProvider.Instance.SetColorBlock(btn.colors, new Color(0.2f, 0.6f, 0.2f));
|
||||||
m_scopeFilter = type;
|
m_scopeFilter = type;
|
||||||
m_lastActiveScopeButton = btn;
|
m_lastActiveScopeButton = btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
btn.colors = colors;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using UnityEngine;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.UI.CacheObject;
|
||||||
using UnityExplorer.UI.Utility;
|
using UnityExplorer.UI.Utility;
|
||||||
|
|
||||||
@ -238,18 +239,12 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.Reflection
|
|||||||
internal void OnMemberFilterClicked(MemberTypes type, Button button)
|
internal void OnMemberFilterClicked(MemberTypes type, Button button)
|
||||||
{
|
{
|
||||||
if (m_lastActiveMemButton)
|
if (m_lastActiveMemButton)
|
||||||
{
|
m_lastActiveMemButton.colors = RuntimeProvider.Instance.SetColorBlock(m_lastActiveMemButton.colors, new Color(0.2f, 0.2f, 0.2f));
|
||||||
var lastColors = m_lastActiveMemButton.colors;
|
|
||||||
lastColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
|
|
||||||
m_lastActiveMemButton.colors = lastColors;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_memberFilter = type;
|
m_memberFilter = type;
|
||||||
m_lastActiveMemButton = button;
|
m_lastActiveMemButton = button;
|
||||||
|
|
||||||
var colors = m_lastActiveMemButton.colors;
|
m_lastActiveMemButton.colors = RuntimeProvider.Instance.SetColorBlock(m_lastActiveMemButton.colors, new Color(0.2f, 0.6f, 0.2f));
|
||||||
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
|
|
||||||
m_lastActiveMemButton.colors = colors;
|
|
||||||
|
|
||||||
FilterMembers(null, true);
|
FilterMembers(null, true);
|
||||||
m_sliderScroller.m_slider.value = 1f;
|
m_sliderScroller.m_slider.value = 1f;
|
||||||
@ -464,17 +459,14 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.Reflection
|
|||||||
UIFactory.SetLayoutElement(btn.gameObject, minHeight: 25, minWidth: 70);
|
UIFactory.SetLayoutElement(btn.gameObject, minHeight: 25, minWidth: 70);
|
||||||
btn.onClick.AddListener(() => { OnMemberFilterClicked(type, btn); });
|
btn.onClick.AddListener(() => { OnMemberFilterClicked(type, btn); });
|
||||||
|
|
||||||
var colors = btn.colors;
|
btn.colors = RuntimeProvider.Instance.SetColorBlock(btn.colors, highlighted: new Color(0.3f, 0.7f, 0.3f));
|
||||||
colors.highlightedColor = new Color(0.3f, 0.7f, 0.3f);
|
|
||||||
|
|
||||||
if (setEnabled)
|
if (setEnabled)
|
||||||
{
|
{
|
||||||
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
|
btn.colors = RuntimeProvider.Instance.SetColorBlock(btn.colors, new Color(0.2f, 0.6f, 0.2f));
|
||||||
m_memberFilter = type;
|
m_memberFilter = type;
|
||||||
m_lastActiveMemButton = btn;
|
m_lastActiveMemButton = btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
btn.colors = colors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ConstructUpdateRow()
|
internal void ConstructUpdateRow()
|
||||||
|
@ -11,6 +11,8 @@ using UnityExplorer.UI.Main.Home;
|
|||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.UI.Utility;
|
using UnityExplorer.UI.Utility;
|
||||||
using UnityExplorer.UI.Main.Search;
|
using UnityExplorer.UI.Main.Search;
|
||||||
|
using System.IO;
|
||||||
|
using UnityExplorer.Core;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Main.Home
|
namespace UnityExplorer.UI.Main.Home
|
||||||
{
|
{
|
||||||
@ -56,11 +58,9 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
internal readonly List<GameObject> m_shortList = new List<GameObject>();
|
internal readonly List<GameObject> m_shortList = new List<GameObject>();
|
||||||
|
|
||||||
private Text m_hideText;
|
private Text m_hideText;
|
||||||
private GameObject m_titleObj;
|
|
||||||
private GameObject m_sceneDropdownObj;
|
private GameObject m_sceneDropdownObj;
|
||||||
private GameObject m_scenePathGroupObj;
|
private GameObject m_scenePathGroupObj;
|
||||||
private GameObject m_scrollObj;
|
private GameObject m_mainContent;
|
||||||
private LayoutElement m_leftLayout;
|
|
||||||
|
|
||||||
internal static GameObject DontDestroyObject
|
internal static GameObject DontDestroyObject
|
||||||
{
|
{
|
||||||
@ -84,6 +84,30 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
ToggleShow();
|
ToggleShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ToggleShow()
|
||||||
|
{
|
||||||
|
if (!Hiding)
|
||||||
|
{
|
||||||
|
Hiding = true;
|
||||||
|
|
||||||
|
m_hideText.text = "►";
|
||||||
|
m_mainContent.SetActive(false);
|
||||||
|
m_pageHandler.Hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Hiding = false;
|
||||||
|
|
||||||
|
m_hideText.text = "◄";
|
||||||
|
m_mainContent.SetActive(true);
|
||||||
|
m_pageHandler.Show();
|
||||||
|
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
InvokeOnToggleShow();
|
||||||
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (Hiding || Time.realtimeSinceStartup - m_timeOfLastSceneUpdate < UPDATE_INTERVAL)
|
if (Hiding || Time.realtimeSinceStartup - m_timeOfLastSceneUpdate < UPDATE_INTERVAL)
|
||||||
@ -223,39 +247,6 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
OnToggleShow?.Invoke(!Instance.Hiding);
|
OnToggleShow?.Invoke(!Instance.Hiding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleShow()
|
|
||||||
{
|
|
||||||
if (!Hiding)
|
|
||||||
{
|
|
||||||
Hiding = true;
|
|
||||||
|
|
||||||
m_hideText.text = "►";
|
|
||||||
m_titleObj.SetActive(false);
|
|
||||||
m_sceneDropdownObj.SetActive(false);
|
|
||||||
m_scenePathGroupObj.SetActive(false);
|
|
||||||
m_scrollObj.SetActive(false);
|
|
||||||
m_pageHandler.Hide();
|
|
||||||
|
|
||||||
m_leftLayout.minWidth = 15;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Hiding = false;
|
|
||||||
|
|
||||||
m_hideText.text = "Hide Scene Explorer";
|
|
||||||
m_titleObj.SetActive(true);
|
|
||||||
m_sceneDropdownObj.SetActive(true);
|
|
||||||
m_scenePathGroupObj.SetActive(true);
|
|
||||||
m_scrollObj.SetActive(true);
|
|
||||||
|
|
||||||
m_leftLayout.minWidth = 350;
|
|
||||||
|
|
||||||
Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
InvokeOnToggleShow();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnActiveScenesChanged(List<string> newNames)
|
public void OnActiveScenesChanged(List<string> newNames)
|
||||||
{
|
{
|
||||||
m_sceneDropdown.options.Clear();
|
m_sceneDropdown.options.Clear();
|
||||||
@ -387,25 +378,32 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
|
|
||||||
public void ConstructScenePane()
|
public void ConstructScenePane()
|
||||||
{
|
{
|
||||||
GameObject leftPane = UIFactory.CreateVerticalGroup(HomePage.Instance.Content, "SceneGroup", true, false, true, true, 0, default,
|
var coreGroup = UIFactory.CreateHorizontalGroup(HomePage.Instance.Content, "SceneExplorer", true, true, true, true, 4, new Vector4(2, 2, 2, 2),
|
||||||
|
new Color(0.05f, 0.05f, 0.05f));
|
||||||
|
|
||||||
|
// hide button
|
||||||
|
|
||||||
|
var hideButton = UIFactory.CreateButton(coreGroup, "HideButton", "◄", ToggleShow, new Color(0.15f, 0.15f, 0.15f));
|
||||||
|
hideButton.GetComponentInChildren<Text>().fontSize = 13;
|
||||||
|
m_hideText = hideButton.GetComponentInChildren<Text>();
|
||||||
|
UIFactory.SetLayoutElement(hideButton.gameObject, minWidth: 20, minHeight: 20, flexibleWidth: 0, flexibleHeight: 9999);
|
||||||
|
|
||||||
|
m_mainContent = UIFactory.CreateVerticalGroup(coreGroup, "SceneGroup", true, false, true, true, 0, default,
|
||||||
new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
||||||
|
UIFactory.SetLayoutElement(m_mainContent, minWidth: 350, flexibleWidth: 0);
|
||||||
|
|
||||||
m_leftLayout = leftPane.AddComponent<LayoutElement>();
|
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(m_mainContent, true, true, true, true, spacing: 4, padTop: 8, 4, 4, 4);
|
||||||
m_leftLayout.minWidth = 350;
|
|
||||||
m_leftLayout.flexibleWidth = 0;
|
|
||||||
|
|
||||||
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(leftPane, true, true, true, true, spacing: 4, padTop: 8, 4, 4, 4);
|
var titleObj = UIFactory.CreateLabel(m_mainContent, "SceneExplorerTitle", "Scene Explorer", TextAnchor.UpperLeft, default, true, 20).gameObject;
|
||||||
|
UIFactory.SetLayoutElement(titleObj, minHeight: 30, flexibleHeight: 0);
|
||||||
|
|
||||||
m_titleObj = UIFactory.CreateLabel(leftPane, "SceneExplorerTitle", "Scene Explorer", TextAnchor.UpperLeft, default, true, 20).gameObject;
|
m_sceneDropdownObj = UIFactory.CreateDropdown(m_mainContent, out m_sceneDropdown, "", 14, null);
|
||||||
UIFactory.SetLayoutElement(m_titleObj, minHeight: 30, flexibleHeight: 0);
|
|
||||||
|
|
||||||
m_sceneDropdownObj = UIFactory.CreateDropdown(leftPane, out m_sceneDropdown, "<notset>", 14, null);
|
|
||||||
UIFactory.SetLayoutElement(m_sceneDropdownObj, minHeight: 40, minWidth: 320, flexibleWidth: 0, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(m_sceneDropdownObj, minHeight: 40, minWidth: 320, flexibleWidth: 0, flexibleHeight: 0);
|
||||||
|
|
||||||
m_sceneDropdownText = m_sceneDropdown.transform.Find("Label").GetComponent<Text>();
|
m_sceneDropdownText = m_sceneDropdown.transform.Find("Label").GetComponent<Text>();
|
||||||
m_sceneDropdown.onValueChanged.AddListener((int val) => { SetTargetScene(val); });
|
m_sceneDropdown.onValueChanged.AddListener((int val) => { SetTargetScene(val); });
|
||||||
|
|
||||||
m_scenePathGroupObj = UIFactory.CreateHorizontalGroup(leftPane, "ScenePathGroup", true, true, true, true, 5, default, new Color(1, 1, 1, 0f));
|
m_scenePathGroupObj = UIFactory.CreateHorizontalGroup(m_mainContent, "ScenePathGroup", true, true, true, true, 5, default, new Color(1, 1, 1, 0f));
|
||||||
UIFactory.SetLayoutElement(m_scenePathGroupObj, minHeight: 20, minWidth: 335);
|
UIFactory.SetLayoutElement(m_scenePathGroupObj, minHeight: 20, minWidth: 335);
|
||||||
|
|
||||||
var backBtnObj = UIFactory.CreateButton(m_scenePathGroupObj,
|
var backBtnObj = UIFactory.CreateButton(m_scenePathGroupObj,
|
||||||
@ -439,20 +437,68 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
m_mainInspectBtn = mainInspectButton.gameObject;
|
m_mainInspectBtn = mainInspectButton.gameObject;
|
||||||
UIFactory.SetLayoutElement(m_mainInspectBtn, minWidth: 65);
|
UIFactory.SetLayoutElement(m_mainInspectBtn, minWidth: 65);
|
||||||
|
|
||||||
m_scrollObj = UIFactory.CreateScrollView(leftPane, "SceneExplorerScrollView",
|
var scrollObj = UIFactory.CreateScrollView(m_mainContent, "SceneExplorerScrollView",
|
||||||
out m_pageContent, out SliderScrollbar scroller, new Color(0.1f, 0.1f, 0.1f));
|
out m_pageContent, out SliderScrollbar scroller, new Color(0.1f, 0.1f, 0.1f));
|
||||||
|
|
||||||
m_pageHandler = new PageHandler(scroller);
|
m_pageHandler = new PageHandler(scroller);
|
||||||
m_pageHandler.ConstructUI(leftPane);
|
m_pageHandler.ConstructUI(m_mainContent);
|
||||||
m_pageHandler.OnPageChanged += OnSceneListPageTurn;
|
m_pageHandler.OnPageChanged += OnSceneListPageTurn;
|
||||||
|
|
||||||
// hide button
|
// Scene Loader
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Type sceneUtil = ReflectionUtility.GetTypeByName("UnityEngine.SceneManagement.SceneUtility");
|
||||||
|
if (sceneUtil == null)
|
||||||
|
throw new Exception("This version of Unity does not ship with the 'SceneUtility' class, or it was not unstripped.");
|
||||||
|
var method = sceneUtil.GetMethod("GetScenePathByBuildIndex", ReflectionUtility.AllFlags);
|
||||||
|
|
||||||
var hideButton = UIFactory.CreateButton(leftPane, "HideButton", "Hide Scene Explorer", ToggleShow, new Color(0.15f, 0.15f, 0.15f));
|
var title2 = UIFactory.CreateLabel(m_mainContent, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 20);
|
||||||
hideButton.GetComponentInChildren<Text>().fontSize = 13;
|
UIFactory.SetLayoutElement(title2.gameObject, minHeight: 30, flexibleHeight: 0);
|
||||||
m_hideText = hideButton.GetComponentInChildren<Text>();
|
|
||||||
|
|
||||||
UIFactory.SetLayoutElement(hideButton.gameObject, minWidth: 20, minHeight: 20);
|
var allSceneDropObj = UIFactory.CreateDropdown(m_mainContent, out Dropdown allSceneDrop, "", 14, null);
|
||||||
|
UIFactory.SetLayoutElement(allSceneDropObj, minHeight: 40, minWidth: 320, flexibleWidth: 0, flexibleHeight: 0);
|
||||||
|
|
||||||
|
int sceneCount = SceneManager.sceneCountInBuildSettings;
|
||||||
|
for (int i = 0; i < sceneCount; i++)
|
||||||
|
{
|
||||||
|
var scenePath = (string)method.Invoke(null, new object[] { i });
|
||||||
|
allSceneDrop.options.Add(new Dropdown.OptionData(Path.GetFileNameWithoutExtension(scenePath)));
|
||||||
|
}
|
||||||
|
allSceneDrop.value = 1;
|
||||||
|
allSceneDrop.value = 0;
|
||||||
|
|
||||||
|
var buttonRow = UIFactory.CreateHorizontalGroup(m_mainContent, "LoadButtons", true, true, true, true, 4);
|
||||||
|
|
||||||
|
var loadButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Single)", () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene(allSceneDrop.options[allSceneDrop.value].text);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Unable to load the Scene! {ex.ReflectionExToString()}");
|
||||||
|
}
|
||||||
|
}, new Color(0.1f, 0.3f, 0.3f));
|
||||||
|
UIFactory.SetLayoutElement(loadButton.gameObject, minHeight: 40, minWidth: 150);
|
||||||
|
|
||||||
|
var loadAdditiveButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Additive)", () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene(allSceneDrop.options[allSceneDrop.value].text, LoadSceneMode.Additive);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Unable to load the Scene! {ex.ReflectionExToString()}");
|
||||||
|
}
|
||||||
|
}, new Color(0.1f, 0.3f, 0.3f));
|
||||||
|
UIFactory.SetLayoutElement(loadAdditiveButton.gameObject, minHeight: 40, minWidth: 150);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Could not create the Scene Loader helper! {ex.ReflectionExToString()}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddObjectListButton()
|
private void AddObjectListButton()
|
||||||
@ -476,9 +522,8 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); });
|
toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); });
|
||||||
|
|
||||||
ColorBlock mainColors = new ColorBlock();
|
ColorBlock mainColors = new ColorBlock();
|
||||||
mainColors.normalColor = new Color(0.1f, 0.1f, 0.1f);
|
mainColors = RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.1f, 0.1f, 0.1f),
|
||||||
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f);
|
new Color(0.2f, 0.2f, 0.2f), new Color(0.05f, 0.05f, 0.05f));
|
||||||
mainColors.pressedColor = new Color(0.05f, 0.05f, 0.05f);
|
|
||||||
|
|
||||||
var mainButton = UIFactory.CreateButton(btnGroupObj,
|
var mainButton = UIFactory.CreateButton(btnGroupObj,
|
||||||
"MainButton",
|
"MainButton",
|
||||||
@ -494,9 +539,8 @@ namespace UnityExplorer.UI.Main.Home
|
|||||||
m_shortListTexts.Add(mainText);
|
m_shortListTexts.Add(mainText);
|
||||||
|
|
||||||
ColorBlock inspectColors = new ColorBlock();
|
ColorBlock inspectColors = new ColorBlock();
|
||||||
inspectColors.normalColor = new Color(0.15f, 0.15f, 0.15f);
|
inspectColors = RuntimeProvider.Instance.SetColorBlock(inspectColors, new Color(0.15f, 0.15f, 0.15f),
|
||||||
inspectColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f);
|
new Color(0.2f, 0.2f, 0.2f), new Color(0.1f, 0.1f, 0.1f));
|
||||||
inspectColors.pressedColor = new Color(0.1f, 0.1f, 0.1f);
|
|
||||||
|
|
||||||
var inspectButton = UIFactory.CreateButton(btnGroupObj,
|
var inspectButton = UIFactory.CreateButton(btnGroupObj,
|
||||||
"InspectButton",
|
"InspectButton",
|
||||||
|
@ -10,6 +10,7 @@ using UnityExplorer.UI.Main.Home;
|
|||||||
using UnityExplorer.UI.Main.Search;
|
using UnityExplorer.UI.Main.Search;
|
||||||
using UnityExplorer.UI.Main.CSConsole;
|
using UnityExplorer.UI.Main.CSConsole;
|
||||||
using UnityExplorer.UI.Main.Options;
|
using UnityExplorer.UI.Main.Options;
|
||||||
|
using UnityExplorer.Core.Runtime;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Main
|
namespace UnityExplorer.UI.Main
|
||||||
{
|
{
|
||||||
@ -135,23 +136,20 @@ namespace UnityExplorer.UI.Main
|
|||||||
|
|
||||||
internal void SetButtonActiveColors(Button button)
|
internal void SetButtonActiveColors(Button button)
|
||||||
{
|
{
|
||||||
ColorBlock colors = button.colors;
|
button.colors = RuntimeProvider.Instance.SetColorBlock(button.colors, m_navButtonSelected);
|
||||||
colors.normalColor = m_navButtonSelected;
|
|
||||||
button.colors = colors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetButtonInactiveColors(Button button)
|
internal void SetButtonInactiveColors(Button button)
|
||||||
{
|
{
|
||||||
ColorBlock colors = button.colors;
|
button.colors = RuntimeProvider.Instance.SetColorBlock(button.colors, m_navButtonNormal);
|
||||||
colors.normalColor = m_navButtonNormal;
|
|
||||||
button.colors = colors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region UI Construction
|
#region UI Construction
|
||||||
|
|
||||||
private void ConstructMenu()
|
private void ConstructMenu()
|
||||||
{
|
{
|
||||||
MainPanel = UIFactory.CreatePanel("MainMenu", out GameObject content, ConfigManager.Last_Window_Anchors.Value);
|
MainPanel = UIFactory.CreatePanel("MainMenu", out GameObject content,
|
||||||
|
ConfigManager.Last_Window_Anchors.Value, ConfigManager.Last_Window_Position.Value);
|
||||||
|
|
||||||
ConstructTitleBar(content);
|
ConstructTitleBar(content);
|
||||||
|
|
||||||
@ -182,9 +180,8 @@ namespace UnityExplorer.UI.Main
|
|||||||
// Hide button
|
// Hide button
|
||||||
|
|
||||||
ColorBlock colorBlock = new ColorBlock();
|
ColorBlock colorBlock = new ColorBlock();
|
||||||
colorBlock.normalColor = new Color(65f / 255f, 23f / 255f, 23f / 255f);
|
RuntimeProvider.Instance.SetColorBlock(colorBlock, new Color(65f / 255f, 23f / 255f, 23f / 255f),
|
||||||
colorBlock.pressedColor = new Color(35f / 255f, 10f / 255f, 10f / 255f);
|
new Color(35f / 255f, 10f / 255f, 10f / 255f), new Color(156f / 255f, 0f, 0f));
|
||||||
colorBlock.highlightedColor = new Color(156f / 255f, 0f, 0f);
|
|
||||||
|
|
||||||
var hideButton = UIFactory.CreateButton(titleBar,
|
var hideButton = UIFactory.CreateButton(titleBar,
|
||||||
"HideButton",
|
"HideButton",
|
||||||
@ -212,9 +209,7 @@ namespace UnityExplorer.UI.Main
|
|||||||
UIFactory.SetLayoutElement(navbarObj, minHeight: 25, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(navbarObj, minHeight: 25, flexibleHeight: 0);
|
||||||
|
|
||||||
ColorBlock colorBlock = new ColorBlock();
|
ColorBlock colorBlock = new ColorBlock();
|
||||||
colorBlock.normalColor = m_navButtonNormal;
|
colorBlock = RuntimeProvider.Instance.SetColorBlock(colorBlock, m_navButtonNormal, m_navButtonHighlight, m_navButtonSelected);
|
||||||
colorBlock.highlightedColor = m_navButtonHighlight;
|
|
||||||
colorBlock.pressedColor = m_navButtonSelected;
|
|
||||||
|
|
||||||
foreach (var page in Pages)
|
foreach (var page in Pages)
|
||||||
{
|
{
|
||||||
|
@ -35,14 +35,14 @@ namespace UnityExplorer.UI.Main.Options
|
|||||||
{
|
{
|
||||||
GameObject parent = MainMenu.Instance.PageViewport;
|
GameObject parent = MainMenu.Instance.PageViewport;
|
||||||
|
|
||||||
Content = UIFactory.CreateVerticalGroup(parent, "OptionsPage", true, true, true, true, 5, new Vector4(4,4,4,4),
|
Content = UIFactory.CreateVerticalGroup(parent, "OptionsPage", false, true, true, true, 5, new Vector4(4,4,4,4),
|
||||||
new Color(0.15f, 0.15f, 0.15f));
|
new Color(0.15f, 0.15f, 0.15f));
|
||||||
UIFactory.SetLayoutElement(Content, minHeight: 340, flexibleHeight: 9999);
|
UIFactory.SetLayoutElement(Content, minHeight: 340, flexibleHeight: 9999);
|
||||||
|
|
||||||
// ~~~~~ Title ~~~~~
|
// ~~~~~ Title ~~~~~
|
||||||
|
|
||||||
var titleLabel = UIFactory.CreateLabel(Content, "Title", "Options", TextAnchor.UpperLeft, default, true, 25);
|
var titleLabel = UIFactory.CreateLabel(Content, "Title", "Options", TextAnchor.UpperLeft, default, true, 25);
|
||||||
UIFactory.SetLayoutElement(titleLabel.gameObject, minHeight: 30, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(titleLabel.gameObject, minHeight: 30, flexibleHeight: 0, flexibleWidth: 9999);
|
||||||
|
|
||||||
// Save button
|
// Save button
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ namespace UnityExplorer.UI.Main.Options
|
|||||||
"Save Config File",
|
"Save Config File",
|
||||||
() => { ConfigManager.Handler.SaveConfig(); },
|
() => { ConfigManager.Handler.SaveConfig(); },
|
||||||
new Color(0.25f, 0.6f, 0.25f));
|
new Color(0.25f, 0.6f, 0.25f));
|
||||||
UIFactory.SetLayoutElement(btn.gameObject, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(btn.gameObject, minWidth: 200, flexibleWidth: 0, minHeight: 30, flexibleHeight: 0);
|
||||||
|
|
||||||
// ~~~~~ Actual options ~~~~~
|
// ~~~~~ Actual options ~~~~~
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ namespace UnityExplorer.UI.Main
|
|||||||
public RectTransform Panel { get; set; }
|
public RectTransform Panel { get; set; }
|
||||||
|
|
||||||
public static event Action<RectTransform> OnFinishResize;
|
public static event Action<RectTransform> OnFinishResize;
|
||||||
|
public static event Action<RectTransform> OnFinishDrag;
|
||||||
|
|
||||||
public PanelDragger(RectTransform dragArea, RectTransform panelToDrag)
|
public PanelDragger(RectTransform dragArea, RectTransform panelToDrag)
|
||||||
{
|
{
|
||||||
@ -115,6 +116,7 @@ namespace UnityExplorer.UI.Main
|
|||||||
Vector3 diff = InputManager.MousePosition - m_lastDragPosition;
|
Vector3 diff = InputManager.MousePosition - m_lastDragPosition;
|
||||||
m_lastDragPosition = InputManager.MousePosition;
|
m_lastDragPosition = InputManager.MousePosition;
|
||||||
|
|
||||||
|
// update position while preserving the z value
|
||||||
Vector3 pos = Panel.localPosition;
|
Vector3 pos = Panel.localPosition;
|
||||||
float z = pos.z;
|
float z = pos.z;
|
||||||
pos += diff;
|
pos += diff;
|
||||||
@ -125,7 +127,8 @@ namespace UnityExplorer.UI.Main
|
|||||||
public void OnEndDrag()
|
public void OnEndDrag()
|
||||||
{
|
{
|
||||||
WasDragging = false;
|
WasDragging = false;
|
||||||
//UpdateResizeCache();
|
|
||||||
|
OnFinishDrag?.Invoke(Panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -259,10 +259,8 @@ namespace UnityExplorer.UI.Main.Search
|
|||||||
|
|
||||||
m_selectedContextButton = button;
|
m_selectedContextButton = button;
|
||||||
|
|
||||||
var colors = m_selectedContextButton.colors;
|
m_selectedContextButton.colors = RuntimeProvider.Instance.SetColorBlock(m_selectedContextButton.colors,
|
||||||
colors.normalColor = new Color(0.35f, 0.7f, 0.35f);
|
new Color(0.35f, 0.7f, 0.35f), new Color(0.35f, 0.7f, 0.35f));
|
||||||
colors.highlightedColor = colors.normalColor;
|
|
||||||
m_selectedContextButton.colors = colors;
|
|
||||||
|
|
||||||
m_context = context;
|
m_context = context;
|
||||||
|
|
||||||
@ -439,16 +437,13 @@ namespace UnityExplorer.UI.Main.Search
|
|||||||
UIFactory.SetLayoutElement(btnGroupObj, flexibleWidth: 320, minHeight: 25, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(btnGroupObj, flexibleWidth: 320, minHeight: 25, flexibleHeight: 0);
|
||||||
btnGroupObj.AddComponent<Mask>();
|
btnGroupObj.AddComponent<Mask>();
|
||||||
|
|
||||||
var mainColors = new ColorBlock
|
var mainColors = new ColorBlock();
|
||||||
{
|
RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.1f, 0.1f, 0.1f),
|
||||||
normalColor = new Color(0.1f, 0.1f, 0.1f),
|
new Color(0.2f, 0.2f, 0.2f), new Color(0.05f, 0.05f, 0.05f));
|
||||||
highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1),
|
|
||||||
pressedColor = new Color(0.05f, 0.05f, 0.05f)
|
|
||||||
};
|
|
||||||
|
|
||||||
var mainButton = UIFactory.CreateButton(btnGroupObj,
|
var mainButton = UIFactory.CreateButton(btnGroupObj,
|
||||||
"ResultButton",
|
"ResultButton",
|
||||||
"<not set>",
|
"",
|
||||||
() => { OnResultClicked(thisIndex); },
|
() => { OnResultClicked(thisIndex); },
|
||||||
mainColors);
|
mainColors);
|
||||||
|
|
||||||
|
@ -52,27 +52,26 @@ namespace UnityExplorer.UI
|
|||||||
|
|
||||||
internal static void SetDefaultSelectableColors(Selectable selectable)
|
internal static void SetDefaultSelectableColors(Selectable selectable)
|
||||||
{
|
{
|
||||||
ColorBlock colors = selectable.colors;
|
selectable.colors = RuntimeProvider.Instance.SetColorBlock(selectable.colors, new Color(0.2f, 0.2f, 0.2f),
|
||||||
SetColorBlockValues(ref colors, new Color(0.2f, 0.2f, 0.2f), new Color(0.3f, 0.3f, 0.3f), new Color(0.15f, 0.15f, 0.15f));
|
new Color(0.3f, 0.3f, 0.3f), new Color(0.15f, 0.15f, 0.15f));
|
||||||
selectable.colors = colors;
|
|
||||||
|
|
||||||
// Deselect all Buttons after they are clicked.
|
// Deselect all Buttons after they are clicked.
|
||||||
if (selectable is Button button)
|
if (selectable is Button button)
|
||||||
button.onClick.AddListener(() => { button.OnDeselect(null); });
|
button.onClick.AddListener(() => { button.OnDeselect(null); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColorBlockValues(ref this ColorBlock colorBlock, Color? normal = null, Color? highlighted = null,
|
//public static void SetColorBlockValues(ref this ColorBlock colorBlock, Color? normal = null, Color? highlighted = null,
|
||||||
Color? pressed = null)
|
// Color? pressed = null)
|
||||||
{
|
//{
|
||||||
if (normal != null)
|
// if (normal != null)
|
||||||
colorBlock.normalColor = (Color)normal;
|
// colorBlock.normalColor = (Color)normal;
|
||||||
|
|
||||||
if (highlighted != null)
|
// if (highlighted != null)
|
||||||
colorBlock.highlightedColor = (Color)highlighted;
|
// colorBlock.highlightedColor = (Color)highlighted;
|
||||||
|
|
||||||
if (pressed != null)
|
// if (pressed != null)
|
||||||
colorBlock.pressedColor = (Color)pressed;
|
// colorBlock.pressedColor = (Color)pressed;
|
||||||
}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get and/or Add a LayoutElement component to the GameObject, and set any of the values on it.
|
/// Get and/or Add a LayoutElement component to the GameObject, and set any of the values on it.
|
||||||
@ -114,13 +113,15 @@ namespace UnityExplorer.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static T SetLayoutGroup<T>(GameObject gameObject, bool? forceWidth = null, bool? forceHeight = null,
|
public static T SetLayoutGroup<T>(GameObject gameObject, bool? forceWidth = null, bool? forceHeight = null,
|
||||||
bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null,
|
bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null,
|
||||||
int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null) where T : HorizontalOrVerticalLayoutGroup
|
int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null)
|
||||||
|
where T : HorizontalOrVerticalLayoutGroup
|
||||||
{
|
{
|
||||||
var group = gameObject.GetComponent<T>();
|
var group = gameObject.GetComponent<T>();
|
||||||
if (!group)
|
if (!group)
|
||||||
group = gameObject.AddComponent<T>();
|
group = gameObject.AddComponent<T>();
|
||||||
|
|
||||||
return SetLayoutGroup(group, forceWidth, forceHeight, childControlWidth, childControlHeight, spacing, padTop, padBottom, padLeft, padRight);
|
return SetLayoutGroup(group, forceWidth, forceHeight, childControlWidth, childControlHeight, spacing, padTop,
|
||||||
|
padBottom, padLeft, padRight, childAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -128,7 +129,8 @@ namespace UnityExplorer.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static T SetLayoutGroup<T>(T group, bool? forceWidth = null, bool? forceHeight = null,
|
public static T SetLayoutGroup<T>(T group, bool? forceWidth = null, bool? forceHeight = null,
|
||||||
bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null,
|
bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null,
|
||||||
int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null) where T : HorizontalOrVerticalLayoutGroup
|
int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null)
|
||||||
|
where T : HorizontalOrVerticalLayoutGroup
|
||||||
{
|
{
|
||||||
if (forceWidth != null)
|
if (forceWidth != null)
|
||||||
group.childForceExpandWidth = (bool)forceWidth;
|
group.childForceExpandWidth = (bool)forceWidth;
|
||||||
@ -157,7 +159,7 @@ namespace UnityExplorer.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a Panel on the UI Canvas.
|
/// Create a Panel on the UI Canvas.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static GameObject CreatePanel(string name, out GameObject contentHolder, string anchors = null)
|
public static GameObject CreatePanel(string name, out GameObject contentHolder, string anchors = null, string position = null)
|
||||||
{
|
{
|
||||||
var panelObj = CreateUIObject(name, UIManager.CanvasRoot);
|
var panelObj = CreateUIObject(name, UIManager.CanvasRoot);
|
||||||
var rect = panelObj.GetComponent<RectTransform>();
|
var rect = panelObj.GetComponent<RectTransform>();
|
||||||
@ -169,6 +171,9 @@ namespace UnityExplorer.UI
|
|||||||
if (anchors != null)
|
if (anchors != null)
|
||||||
rect.SetAnchorsFromString(anchors);
|
rect.SetAnchorsFromString(anchors);
|
||||||
|
|
||||||
|
if (position != null)
|
||||||
|
rect.SetPositionFromString(position);
|
||||||
|
|
||||||
var maskImg = panelObj.AddComponent<Image>();
|
var maskImg = panelObj.AddComponent<Image>();
|
||||||
maskImg.color = Color.white;
|
maskImg.color = Color.white;
|
||||||
panelObj.AddComponent<Mask>().showMaskGraphic = false;
|
panelObj.AddComponent<Mask>().showMaskGraphic = false;
|
||||||
@ -270,13 +275,9 @@ namespace UnityExplorer.UI
|
|||||||
public static Button CreateButton(GameObject parent, string name, string text, Action onClick = null, Color? normalColor = null)
|
public static Button CreateButton(GameObject parent, string name, string text, Action onClick = null, Color? normalColor = null)
|
||||||
{
|
{
|
||||||
var colors = new ColorBlock();
|
var colors = new ColorBlock();
|
||||||
if (normalColor != null)
|
normalColor = normalColor ?? new Color(0.25f, 0.25f, 0.25f);
|
||||||
colors.normalColor = (Color)normalColor;
|
colors = RuntimeProvider.Instance.SetColorBlock(colors, normalColor, new Color(0.4f, 0.4f, 0.4f),
|
||||||
else
|
new Color(0.15f, 0.15f, 0.15f));
|
||||||
colors.normalColor = new Color(0.25f, 0.25f, 0.25f);
|
|
||||||
|
|
||||||
colors.pressedColor = new Color(0.15f, 0.15f, 0.15f);
|
|
||||||
colors.highlightedColor = new Color(0.4f, 0.4f, 0.4f);
|
|
||||||
|
|
||||||
return CreateButton(parent, name, text, onClick, colors);
|
return CreateButton(parent, name, text, onClick, colors);
|
||||||
}
|
}
|
||||||
@ -313,51 +314,6 @@ namespace UnityExplorer.UI
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Create a Button and specify only the Normal color.
|
|
||||||
///// </summary>
|
|
||||||
//public static Button CreateButton(GameObject parent, string name, string text, Action onClick = null, Color? normalColor = null)
|
|
||||||
//{
|
|
||||||
// var colors = new ColorBlock
|
|
||||||
// {
|
|
||||||
// normalColor = normalColor ?? new Color(0.25f, 0.25f, 0.25f),
|
|
||||||
// highlightedColor = new Color(0.3f, 0.3f, 0.3f),
|
|
||||||
// pressedColor = new Color(0.15f, 0.15f, 0.15f)
|
|
||||||
// };
|
|
||||||
|
|
||||||
// return CreateButton(parent, name, text, onClick, colors);
|
|
||||||
//}
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Create a Button and specify the entire ColorBlock for the transition values.
|
|
||||||
///// </summary>
|
|
||||||
//public static Button CreateButton(GameObject parent, string name, string text, Action onClick, ColorBlock? colors)
|
|
||||||
//{
|
|
||||||
// var buttonObj = CreateUIObject(name, parent);
|
|
||||||
|
|
||||||
// Image bgImage = buttonObj.AddComponent<Image>();
|
|
||||||
// bgImage.type = Image.Type.Sliced;
|
|
||||||
// bgImage.color = new Color(1, 1, 1, 0.75f);
|
|
||||||
|
|
||||||
// Button button = buttonObj.AddComponent<Button>();
|
|
||||||
// SetDefaultSelectableColors(button);
|
|
||||||
|
|
||||||
// if (onClick != null)
|
|
||||||
// button.onClick.AddListener(onClick);
|
|
||||||
|
|
||||||
// if (colors != null)
|
|
||||||
// button.colors = (ColorBlock)colors;
|
|
||||||
|
|
||||||
// var textObj = CreateLabel(buttonObj, "Text", text, TextAnchor.MiddleCenter);
|
|
||||||
|
|
||||||
// RectTransform rect = textObj.GetComponent<RectTransform>();
|
|
||||||
// rect.anchorMin = Vector2.zero;
|
|
||||||
// rect.anchorMax = Vector2.one;
|
|
||||||
// rect.sizeDelta = Vector2.zero;
|
|
||||||
|
|
||||||
// return button;
|
|
||||||
//}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a Slider control.
|
/// Create a Slider control.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -408,7 +364,8 @@ namespace UnityExplorer.UI
|
|||||||
slider.targetGraphic = handleImage;
|
slider.targetGraphic = handleImage;
|
||||||
slider.direction = Slider.Direction.LeftToRight;
|
slider.direction = Slider.Direction.LeftToRight;
|
||||||
|
|
||||||
SetDefaultSelectableColors(slider);
|
slider.colors = RuntimeProvider.Instance.SetColorBlock(slider.colors, new Color(0.4f, 0.4f, 0.4f),
|
||||||
|
new Color(0.55f, 0.55f, 0.55f), new Color(0.3f, 0.3f, 0.3f));
|
||||||
|
|
||||||
return sliderObj;
|
return sliderObj;
|
||||||
}
|
}
|
||||||
@ -547,12 +504,8 @@ namespace UnityExplorer.UI
|
|||||||
mainInput.transition = Selectable.Transition.ColorTint;
|
mainInput.transition = Selectable.Transition.ColorTint;
|
||||||
mainInput.targetGraphic = mainImage;
|
mainInput.targetGraphic = mainImage;
|
||||||
|
|
||||||
ColorBlock mainColors = mainInput.colors;
|
mainInput.colors = RuntimeProvider.Instance.SetColorBlock(mainInput.colors, new Color(1, 1, 1, 1),
|
||||||
mainColors.normalColor = new Color(1, 1, 1, 1);
|
new Color(0.95f, 0.95f, 0.95f, 1.0f), new Color(0.78f, 0.78f, 0.78f, 1.0f));
|
||||||
mainColors.highlightedColor = new Color(0.95f, 0.95f, 0.95f, 1.0f);
|
|
||||||
mainColors.pressedColor = new Color(0.78f, 0.78f, 0.78f, 1.0f);
|
|
||||||
mainColors.highlightedColor = new Color(0.95f, 0.95f, 0.95f, 1.0f);
|
|
||||||
mainInput.colors = mainColors;
|
|
||||||
|
|
||||||
SetLayoutGroup<VerticalLayoutGroup>(mainObj, true, true, true, true);
|
SetLayoutGroup<VerticalLayoutGroup>(mainObj, true, true, true, true);
|
||||||
|
|
||||||
@ -656,10 +609,8 @@ namespace UnityExplorer.UI
|
|||||||
Toggle itemToggle = itemObj.AddComponent<Toggle>();
|
Toggle itemToggle = itemObj.AddComponent<Toggle>();
|
||||||
itemToggle.targetGraphic = itemBgImage;
|
itemToggle.targetGraphic = itemBgImage;
|
||||||
itemToggle.isOn = true;
|
itemToggle.isOn = true;
|
||||||
ColorBlock colors = itemToggle.colors;
|
itemToggle.colors = RuntimeProvider.Instance.SetColorBlock(itemToggle.colors,
|
||||||
colors.normalColor = new Color(0.35f, 0.35f, 0.35f, 1.0f);
|
new Color(0.35f, 0.35f, 0.35f, 1.0f), new Color(0.25f, 0.45f, 0.25f, 1.0f));
|
||||||
colors.highlightedColor = new Color(0.25f, 0.45f, 0.25f, 1.0f);
|
|
||||||
itemToggle.colors = colors;
|
|
||||||
|
|
||||||
itemToggle.onValueChanged.AddListener((bool val) => { itemToggle.OnDeselect(null); });
|
itemToggle.onValueChanged.AddListener((bool val) => { itemToggle.OnDeselect(null); });
|
||||||
Image templateImage = templateObj.AddComponent<Image>();
|
Image templateImage = templateObj.AddComponent<Image>();
|
||||||
|
@ -81,8 +81,6 @@ namespace UnityExplorer.UI
|
|||||||
if (EventSystem.current != EventSys)
|
if (EventSystem.current != EventSys)
|
||||||
CursorUnlocker.SetEventSystem();
|
CursorUnlocker.SetEventSystem();
|
||||||
|
|
||||||
RuntimeProvider.Instance.CheckInputPointerEvent();
|
|
||||||
|
|
||||||
PanelDragger.Instance.Update();
|
PanelDragger.Instance.Update();
|
||||||
|
|
||||||
SliderScrollbar.UpdateInstances();
|
SliderScrollbar.UpdateInstances();
|
||||||
|
@ -186,7 +186,7 @@ public static class SliderExtensions
|
|||||||
{
|
{
|
||||||
if (m_setMethod == null)
|
if (m_setMethod == null)
|
||||||
{
|
{
|
||||||
m_setMethod = typeof(Slider).GetMethod("Set", ReflectionUtility.CommonFlags, null, new[] { typeof(float), typeof(bool) }, null);
|
m_setMethod = typeof(Slider).GetMethod("Set", ReflectionUtility.AllFlags, null, new[] { typeof(float), typeof(bool) }, null);
|
||||||
}
|
}
|
||||||
return m_setMethod;
|
return m_setMethod;
|
||||||
}
|
}
|
||||||
|
@ -265,6 +265,7 @@
|
|||||||
<Compile Include="UI\CacheObject\CachePaired.cs" />
|
<Compile Include="UI\CacheObject\CachePaired.cs" />
|
||||||
<Compile Include="UI\CacheObject\CacheProperty.cs" />
|
<Compile Include="UI\CacheObject\CacheProperty.cs" />
|
||||||
<Compile Include="UI\InteractiveValues\InteractiveBool.cs" />
|
<Compile Include="UI\InteractiveValues\InteractiveBool.cs" />
|
||||||
|
<Compile Include="UI\InteractiveValues\InteractiveColor.cs" />
|
||||||
<Compile Include="UI\InteractiveValues\InteractiveDictionary.cs" />
|
<Compile Include="UI\InteractiveValues\InteractiveDictionary.cs" />
|
||||||
<Compile Include="UI\InteractiveValues\InteractiveEnum.cs" />
|
<Compile Include="UI\InteractiveValues\InteractiveEnum.cs" />
|
||||||
<Compile Include="UI\InteractiveValues\InteractiveEnumerable.cs" />
|
<Compile Include="UI\InteractiveValues\InteractiveEnumerable.cs" />
|
||||||
|
Reference in New Issue
Block a user