mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 14:17:51 +08:00
Fix setting color block when partially stripped
This commit is contained in:
parent
3762d14bdb
commit
7a2b4aa257
@ -160,38 +160,56 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
.Invoke(handle);
|
.Invoke(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool? s_doPropertiesExist;
|
internal static bool triedToGetProperties;
|
||||||
|
internal static PropertyInfo _normalColorProp;
|
||||||
|
internal static PropertyInfo _highlightColorProp;
|
||||||
|
internal static PropertyInfo _pressedColorProp;
|
||||||
|
|
||||||
public override ColorBlock SetColorBlock(ColorBlock colors, Color? normal = null, Color? highlighted = null, Color? pressed = null)
|
public override ColorBlock SetColorBlock(ColorBlock colors, Color? normal = null, Color? highlighted = null, Color? pressed = null)
|
||||||
{
|
{
|
||||||
if (s_doPropertiesExist == null)
|
|
||||||
{
|
|
||||||
var prop = ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "normalColor") as PropertyInfo;
|
|
||||||
s_doPropertiesExist = prop != null && prop.CanWrite;
|
|
||||||
}
|
|
||||||
|
|
||||||
colors.colorMultiplier = 1;
|
colors.colorMultiplier = 1;
|
||||||
|
|
||||||
object boxed = (object)colors;
|
object boxed = (object)colors;
|
||||||
|
|
||||||
if (s_doPropertiesExist == true)
|
if (!triedToGetProperties)
|
||||||
|
{
|
||||||
|
triedToGetProperties = true;
|
||||||
|
|
||||||
|
if (ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "normalColor") is PropertyInfo norm && norm.CanWrite)
|
||||||
|
_normalColorProp = norm;
|
||||||
|
if (ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "highlightedColor") is PropertyInfo high && high.CanWrite)
|
||||||
|
_highlightColorProp = high;
|
||||||
|
if (ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "pressedColor") is PropertyInfo pres && pres.CanWrite)
|
||||||
|
_pressedColorProp = pres;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (normal != null)
|
if (normal != null)
|
||||||
ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "normalColor").SetValue(boxed, (Color)normal);
|
{
|
||||||
if (pressed != null)
|
if (_normalColorProp != null)
|
||||||
ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "pressedColor").SetValue(boxed, (Color)pressed);
|
_normalColorProp.SetValue(boxed, (Color)normal);
|
||||||
|
else if (ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_NormalColor") is FieldInfo fi)
|
||||||
|
fi.SetValue(boxed, (Color)normal);
|
||||||
|
}
|
||||||
|
|
||||||
if (highlighted != null)
|
if (highlighted != null)
|
||||||
ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "highlightedColor").SetValue(boxed, (Color)highlighted);
|
{
|
||||||
}
|
if (_highlightColorProp != null)
|
||||||
else if (s_doPropertiesExist == false)
|
_highlightColorProp.SetValue(boxed, (Color)highlighted);
|
||||||
{
|
else if (ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_HighlightedColor") is FieldInfo fi)
|
||||||
if (normal != null)
|
fi.SetValue(boxed, (Color)highlighted);
|
||||||
ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_NormalColor").SetValue(boxed, (Color)normal);
|
}
|
||||||
|
|
||||||
if (pressed != null)
|
if (pressed != null)
|
||||||
ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_PressedColor").SetValue(boxed, (Color)pressed);
|
{
|
||||||
if (highlighted != null)
|
if (_pressedColorProp != null)
|
||||||
ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_HighlightedColor").SetValue(boxed, (Color)highlighted);
|
_pressedColorProp.SetValue(boxed, (Color)pressed);
|
||||||
|
else if (ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_PressedColor") is FieldInfo fi)
|
||||||
|
fi.SetValue(boxed, (Color)pressed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
colors = (ColorBlock)boxed;
|
colors = (ColorBlock)boxed;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user