mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 05:48:12 +08:00
Add support for setting disabled color on ColoBlock
This commit is contained in:
parent
a5a07a0a23
commit
a1c2dfbe50
@ -164,8 +164,10 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
internal static PropertyInfo _normalColorProp;
|
internal static PropertyInfo _normalColorProp;
|
||||||
internal static PropertyInfo _highlightColorProp;
|
internal static PropertyInfo _highlightColorProp;
|
||||||
internal static PropertyInfo _pressedColorProp;
|
internal static PropertyInfo _pressedColorProp;
|
||||||
|
internal static PropertyInfo _disabledColorProp;
|
||||||
|
|
||||||
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null)
|
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
|
||||||
|
Color? disabled = null)
|
||||||
{
|
{
|
||||||
var colors = selectable.colors;
|
var colors = selectable.colors;
|
||||||
|
|
||||||
@ -183,6 +185,8 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
_highlightColorProp = high;
|
_highlightColorProp = high;
|
||||||
if (ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "pressedColor") is PropertyInfo pres && pres.CanWrite)
|
if (ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "pressedColor") is PropertyInfo pres && pres.CanWrite)
|
||||||
_pressedColorProp = pres;
|
_pressedColorProp = pres;
|
||||||
|
if (ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "disabledColor") is PropertyInfo disa && disa.CanWrite)
|
||||||
|
_disabledColorProp = disa;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -210,6 +214,14 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
else if (ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_PressedColor") is FieldInfo fi)
|
else if (ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_PressedColor") is FieldInfo fi)
|
||||||
fi.SetValue(boxed, (Color)pressed);
|
fi.SetValue(boxed, (Color)pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (disabled != null)
|
||||||
|
{
|
||||||
|
if (_disabledColorProp != null)
|
||||||
|
_disabledColorProp.SetValue(boxed, (Color)disabled);
|
||||||
|
else if (ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_DisabledColor") is FieldInfo fi)
|
||||||
|
fi.SetValue(boxed, (Color)disabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,8 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
return scene.rootCount;
|
return scene.rootCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null)
|
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
|
||||||
|
Color? disabled = null)
|
||||||
{
|
{
|
||||||
var colors = selectable.colors;
|
var colors = selectable.colors;
|
||||||
|
|
||||||
@ -99,6 +100,9 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
if (pressed != null)
|
if (pressed != null)
|
||||||
colors.pressedColor = (Color)pressed;
|
colors.pressedColor = (Color)pressed;
|
||||||
|
|
||||||
|
if (disabled != null)
|
||||||
|
colors.disabledColor = (Color)disabled;
|
||||||
|
|
||||||
SetColorBlock(selectable, colors);
|
SetColorBlock(selectable, colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
public abstract void SetColorBlock(Selectable selectable, ColorBlock colors);
|
public abstract void SetColorBlock(Selectable selectable, ColorBlock colors);
|
||||||
|
|
||||||
public abstract void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null);
|
public abstract void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
|
||||||
|
Color? disabled = null);
|
||||||
|
|
||||||
public virtual void FindSingleton(string[] s_instanceNames, Type type, BindingFlags flags, List<object> instances)
|
public virtual void FindSingleton(string[] s_instanceNames, Type type, BindingFlags flags, List<object> instances)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user