Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit b1264c6

Browse files
committed
1.5.6
* Added a fallback method for GetRootSceneObjects for games where this fails. * Fixed an issue where the `new Rect(Rect source)` constructor was failing in some games, using the normal ctor now. * Added special support for `Vector2`, `Vector3`, `Vector4`, `Quaternion`, `Color` and `Rect` structs in the reflection inspector to allow for easier editing. * Several improvements to GameObject Inspector, such as position/rotation freezing, local/global context, and an improved way to edit the transform values.
1 parent 9836566 commit b1264c6

18 files changed

+665
-119
lines changed

src/CachedObjects/CacheObjectBase.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Reflection;
55
using System.Text;
66
using System.Threading.Tasks;
7+
using Explorer.CachedObjects;
78
using MelonLoader;
89
using UnhollowerBaseLib;
910
using UnityEngine;
@@ -137,6 +138,22 @@ private static CacheObjectBase GetCacheObjectImpl(object obj, MemberInfo memberI
137138
{
138139
holder = new CacheEnum();
139140
}
141+
else if (valueType == typeof(Vector2) || valueType == typeof(Vector3) || valueType == typeof(Vector4))
142+
{
143+
holder = new CacheVector();
144+
}
145+
else if (valueType == typeof(Quaternion))
146+
{
147+
holder = new CacheQuaternion();
148+
}
149+
else if (valueType == typeof(Color))
150+
{
151+
holder = new CacheColor();
152+
}
153+
else if (valueType == typeof(Rect))
154+
{
155+
holder = new CacheRect();
156+
}
140157
else if (ReflectionHelpers.IsArray(valueType) || ReflectionHelpers.IsList(valueType))
141158
{
142159
holder = new CacheList();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using UnityEngine;
7+
8+
namespace Explorer.CachedObjects
9+
{
10+
public class CacheColor : CacheObjectBase
11+
{
12+
private string r = "0";
13+
private string g = "0";
14+
private string b = "0";
15+
private string a = "0";
16+
17+
public override void UpdateValue()
18+
{
19+
base.UpdateValue();
20+
21+
var color = (Color)Value;
22+
23+
r = color.r.ToString();
24+
g = color.g.ToString();
25+
b = color.b.ToString();
26+
a = color.a.ToString();
27+
}
28+
29+
public override void DrawValue(Rect window, float width)
30+
{
31+
GUILayout.Label($"<color=yellow>Color</color>: {(Color)Value}", null);
32+
33+
if (CanWrite)
34+
{
35+
GUILayout.EndHorizontal();
36+
var whitespace = window.width - width - 90;
37+
38+
GUILayout.BeginHorizontal(null);
39+
GUILayout.Space(whitespace);
40+
GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) });
41+
r = GUILayout.TextField(r, new GUILayoutOption[] { GUILayout.Width(70) });
42+
GUILayout.EndHorizontal();
43+
44+
GUILayout.BeginHorizontal(null);
45+
GUILayout.Space(whitespace);
46+
GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) });
47+
g = GUILayout.TextField(g, new GUILayoutOption[] { GUILayout.Width(70) });
48+
GUILayout.EndHorizontal();
49+
50+
GUILayout.BeginHorizontal(null);
51+
GUILayout.Space(whitespace);
52+
GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) });
53+
b = GUILayout.TextField(b, new GUILayoutOption[] { GUILayout.Width(70) });
54+
GUILayout.EndHorizontal();
55+
56+
GUILayout.BeginHorizontal(null);
57+
GUILayout.Space(whitespace);
58+
GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) });
59+
a = GUILayout.TextField(a, new GUILayoutOption[] { GUILayout.Width(70) });
60+
GUILayout.EndHorizontal();
61+
62+
// draw set value button
63+
GUILayout.BeginHorizontal(null);
64+
GUILayout.Space(whitespace);
65+
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(130) }))
66+
{
67+
SetValueFromInput();
68+
}
69+
GUILayout.EndHorizontal();
70+
71+
GUILayout.BeginHorizontal(null);
72+
}
73+
}
74+
75+
private void SetValueFromInput()
76+
{
77+
if (float.TryParse(r, out float fR)
78+
&& float.TryParse(g, out float fG)
79+
&& float.TryParse(b, out float fB)
80+
&& float.TryParse(a, out float fA))
81+
{
82+
Value = new Color(fR, fB, fG, fA);
83+
}
84+
}
85+
}
86+
}
File renamed without changes.
File renamed without changes.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using UnityEngine;
7+
8+
namespace Explorer
9+
{
10+
public class CacheQuaternion : CacheObjectBase
11+
{
12+
private Vector3 EulerAngle = Vector3.zero;
13+
14+
private string x = "0";
15+
private string y = "0";
16+
private string z = "0";
17+
18+
public override void UpdateValue()
19+
{
20+
base.UpdateValue();
21+
22+
EulerAngle = ((Quaternion)Value).eulerAngles;
23+
24+
x = EulerAngle.x.ToString();
25+
y = EulerAngle.y.ToString();
26+
z = EulerAngle.z.ToString();
27+
}
28+
29+
public override void DrawValue(Rect window, float width)
30+
{
31+
GUILayout.Label($"<color=yellow>Quaternion</color>: {((Quaternion)Value).eulerAngles}", null);
32+
33+
if (CanWrite)
34+
{
35+
GUILayout.EndHorizontal();
36+
var whitespace = window.width - width - 90;
37+
38+
GUILayout.BeginHorizontal(null);
39+
GUILayout.Space(whitespace);
40+
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
41+
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(70) });
42+
GUILayout.EndHorizontal();
43+
44+
GUILayout.BeginHorizontal(null);
45+
GUILayout.Space(whitespace);
46+
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
47+
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(70) });
48+
GUILayout.EndHorizontal();
49+
50+
GUILayout.BeginHorizontal(null);
51+
GUILayout.Space(whitespace);
52+
GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
53+
z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(70) });
54+
GUILayout.EndHorizontal();
55+
56+
// draw set value button
57+
GUILayout.BeginHorizontal(null);
58+
GUILayout.Space(whitespace);
59+
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(130) }))
60+
{
61+
SetValueFromInput();
62+
}
63+
GUILayout.EndHorizontal();
64+
65+
GUILayout.BeginHorizontal(null);
66+
}
67+
}
68+
69+
private void SetValueFromInput()
70+
{
71+
if (float.TryParse(x, out float fX)
72+
&& float.TryParse(y, out float fY)
73+
&& float.TryParse(z, out float fZ))
74+
{
75+
Value = Quaternion.Euler(new Vector3(fX, fY, fZ));
76+
SetValue();
77+
}
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)