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

Commit ad54d2c

Browse files
committed
2.0.2
* Added support for viewing Texture2D (and Sprite) from the Inspector, and exporting them to PNG * Fixed an issue with generic methods not showing their return value type * Fixed an issue where destroyed UnityEngine.Objects would cause issues in the inspector * Fixed an issue when caching a ValueCollection of a Dictionary (the generic argument for the Entry Type is the last arg, not the first as with other Enumerables)
1 parent 867370c commit ad54d2c

File tree

14 files changed

+399
-56
lines changed

14 files changed

+399
-56
lines changed

src/CacheObject/CacheMember.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void DrawArgsInput()
129129

130130
GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) });
131131
GUILayout.Label(label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) });
132-
this.m_argumentInput[i] = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) });
132+
this.m_argumentInput[i] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) });
133133

134134
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
135135

src/CacheObject/CacheMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void Evaluate()
7373
if (ret != null)
7474
{
7575
//m_cachedReturnValue = CacheFactory.GetTypeAndCacheObject(ret);
76-
m_cachedReturnValue = CacheFactory.GetCacheObject(ret, IValue.ValueType);
76+
m_cachedReturnValue = CacheFactory.GetCacheObject(ret);
7777
m_cachedReturnValue.UpdateValue();
7878
}
7979
else

src/CacheObject/CacheObjectBase.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,22 @@ public virtual void Init(object obj, Type valueType)
2525
return;
2626
}
2727

28+
//ExplorerCore.Log("Initializing InteractiveValue of type " + valueType.FullName);
29+
2830
InteractiveValue interactive;
2931

3032
if (valueType == typeof(GameObject) || valueType == typeof(Transform))
3133
{
3234
interactive = new InteractiveGameObject();
3335
}
36+
else if (valueType == typeof(Texture2D))
37+
{
38+
interactive = new InteractiveTexture2D();
39+
}
40+
else if (valueType == typeof(Sprite))
41+
{
42+
interactive = new InteractiveSprite();
43+
}
3444
else if (valueType.IsPrimitive || valueType == typeof(string))
3545
{
3646
interactive = new InteractivePrimitive();

src/Config/ModConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class ModConfig
1919
public int Default_Page_Limit = 20;
2020
public bool Bitwise_Support = false;
2121
public bool Tab_View = true;
22-
//public bool Main_Toggle_Global = true;
22+
public string Default_Output_Path = @"Mods\Explorer";
2323

2424
public static void OnLoad()
2525
{

src/Explorer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@
212212
<Compile Include="UI\InteractiveValue\Object\InteractiveDictionary.cs" />
213213
<Compile Include="UI\InteractiveValue\Object\InteractiveEnumerable.cs" />
214214
<Compile Include="UI\InteractiveValue\Object\InteractiveGameObject.cs" />
215+
<Compile Include="UI\InteractiveValue\Object\InteractiveSprite.cs" />
216+
<Compile Include="UI\InteractiveValue\Object\InteractiveTexture2D.cs" />
215217
<Compile Include="UI\InteractiveValue\Struct\InteractiveQuaternion.cs" />
216218
<Compile Include="UI\InteractiveValue\Struct\InteractiveRect.cs" />
217219
<Compile Include="UI\InteractiveValue\Struct\InteractiveVector.cs" />
@@ -257,6 +259,7 @@
257259
<Compile Include="UI\TabViewWindow.cs" />
258260
<Compile Include="UI\WindowBase.cs" />
259261
<Compile Include="UI\WindowManager.cs" />
262+
<Compile Include="Unstrip\ImageConversion\ImageConversionUnstrip.cs" />
260263
<Compile Include="Unstrip\Scene\SceneUnstrip.cs" />
261264
<Compile Include="Unstrip\IMGUI\GUIUnstrip.cs" />
262265
<Compile Include="Unstrip\IMGUI\Internal_LayoutUtility.cs" />

src/Tests/TestClass.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEngine;
55
using System.Reflection;
66
using System.Runtime.InteropServices;
7+
using Explorer.UI.Shared;
78
#if CPP
89
using UnhollowerBaseLib;
910
using UnityEngine.SceneManagement;
@@ -33,6 +34,9 @@ public class TestClass
3334
public static TestClass Instance => m_instance ?? (m_instance = new TestClass());
3435
private static TestClass m_instance;
3536

37+
public Texture2D TestTexture = UIStyles.MakeTex(200, 200, Color.white);
38+
public static Sprite TestSprite;
39+
3640
public static int StaticProperty => 5;
3741
public static int StaticField = 5;
3842
public int NonStaticField;
@@ -52,6 +56,16 @@ public class TestClass
5256
public TestClass()
5357
{
5458
#if CPP
59+
TestTexture.name = "TestTexture";
60+
61+
var r = new Rect(0, 0, TestTexture.width, TestTexture.height);
62+
var v2 = Vector2.zero;
63+
var v4 = Vector4.zero;
64+
TestSprite = Sprite.CreateSprite_Injected(TestTexture, ref r, ref v2, 100f, 0u, SpriteMeshType.Tight, ref v4, false);
65+
66+
GameObject.DontDestroyOnLoad(TestTexture);
67+
GameObject.DontDestroyOnLoad(TestSprite);
68+
5569
ILHashSetTest = new Il2CppSystem.Collections.Generic.HashSet<string>();
5670
ILHashSetTest.Add("1");
5771
ILHashSetTest.Add("2");

src/UI/Inspectors/ReflectionInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private void CacheMembers(Type[] types)
160160
{
161161
try
162162
{
163-
// make sure member type is Field, Method of Property (4 / 8 / 16)
163+
// make sure member type is Field, Method or Property (4 / 8 / 16)
164164
int m = (int)member.MemberType;
165165
if (m < 4 || m > 16)
166166
continue;

src/UI/InteractiveValue/InteractiveValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void Draw(Rect window, float labelWidth = 215f)
146146
{
147147
GUILayout.Label($"<color=grey><i>Not yet evaluated</i></color> ({typeName})", new GUILayoutOption[0]);
148148
}
149-
else if (Value == null && !(cacheMember is CacheMethod))
149+
else if ((Value == null || Value is UnityEngine.Object uObj && !uObj) && !(cacheMember is CacheMethod))
150150
{
151151
GUILayout.Label($"<i>null ({typeName})</i>", new GUILayoutOption[0]);
152152
}

src/UI/InteractiveValue/Object/InteractiveEnumerable.cs

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -173,38 +173,20 @@ private IList CppIListToMono()
173173

174174
private Type GetEntryType()
175175
{
176-
if (m_entryType == null)
176+
if (ValueType.IsGenericType)
177177
{
178-
if (OwnerCacheObject is CacheMember cacheMember && cacheMember.MemInfo != null)
179-
{
180-
Type memberType = null;
181-
switch (cacheMember.MemInfo.MemberType)
182-
{
183-
case MemberTypes.Field:
184-
memberType = (cacheMember.MemInfo as FieldInfo).FieldType;
185-
break;
186-
case MemberTypes.Property:
187-
memberType = (cacheMember.MemInfo as PropertyInfo).PropertyType;
188-
break;
189-
}
178+
var gArgs = ValueType.GetGenericArguments();
190179

191-
if (memberType != null && memberType.IsGenericType)
192-
{
193-
m_entryType = memberType.GetGenericArguments()[0];
194-
}
180+
if (ValueType.FullName.Contains("ValueCollection"))
181+
{
182+
m_entryType = gArgs[gArgs.Length - 1];
195183
}
196-
else if (Value != null)
184+
else
197185
{
198-
var type = Value.GetType();
199-
if (type.IsGenericType)
200-
{
201-
m_entryType = type.GetGenericArguments()[0];
202-
}
186+
m_entryType = gArgs[0];
203187
}
204188
}
205-
206-
// use System.Object for non-generic.
207-
if (m_entryType == null)
189+
else
208190
{
209191
m_entryType = typeof(object);
210192
}
@@ -255,18 +237,11 @@ public void CacheEntries()
255237
}
256238
#endif
257239

240+
//ExplorerCore.Log("Caching enumeration entry " + obj.ToString() + " as " + EntryType.FullName);
241+
258242
var cached = new CacheEnumerated() { Index = index, RefIList = Value as IList, ParentEnumeration = this };
259243
cached.Init(obj, EntryType);
260244
list.Add(cached);
261-
262-
//if (CacheFactory.GetCacheObject(obj, t) is CacheObjectBase cached)
263-
//{
264-
// list.Add(cached);
265-
//}
266-
//else
267-
//{
268-
// list.Add(null);
269-
//}
270245
}
271246
else
272247
{
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using UnityEngine;
6+
7+
namespace Explorer.UI
8+
{
9+
public class InteractiveSprite : InteractiveTexture2D
10+
{
11+
public override void GetTexture2D()
12+
{
13+
#if CPP
14+
if (Value != null && Value.Il2CppCast(typeof(Sprite)) is Sprite sprite)
15+
#else
16+
if (Value is Sprite sprite)
17+
#endif
18+
{
19+
currentTex = sprite.texture;
20+
texContent = new GUIContent
21+
{
22+
image = currentTex
23+
};
24+
}
25+
}
26+
27+
}
28+
}

0 commit comments

Comments
 (0)