* Added InteractiveColor UI editor to make changing a Color easier
* Added a "Scene Loader" helper which allows you to load any Scene that the game was built with. In some cases you may not find all the Scenes that the game uses, they may be loaded through AssetBundles or other means and won't show up here yet
* Adjusted the SceneExplorer UI, the "Hide" button is now always on the left of the window
*
* Handled some errors related to UI unstripping that could occur in rare cases
This commit is contained in:
Sinai 2021-03-31 22:58:17 +11:00
parent 89f137680e
commit 8f025622b4
29 changed files with 441 additions and 229 deletions

View File

@ -11,7 +11,7 @@ namespace UnityExplorer.Core
{
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>
/// 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>
/// Helper to display a simple "{ExceptionType}: {Message}" of the exception, and optionally use the inner-most exception.
/// </summary>

View File

@ -13,6 +13,7 @@ using UnityEngine.SceneManagement;
using System.Collections;
using UnityEngine.UI;
using UnityExplorer.Core.Input;
using UnityEngine.EventSystems;
namespace UnityExplorer.Core.Runtime.Il2Cpp
{
@ -121,17 +122,42 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
.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.
var evt = InputManager.InputPointerEvent;
if (evt != null)
if (s_doPropertiesExist == null)
{
if (!evt.eligibleForClick && evt.selectedObject)
evt.eligibleForClick = true;
var prop = ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "normalColor") as PropertyInfo;
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;
}
}
}

View File

@ -43,7 +43,7 @@ namespace UnityExplorer.Core.Runtime.Mono
public override UnityEngine.Object[] FindObjectsOfTypeAll(Type 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)
{
@ -60,9 +60,18 @@ namespace UnityExplorer.Core.Runtime.Mono
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;
}
}
}

View File

@ -52,9 +52,9 @@ namespace UnityExplorer.Core.Runtime.Mono
private static MethodInfo GetEncodeToPNGMethod()
{
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)
return m_encodeToPNGMethod = method;

View File

@ -52,6 +52,6 @@ namespace UnityExplorer.Core.Runtime
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);
}
}

View File

@ -12,7 +12,7 @@ namespace UnityExplorer
public class ExplorerCore
{
public const string NAME = "UnityExplorer";
public const string VERSION = "3.3.1";
public const string VERSION = "3.3.2";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityExplorer.Core;
using UnityExplorer.Core.Config;
namespace UnityExplorer.Loader.ML
@ -66,6 +67,11 @@ namespace UnityExplorer.Loader.ML
return default;
}
public override void OnAnyConfigChanged()
{
MelonPreferences.Save();
}
public override void SaveConfig()
{
MelonPreferences.Save();

View File

@ -49,13 +49,9 @@ namespace UnityExplorer.UI.CacheObject
public override void SetValue()
{
RefConfig.BoxedValue = IValue.Value;
ConfigManager.Handler.OnAnyConfigChanged();
}
internal GameObject m_mainGroup;
//internal GameObject m_leftGroup;
//internal GameObject m_rightGroup;
//internal GameObject m_secondRow;
internal override void ConstructUI()
{
@ -66,11 +62,6 @@ namespace UnityExplorer.UI.CacheObject
var horiGroup = UIFactory.CreateHorizontalGroup(m_mainGroup, "ConfigEntryHolder", false, false, true, true, childAlignment: TextAnchor.MiddleLeft);
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: 200, flexibleWidth: 0);
// config entry label
var configLabel = UIFactory.CreateLabel(horiGroup, "ConfigLabel", this.RefConfig.Name, TextAnchor.MiddleLeft);
@ -91,20 +82,11 @@ namespace UnityExplorer.UI.CacheObject
new Color(0.3f, 0.3f, 0.3f));
UIFactory.SetLayoutElement(defaultButton.gameObject, minWidth: 80, minHeight: 22, flexibleWidth: 0);
//// right group
//m_rightGroup = UIFactory.CreateVerticalGroup(horiGroup, "ConfigValueGroup", false, false, true, true, 4, default, new Color(1, 1, 1, 0));
//UIFactory.SetLayoutElement(m_rightGroup, minHeight: 25, minWidth: 150, flexibleHeight: 0, flexibleWidth: 5000);
// 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);
//// Second row (IValue)
//m_secondRow = UIFactory.CreateHorizontalGroup(m_mainGroup, "DescriptionRow", false, false, true, true, 4, new Color(0.08f, 0.08f, 0.08f));
// IValue
if (IValue != null)

View File

@ -320,9 +320,8 @@ namespace UnityExplorer.UI.CacheObject
UIFactory.SetLayoutElement(evalGroupObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 5000);
var colors = new ColorBlock();
colors.normalColor = new Color(0.4f, 0.4f, 0.4f);
colors.highlightedColor = new Color(0.4f, 0.7f, 0.4f);
colors.pressedColor = new Color(0.3f, 0.3f, 0.3f);
colors = RuntimeProvider.Instance.SetColorBlock(colors, new Color(0.4f, 0.4f, 0.4f),
new Color(0.4f, 0.7f, 0.4f), new Color(0.3f, 0.3f, 0.3f));
var evalButton = UIFactory.CreateButton(evalGroupObj,
"EvalButton",
@ -346,9 +345,7 @@ namespace UnityExplorer.UI.CacheObject
argsHolder.SetActive(true);
m_isEvaluating = true;
evalText.text = "Evaluate";
colors = evalButton.colors;
colors.normalColor = new Color(0.3f, 0.6f, 0.3f);
evalButton.colors = colors;
evalButton.colors = RuntimeProvider.Instance.SetColorBlock(evalButton.colors, new Color(0.3f, 0.6f, 0.3f));
cancelButton.gameObject.SetActive(true);
}
@ -368,9 +365,7 @@ namespace UnityExplorer.UI.CacheObject
m_isEvaluating = false;
evalText.text = $"Evaluate ({ParamCount})";
colors = evalButton.colors;
colors.normalColor = new Color(0.4f, 0.4f, 0.4f);
evalButton.colors = colors;
evalButton.colors = RuntimeProvider.Instance.SetColorBlock(evalButton.colors, new Color(0.4f, 0.4f, 0.4f));
});
}
else if (this is CacheMethod)
@ -378,9 +373,8 @@ namespace UnityExplorer.UI.CacheObject
// simple method evaluate button
var colors = new ColorBlock();
colors.normalColor = new Color(0.4f, 0.4f, 0.4f);
colors.highlightedColor = new Color(0.4f, 0.7f, 0.4f);
colors.pressedColor = new Color(0.3f, 0.3f, 0.3f);
colors = RuntimeProvider.Instance.SetColorBlock(colors, new Color(0.4f, 0.4f, 0.4f),
new Color(0.4f, 0.7f, 0.4f), new Color(0.3f, 0.3f, 0.3f));
var evalButton = UIFactory.CreateButton(m_rightGroup, "EvalButton", "Evaluate", () => { (this as CacheMethod).Evaluate(); }, colors);
UIFactory.SetLayoutElement(evalButton.gameObject, minWidth: 100, minHeight: 22, flexibleWidth: 0);

View File

@ -88,13 +88,13 @@ namespace UnityExplorer.UI.InteractiveValues
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);
m_toggle.onValueChanged.AddListener(OnToggleValueChanged);
m_baseLabel.transform.SetAsLastSibling();
m_applyBtn = UIFactory.CreateButton(m_valueContent,
m_applyBtn = UIFactory.CreateButton(m_mainContent,
"ApplyButton",
"Apply",
() => { Owner.SetValue(); },

View 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
}
}

View File

@ -102,7 +102,7 @@ namespace UnityExplorer.UI.InteractiveValues
labelLayout.minWidth = 50;
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);
m_valueInput = inputObj.GetComponent<InputField>();
@ -110,7 +110,7 @@ namespace UnityExplorer.UI.InteractiveValues
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);
}
}

View File

@ -115,7 +115,7 @@ namespace UnityExplorer.UI.InteractiveValues
m_labelLayout = m_baseLabel.gameObject.GetComponent<LayoutElement>();
m_readonlyInput = UIFactory.CreateLabel(m_valueContent, "ReadonlyLabel", "", TextAnchor.MiddleLeft);
m_readonlyInput = UIFactory.CreateLabel(m_mainContent, "ReadonlyLabel", "", TextAnchor.MiddleLeft);
m_readonlyInput.horizontalOverflow = HorizontalWrapMode.Overflow;
var testFitter = m_readonlyInput.gameObject.AddComponent<ContentSizeFitter>();

View File

@ -183,7 +183,7 @@ namespace UnityExplorer.UI.InteractiveValues
typeof(Vector3),
typeof(Vector4),
typeof(Rect),
typeof(Color) // todo might make a special editor for colors
//typeof(Color) // todo might make a special editor for colors
};
//~~~~~~~~~ Instance ~~~~~~~~~~

View File

@ -46,6 +46,8 @@ namespace UnityExplorer.UI.InteractiveValues
return typeof(InteractiveEnum);
}
// check for unity struct types
else if (typeof(Color).IsAssignableFrom(type))
return typeof(InteractiveColor);
else if (InteractiveUnityStruct.SupportsType(type))
return typeof(InteractiveUnityStruct);
// check Transform, force InteractiveValue so they dont become InteractiveEnumerables.
@ -95,11 +97,11 @@ namespace UnityExplorer.UI.InteractiveValues
public virtual void OnDestroy()
{
if (this.m_valueContent)
if (this.m_mainContent)
{
m_valueContent.transform.SetParent(null, false);
m_valueContent.SetActive(false);
GameObject.Destroy(this.m_valueContent.gameObject);
m_mainContent.transform.SetParent(null, false);
m_mainContent.SetActive(false);
GameObject.Destroy(this.m_mainContent.gameObject);
}
DestroySubContent();
@ -293,7 +295,7 @@ namespace UnityExplorer.UI.InteractiveValues
internal GameObject m_mainContentParent;
internal GameObject m_subContentParent;
internal GameObject m_valueContent;
internal GameObject m_mainContent;
internal GameObject m_inspectButton;
internal Text m_baseLabel;
@ -304,24 +306,24 @@ namespace UnityExplorer.UI.InteractiveValues
{
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);
var mainRect = m_valueContent.GetComponent<RectTransform>();
var mainRect = m_mainContent.GetComponent<RectTransform>();
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
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);
}
// inspect button
var inspectBtn = UIFactory.CreateButton(m_valueContent,
var inspectBtn = UIFactory.CreateButton(m_mainContent,
"InspectButton",
"Inspect",
() =>
@ -338,7 +340,7 @@ namespace UnityExplorer.UI.InteractiveValues
// value label
m_baseLabel = UIFactory.CreateLabel(m_valueContent, "ValueLabel", "", TextAnchor.MiddleLeft);
m_baseLabel = UIFactory.CreateLabel(m_mainContent, "ValueLabel", "", TextAnchor.MiddleLeft);
UIFactory.SetLayoutElement(m_baseLabel.gameObject, flexibleWidth: 9000, minHeight: 25);
m_subContentParent = subGroup;

View File

@ -5,6 +5,8 @@ using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityExplorer.Core.CSharp;
using UnityExplorer.Core.Input;
using UnityExplorer.Core.Runtime;
using UnityExplorer.Core.Unity;
using UnityExplorer.UI;
using UnityExplorer.UI.Main;
@ -41,16 +43,12 @@ namespace UnityExplorer.UI.Main.CSConsole
public static void Update()
{
if (!m_mainObj)
{
return;
}
if (!CSharpConsole.EnableAutocompletes)
{
if (m_mainObj.activeSelf)
{
m_mainObj.SetActive(false);
}
return;
}
@ -274,8 +272,7 @@ namespace UnityExplorer.UI.Main.CSConsole
mainGroup.childForceExpandWidth = true;
ColorBlock btnColors = new ColorBlock();
btnColors.normalColor = new Color(0f, 0f, 0f, 0f);
btnColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1.0f);
RuntimeProvider.Instance.SetColorBlock(btnColors, new Color(0, 0, 0, 0), highlighted: new Color(0.2f, 0.2f, 0.2f, 1.0f));
for (int i = 0; i < MAX_LABELS; i++)
{

View File

@ -141,18 +141,13 @@ namespace UnityExplorer.UI.Main.Home
public void OnSetInspectorTab(InspectorBase inspector)
{
Color activeColor = new Color(0, 0.25f, 0, 1);
ColorBlock colors = inspector.m_tabButton.colors;
colors.normalColor = activeColor;
colors.highlightedColor = activeColor;
inspector.m_tabButton.colors = colors;
inspector.m_tabButton.colors = RuntimeProvider.Instance.SetColorBlock(inspector.m_tabButton.colors, activeColor, activeColor);
}
public void OnUnsetInspectorTab()
{
ColorBlock colors = m_activeInspector.m_tabButton.colors;
colors.normalColor = new Color(0.2f, 0.2f, 0.2f, 1);
colors.highlightedColor = new Color(0.1f, 0.3f, 0.1f, 1);
m_activeInspector.m_tabButton.colors = colors;
m_activeInspector.m_tabButton.colors = RuntimeProvider.Instance.SetColorBlock(m_activeInspector.m_tabButton.colors,
new Color(0.2f, 0.2f, 0.2f, 1), new Color(0.1f, 0.3f, 0.1f, 1));
}
public void ConstructInspectorPane()

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Core.Runtime;
using UnityExplorer.UI.Utility;
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
@ -168,9 +169,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); });
ColorBlock mainColors = new ColorBlock();
mainColors.normalColor = new Color(0.07f, 0.07f, 0.07f);
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1);
mainColors.pressedColor = new Color(0.05f, 0.05f, 0.05f);
RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.07f, 0.07f, 0.07f),
new Color(0.2f, 0.2f, 0.2f, 1), new Color(0.05f, 0.05f, 0.05f));
var mainBtn = UIFactory.CreateButton(btnGroupObj,
"MainButton",

View File

@ -5,6 +5,7 @@ using System.Text;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Core;
using UnityExplorer.Core.Runtime;
using UnityExplorer.UI.Utility;
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
@ -175,9 +176,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
// Main component button
ColorBlock mainColors = new ColorBlock();
mainColors.normalColor = new Color(0.07f, 0.07f, 0.07f);
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1);
mainColors.pressedColor = new Color(0.05f, 0.05f, 0.05f);
RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.07f, 0.07f, 0.07f),
new Color(0.2f, 0.2f, 0.2f, 1), new Color(0.05f, 0.05f, 0.05f));
var mainBtn = UIFactory.CreateButton(groupObj,
"MainButton",

View File

@ -5,6 +5,7 @@ using System.Text;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Core.Input;
using UnityExplorer.Core.Runtime;
using UnityExplorer.Core.Unity;
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
@ -407,9 +408,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
var sliderObj = UIFactory.CreateSlider(rowObject, "VectorSlider", out Slider slider);
UIFactory.SetLayoutElement(sliderObj, minHeight: 20, flexibleHeight: 0, minWidth: 200, flexibleWidth: 9000);
sliderObj.transform.Find("Fill Area").gameObject.SetActive(false);
var sliderColors = slider.colors;
sliderColors.normalColor = new Color(0.65f, 0.65f, 0.65f);
slider.colors = sliderColors;
slider.colors = RuntimeProvider.Instance.SetColorBlock(slider.colors, new Color(0.65f, 0.65f, 0.65f));
slider.minValue = -2;
slider.maxValue = 2;
slider.value = 0;

View File

@ -30,18 +30,12 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.Reflection
internal void OnScopeFilterClicked(MemberScopes type, Button button)
{
if (m_lastActiveScopeButton)
{
var lastColors = m_lastActiveScopeButton.colors;
lastColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
m_lastActiveScopeButton.colors = lastColors;
}
m_lastActiveScopeButton.colors = RuntimeProvider.Instance.SetColorBlock(m_lastActiveScopeButton.colors, new Color(0.2f, 0.2f, 0.2f));
m_scopeFilter = type;
m_lastActiveScopeButton = button;
var colors = m_lastActiveScopeButton.colors;
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
m_lastActiveScopeButton.colors = colors;
m_lastActiveScopeButton.colors = RuntimeProvider.Instance.SetColorBlock(m_lastActiveScopeButton.colors, new Color(0.2f, 0.6f, 0.2f));
FilterMembers(null, true);
m_sliderScroller.m_slider.value = 1f;
@ -246,17 +240,14 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.Reflection
btn.onClick.AddListener(() => { OnScopeFilterClicked(type, btn); });
var colors = btn.colors;
colors.highlightedColor = new Color(0.3f, 0.7f, 0.3f);
btn.colors = RuntimeProvider.Instance.SetColorBlock(btn.colors, highlighted: new Color(0.3f, 0.7f, 0.3f));
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_lastActiveScopeButton = btn;
}
btn.colors = colors;
}
}
}

View File

@ -7,6 +7,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Core;
using UnityExplorer.Core.Config;
using UnityExplorer.Core.Runtime;
using UnityExplorer.UI.CacheObject;
using UnityExplorer.UI.Utility;
@ -238,18 +239,12 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.Reflection
internal void OnMemberFilterClicked(MemberTypes type, Button button)
{
if (m_lastActiveMemButton)
{
var lastColors = m_lastActiveMemButton.colors;
lastColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
m_lastActiveMemButton.colors = lastColors;
}
m_lastActiveMemButton.colors = RuntimeProvider.Instance.SetColorBlock(m_lastActiveMemButton.colors, new Color(0.2f, 0.2f, 0.2f));
m_memberFilter = type;
m_lastActiveMemButton = button;
var colors = m_lastActiveMemButton.colors;
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
m_lastActiveMemButton.colors = colors;
m_lastActiveMemButton.colors = RuntimeProvider.Instance.SetColorBlock(m_lastActiveMemButton.colors, new Color(0.2f, 0.6f, 0.2f));
FilterMembers(null, true);
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);
btn.onClick.AddListener(() => { OnMemberFilterClicked(type, btn); });
var colors = btn.colors;
colors.highlightedColor = new Color(0.3f, 0.7f, 0.3f);
btn.colors = RuntimeProvider.Instance.SetColorBlock(btn.colors, highlighted: new Color(0.3f, 0.7f, 0.3f));
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_lastActiveMemButton = btn;
}
btn.colors = colors;
}
internal void ConstructUpdateRow()

View File

@ -11,6 +11,8 @@ using UnityExplorer.UI.Main.Home;
using UnityExplorer.Core.Config;
using UnityExplorer.UI.Utility;
using UnityExplorer.UI.Main.Search;
using System.IO;
using UnityExplorer.Core;
namespace UnityExplorer.UI.Main.Home
{
@ -56,11 +58,9 @@ namespace UnityExplorer.UI.Main.Home
internal readonly List<GameObject> m_shortList = new List<GameObject>();
private Text m_hideText;
private GameObject m_titleObj;
private GameObject m_sceneDropdownObj;
private GameObject m_scenePathGroupObj;
private GameObject m_scrollObj;
private LayoutElement m_leftLayout;
private GameObject m_mainContent;
internal static GameObject DontDestroyObject
{
@ -84,6 +84,30 @@ namespace UnityExplorer.UI.Main.Home
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()
{
if (Hiding || Time.realtimeSinceStartup - m_timeOfLastSceneUpdate < UPDATE_INTERVAL)
@ -223,39 +247,6 @@ namespace UnityExplorer.UI.Main.Home
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)
{
m_sceneDropdown.options.Clear();
@ -387,25 +378,32 @@ namespace UnityExplorer.UI.Main.Home
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));
UIFactory.SetLayoutElement(m_mainContent, minWidth: 350, flexibleWidth: 0);
m_leftLayout = leftPane.AddComponent<LayoutElement>();
m_leftLayout.minWidth = 350;
m_leftLayout.flexibleWidth = 0;
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(m_mainContent, true, true, true, true, spacing: 4, padTop: 8, 4, 4, 4);
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;
UIFactory.SetLayoutElement(m_titleObj, minHeight: 30, flexibleHeight: 0);
m_sceneDropdownObj = UIFactory.CreateDropdown(leftPane, out m_sceneDropdown, "", 14, null);
m_sceneDropdownObj = UIFactory.CreateDropdown(m_mainContent, out m_sceneDropdown, "", 14, null);
UIFactory.SetLayoutElement(m_sceneDropdownObj, minHeight: 40, minWidth: 320, flexibleWidth: 0, flexibleHeight: 0);
m_sceneDropdownText = m_sceneDropdown.transform.Find("Label").GetComponent<Text>();
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);
var backBtnObj = UIFactory.CreateButton(m_scenePathGroupObj,
@ -439,20 +437,68 @@ namespace UnityExplorer.UI.Main.Home
m_mainInspectBtn = mainInspectButton.gameObject;
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));
m_pageHandler = new PageHandler(scroller);
m_pageHandler.ConstructUI(leftPane);
m_pageHandler.ConstructUI(m_mainContent);
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));
hideButton.GetComponentInChildren<Text>().fontSize = 13;
m_hideText = hideButton.GetComponentInChildren<Text>();
var title2 = UIFactory.CreateLabel(m_mainContent, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 20);
UIFactory.SetLayoutElement(title2.gameObject, minHeight: 30, flexibleHeight: 0);
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()
@ -476,9 +522,8 @@ namespace UnityExplorer.UI.Main.Home
toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); });
ColorBlock mainColors = new ColorBlock();
mainColors.normalColor = new Color(0.1f, 0.1f, 0.1f);
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f);
mainColors.pressedColor = new Color(0.05f, 0.05f, 0.05f);
mainColors = RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.1f, 0.1f, 0.1f),
new Color(0.2f, 0.2f, 0.2f), new Color(0.05f, 0.05f, 0.05f));
var mainButton = UIFactory.CreateButton(btnGroupObj,
"MainButton",
@ -494,9 +539,8 @@ namespace UnityExplorer.UI.Main.Home
m_shortListTexts.Add(mainText);
ColorBlock inspectColors = new ColorBlock();
inspectColors.normalColor = new Color(0.15f, 0.15f, 0.15f);
inspectColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f);
inspectColors.pressedColor = new Color(0.1f, 0.1f, 0.1f);
inspectColors = RuntimeProvider.Instance.SetColorBlock(inspectColors, new Color(0.15f, 0.15f, 0.15f),
new Color(0.2f, 0.2f, 0.2f), new Color(0.1f, 0.1f, 0.1f));
var inspectButton = UIFactory.CreateButton(btnGroupObj,
"InspectButton",

View File

@ -10,6 +10,7 @@ using UnityExplorer.UI.Main.Home;
using UnityExplorer.UI.Main.Search;
using UnityExplorer.UI.Main.CSConsole;
using UnityExplorer.UI.Main.Options;
using UnityExplorer.Core.Runtime;
namespace UnityExplorer.UI.Main
{
@ -135,16 +136,12 @@ namespace UnityExplorer.UI.Main
internal void SetButtonActiveColors(Button button)
{
ColorBlock colors = button.colors;
colors.normalColor = m_navButtonSelected;
button.colors = colors;
button.colors = RuntimeProvider.Instance.SetColorBlock(button.colors, m_navButtonSelected);
}
internal void SetButtonInactiveColors(Button button)
{
ColorBlock colors = button.colors;
colors.normalColor = m_navButtonNormal;
button.colors = colors;
button.colors = RuntimeProvider.Instance.SetColorBlock(button.colors, m_navButtonNormal);
}
#region UI Construction
@ -183,9 +180,8 @@ namespace UnityExplorer.UI.Main
// Hide button
ColorBlock colorBlock = new ColorBlock();
colorBlock.normalColor = new Color(65f / 255f, 23f / 255f, 23f / 255f);
colorBlock.pressedColor = new Color(35f / 255f, 10f / 255f, 10f / 255f);
colorBlock.highlightedColor = new Color(156f / 255f, 0f, 0f);
RuntimeProvider.Instance.SetColorBlock(colorBlock, new Color(65f / 255f, 23f / 255f, 23f / 255f),
new Color(35f / 255f, 10f / 255f, 10f / 255f), new Color(156f / 255f, 0f, 0f));
var hideButton = UIFactory.CreateButton(titleBar,
"HideButton",
@ -213,9 +209,7 @@ namespace UnityExplorer.UI.Main
UIFactory.SetLayoutElement(navbarObj, minHeight: 25, flexibleHeight: 0);
ColorBlock colorBlock = new ColorBlock();
colorBlock.normalColor = m_navButtonNormal;
colorBlock.highlightedColor = m_navButtonHighlight;
colorBlock.pressedColor = m_navButtonSelected;
colorBlock = RuntimeProvider.Instance.SetColorBlock(colorBlock, m_navButtonNormal, m_navButtonHighlight, m_navButtonSelected);
foreach (var page in Pages)
{

View File

@ -259,10 +259,8 @@ namespace UnityExplorer.UI.Main.Search
m_selectedContextButton = button;
var colors = m_selectedContextButton.colors;
colors.normalColor = new Color(0.35f, 0.7f, 0.35f);
colors.highlightedColor = colors.normalColor;
m_selectedContextButton.colors = colors;
m_selectedContextButton.colors = RuntimeProvider.Instance.SetColorBlock(m_selectedContextButton.colors,
new Color(0.35f, 0.7f, 0.35f), new Color(0.35f, 0.7f, 0.35f));
m_context = context;
@ -439,12 +437,9 @@ namespace UnityExplorer.UI.Main.Search
UIFactory.SetLayoutElement(btnGroupObj, flexibleWidth: 320, minHeight: 25, flexibleHeight: 0);
btnGroupObj.AddComponent<Mask>();
var mainColors = new ColorBlock
{
normalColor = new Color(0.1f, 0.1f, 0.1f),
highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1),
pressedColor = new Color(0.05f, 0.05f, 0.05f)
};
var mainColors = new ColorBlock();
RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.1f, 0.1f, 0.1f),
new Color(0.2f, 0.2f, 0.2f), new Color(0.05f, 0.05f, 0.05f));
var mainButton = UIFactory.CreateButton(btnGroupObj,
"ResultButton",

View File

@ -52,27 +52,26 @@ namespace UnityExplorer.UI
internal static void SetDefaultSelectableColors(Selectable selectable)
{
ColorBlock colors = selectable.colors;
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));
selectable.colors = colors;
selectable.colors = RuntimeProvider.Instance.SetColorBlock(selectable.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));
// Deselect all Buttons after they are clicked.
if (selectable is Button button)
button.onClick.AddListener(() => { button.OnDeselect(null); });
}
public static void SetColorBlockValues(ref this ColorBlock colorBlock, Color? normal = null, Color? highlighted = null,
Color? pressed = null)
{
if (normal != null)
colorBlock.normalColor = (Color)normal;
//public static void SetColorBlockValues(ref this ColorBlock colorBlock, Color? normal = null, Color? highlighted = null,
// Color? pressed = null)
//{
// if (normal != null)
// colorBlock.normalColor = (Color)normal;
if (highlighted != null)
colorBlock.highlightedColor = (Color)highlighted;
// if (highlighted != null)
// colorBlock.highlightedColor = (Color)highlighted;
if (pressed != null)
colorBlock.pressedColor = (Color)pressed;
}
// if (pressed != null)
// colorBlock.pressedColor = (Color)pressed;
//}
/// <summary>
/// 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>
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,
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>();
if (!group)
group = gameObject.AddComponent<T>();
return SetLayoutGroup(group, forceWidth, forceHeight, childControlWidth, childControlHeight, spacing, padTop, padBottom, padLeft, padRight, childAlignment);
return SetLayoutGroup(group, forceWidth, forceHeight, childControlWidth, childControlHeight, spacing, padTop,
padBottom, padLeft, padRight, childAlignment);
}
/// <summary>
@ -128,7 +129,8 @@ namespace UnityExplorer.UI
/// </summary>
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,
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)
group.childForceExpandWidth = (bool)forceWidth;
@ -273,13 +275,9 @@ namespace UnityExplorer.UI
public static Button CreateButton(GameObject parent, string name, string text, Action onClick = null, Color? normalColor = null)
{
var colors = new ColorBlock();
if (normalColor != null)
colors.normalColor = (Color)normalColor;
else
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);
normalColor = normalColor ?? new Color(0.25f, 0.25f, 0.25f);
colors = RuntimeProvider.Instance.SetColorBlock(colors, normalColor, new Color(0.4f, 0.4f, 0.4f),
new Color(0.15f, 0.15f, 0.15f));
return CreateButton(parent, name, text, onClick, colors);
}
@ -366,7 +364,8 @@ namespace UnityExplorer.UI
slider.targetGraphic = handleImage;
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;
}
@ -505,12 +504,8 @@ namespace UnityExplorer.UI
mainInput.transition = Selectable.Transition.ColorTint;
mainInput.targetGraphic = mainImage;
ColorBlock mainColors = mainInput.colors;
mainColors.normalColor = new Color(1, 1, 1, 1);
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;
mainInput.colors = RuntimeProvider.Instance.SetColorBlock(mainInput.colors, 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));
SetLayoutGroup<VerticalLayoutGroup>(mainObj, true, true, true, true);
@ -614,10 +609,8 @@ namespace UnityExplorer.UI
Toggle itemToggle = itemObj.AddComponent<Toggle>();
itemToggle.targetGraphic = itemBgImage;
itemToggle.isOn = true;
ColorBlock colors = itemToggle.colors;
colors.normalColor = new Color(0.35f, 0.35f, 0.35f, 1.0f);
colors.highlightedColor = new Color(0.25f, 0.45f, 0.25f, 1.0f);
itemToggle.colors = colors;
itemToggle.colors = RuntimeProvider.Instance.SetColorBlock(itemToggle.colors,
new Color(0.35f, 0.35f, 0.35f, 1.0f), new Color(0.25f, 0.45f, 0.25f, 1.0f));
itemToggle.onValueChanged.AddListener((bool val) => { itemToggle.OnDeselect(null); });
Image templateImage = templateObj.AddComponent<Image>();

View File

@ -81,8 +81,6 @@ namespace UnityExplorer.UI
if (EventSystem.current != EventSys)
CursorUnlocker.SetEventSystem();
RuntimeProvider.Instance.CheckInputPointerEvent();
PanelDragger.Instance.Update();
SliderScrollbar.UpdateInstances();

View File

@ -186,7 +186,7 @@ public static class SliderExtensions
{
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;
}

View File

@ -265,6 +265,7 @@
<Compile Include="UI\CacheObject\CachePaired.cs" />
<Compile Include="UI\CacheObject\CacheProperty.cs" />
<Compile Include="UI\InteractiveValues\InteractiveBool.cs" />
<Compile Include="UI\InteractiveValues\InteractiveColor.cs" />
<Compile Include="UI\InteractiveValues\InteractiveDictionary.cs" />
<Compile Include="UI\InteractiveValues\InteractiveEnum.cs" />
<Compile Include="UI\InteractiveValues\InteractiveEnumerable.cs" />