* More fixes for failed unstripping, should fix most issues in Audica and other games
* If `GetRootSceneObjects` fails and we fall back to the manual implementation, the auto-update for root scene objects will be disabled. Instead, there will be a button to press to update the list.
* Transforms are now listed on the Components list in the GameObject inspector
* Various cleanups
This commit is contained in:
sinaioutlander 2020-09-06 03:19:21 +10:00
parent d0a4863139
commit ffb6cad8c2
8 changed files with 65 additions and 50 deletions

View File

@ -12,7 +12,7 @@ namespace Explorer
public class CppExplorer : MelonMod
{
public const string GUID = "com.sinai.cppexplorer";
public const string VERSION = "1.5.6";
public const string VERSION = "1.5.7";
public const string AUTHOR = "Sinai";
public const string NAME = "CppExplorer"

View File

@ -14,7 +14,7 @@ namespace Explorer
{
public class ConsolePage : WindowPage
{
public override string Name { get => "C# Console"; set => base.Name = value; }
public override string Name { get => "C# Console"; }
private ScriptEvaluator _evaluator;
private readonly StringBuilder _sb = new StringBuilder();

View File

@ -17,9 +17,7 @@ namespace Explorer
public PageHelper Pages = new PageHelper();
private float m_timeOfLastUpdate = -1f;
private static int PASSIVE_UPDATE_INTERVAL = 1;
private static bool m_getRootObjectsFailed = false;
private const int PASSIVE_UPDATE_INTERVAL = 1;
// ----- Holders for GUI elements ----- //
@ -54,7 +52,7 @@ namespace Explorer
if (m_searching)
CancelSearch();
Update_Impl();
Update_Impl(true);
}
public void TraverseUp()
@ -90,11 +88,12 @@ namespace Explorer
{
var matches = new List<GameObjectCache>();
foreach (var obj in Resources.FindObjectsOfTypeAll<GameObject>())
foreach (var obj in Resources.FindObjectsOfTypeAll(ReflectionHelpers.GameObjectType))
{
if (obj.name.ToLower().Contains(_search.ToLower()) && obj.scene.name == m_currentScene)
var go = obj.TryCast<GameObject>();
if (go.name.ToLower().Contains(_search.ToLower()) && go.scene.name == m_currentScene)
{
matches.Add(new GameObjectCache(obj));
matches.Add(new GameObjectCache(go));
}
}
@ -111,9 +110,9 @@ namespace Explorer
Update_Impl();
}
private void Update_Impl()
private void Update_Impl(bool manual = false)
{
var allTransforms = new List<Transform>();
List<Transform> allTransforms = new List<Transform>();
// get current list of all transforms (either scene root or our current transform children)
if (m_currentTransform)
@ -125,30 +124,26 @@ namespace Explorer
}
else
{
if (!m_getRootObjectsFailed)
if (!manual && m_getRootObjectsFailed) return;
if (!manual)
{
try
{
var list = SceneManager.GetSceneByName(m_currentScene)
.GetRootGameObjects()
.ToArray();
var scene = SceneManager.GetSceneByName(m_currentScene);
foreach (var obj in list)
{
allTransforms.Add(obj.transform);
}
allTransforms.AddRange(scene.GetRootGameObjects()
.Select(it => it.transform));
}
catch
{
m_getRootObjectsFailed = true;
PASSIVE_UPDATE_INTERVAL = 2;
allTransforms = GetRootObjectsManual_Impl();
allTransforms.AddRange(GetRootObjectsManual_Impl());
}
}
else
{
allTransforms = GetRootObjectsManual_Impl();
allTransforms.AddRange(GetRootObjectsManual_Impl());
}
}
@ -168,14 +163,30 @@ namespace Explorer
}
}
private List<Transform> GetRootObjectsManual_Impl()
private IEnumerable<Transform> GetRootObjectsManual_Impl()
{
var allTransforms = Resources.FindObjectsOfTypeAll<Transform>()
.Where(x => x.parent == null
&& x.gameObject.scene.name == m_currentScene)
.ToList();
try
{
var array = Resources.FindObjectsOfTypeAll(ReflectionHelpers.TransformType);
return allTransforms;
var list = new List<Transform>();
foreach (var obj in array)
{
var transform = obj.TryCast<Transform>();
if (transform.parent == null && transform.gameObject.scene.name == m_currentScene)
{
list.Add(transform);
}
}
return list;
}
catch (Exception e)
{
MelonLogger.Log("Exception getting root scene objects (manual): "
+ e.GetType() + ", " + e.Message + "\r\n"
+ e.StackTrace);
return new Transform[0];
}
}
// --------- GUI Draw Function --------- //
@ -277,7 +288,7 @@ namespace Explorer
{
Pages.TurnPage(Turn.Left, ref this.scroll);
Update_Impl();
Update_Impl(true);
}
Pages.CurrentPageLabel();
@ -286,7 +297,7 @@ namespace Explorer
{
Pages.TurnPage(Turn.Right, ref this.scroll);
Update_Impl();
Update_Impl(true);
}
}
@ -316,6 +327,14 @@ namespace Explorer
else
{
GUILayout.Label("Scene Root GameObjects:", null);
if (m_getRootObjectsFailed)
{
if (GUILayout.Button("Update Root Object List (auto-update failed!)", null))
{
Update_Impl(true);
}
}
}
if (m_objectList.Count > 0)

View File

@ -13,7 +13,7 @@ namespace Explorer
{
public static SearchPage Instance;
public override string Name { get => "Object Search"; set => base.Name = value; }
public override string Name { get => "Object Search"; }
private string m_searchInput = "";
private string m_typeInput = "";
@ -318,7 +318,8 @@ namespace Explorer
continue;
}
if (searchType == ReflectionHelpers.ComponentType && ReflectionHelpers.TransformType.IsAssignableFrom(obj.GetIl2CppType()))
if (searchType.FullName == ReflectionHelpers.ComponentType.FullName
&& ReflectionHelpers.TransformType.IsAssignableFrom(obj.GetIl2CppType()))
{
// Transforms shouldn't really be counted as Components, skip them.
// They're more akin to GameObjects.

View File

@ -9,7 +9,7 @@ namespace Explorer
{
public abstract class WindowPage
{
public virtual string Name { get; set; }
public virtual string Name { get; }
public Vector2 scroll = Vector2.zero;

View File

@ -128,28 +128,22 @@ namespace Explorer
m_object.transform.localScale = m_frozenScale;
}
var list = new List<Transform>();
// update child objects
var childList = new List<Transform>();
for (int i = 0; i < m_object.transform.childCount; i++)
{
list.Add(m_object.transform.GetChild(i));
childList.Add(m_object.transform.GetChild(i));
}
list.Sort((a, b) => b.childCount.CompareTo(a.childCount));
m_children = list.ToArray();
childList.Sort((a, b) => b.childCount.CompareTo(a.childCount));
m_children = childList.ToArray();
ChildPages.ItemCount = m_children.Length;
var list2 = new List<Component>();
foreach (var comp in m_object.GetComponents(ReflectionHelpers.ComponentType))
{
var ilType = comp.GetIl2CppType();
if (ilType == ReflectionHelpers.TransformType)
{
continue;
}
// update components
var compList = new Il2CppSystem.Collections.Generic.List<Component>();
m_object.GetComponentsInternal(ReflectionHelpers.ComponentType, true, false, true, false, compList);
list2.Add(comp);
}
m_components = list2.ToArray();
m_components = compList.ToArray();
CompPages.ItemCount = m_components.Length;
}

View File

@ -26,6 +26,7 @@ namespace Explorer
}
public override void Init() { }
public override void Update()
{
while (TargetTabID >= WindowManager.Windows.Count)

View File

@ -109,7 +109,7 @@ namespace Explorer
if (!equals && iObj is Il2CppSystem.Object iCurrent && window.Target is Il2CppSystem.Object iTarget)
{
if (iCurrent.GetIl2CppType() != iTarget.GetIl2CppType())
if (iCurrent.GetIl2CppType().FullName != iTarget.GetIl2CppType().FullName)
{
if (iCurrent is Transform transform)
{