diff --git a/src/Helpers/ReflectionHelpers.cs b/src/Helpers/ReflectionHelpers.cs index 104b4ac..a2e9fb9 100644 --- a/src/Helpers/ReflectionHelpers.cs +++ b/src/Helpers/ReflectionHelpers.cs @@ -21,20 +21,6 @@ namespace UnityExplorer.Helpers { public static BF CommonFlags = BF.Public | BF.Instance | BF.NonPublic | BF.Static; -#if CPP - public static ILType GameObjectType => Il2CppType.Of(); - public static ILType TransformType => Il2CppType.Of(); - public static ILType ObjectType => Il2CppType.Of(); - public static ILType ComponentType => Il2CppType.Of(); - public static ILType BehaviourType => Il2CppType.Of(); -#else - public static Type GameObjectType => typeof(GameObject); - public static Type TransformType => typeof(Transform); - public static Type ObjectType => typeof(UnityEngine.Object); - public static Type ComponentType => typeof(Component); - public static Type BehaviourType => typeof(Behaviour); -#endif - public static Type GetTypeByName(string fullName) { foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) @@ -78,10 +64,13 @@ namespace UnityExplorer.Helpers if (obj is ILType) return typeof(ILType); - // Il2CppSystem-namespace objects should just return GetType, - // because using GetIl2CppType returns the System namespace type instead. - if (type.Namespace.StartsWith("System.") || type.Namespace.StartsWith("Il2CppSystem.")) - return ilObject.GetType(); + if (!string.IsNullOrEmpty(type.Namespace)) + { + // Il2CppSystem-namespace objects should just return GetType, + // because using GetIl2CppType returns the System namespace type instead. + if (type.Namespace.StartsWith("System.") || type.Namespace.StartsWith("Il2CppSystem.")) + return ilObject.GetType(); + } var il2cppType = ilObject.GetIl2CppType(); diff --git a/src/Inspectors/GameObjects/ChildList.cs b/src/Inspectors/GameObjects/ChildList.cs index 8708569..ab12669 100644 --- a/src/Inspectors/GameObjects/ChildList.cs +++ b/src/Inspectors/GameObjects/ChildList.cs @@ -21,12 +21,15 @@ namespace UnityExplorer.Inspectors.GameObjects } public static PageHandler s_childListPageHandler; + private static GameObject s_childListContent; + private static GameObject[] s_allChildren = new GameObject[0]; private static readonly List s_childrenShortlist = new List(); - private static GameObject s_childListContent; - private static readonly List s_childListTexts = new List(); private static int s_lastChildCount; + private static readonly List s_childListTexts = new List(); + private static readonly List s_childListToggles = new List(); + internal void RefreshChildObjectList() { var go = GameObjectInspector.ActiveInstance.TargetGO; @@ -86,6 +89,9 @@ namespace UnityExplorer.Inspectors.GameObjects text.text = name; text.color = obj.activeSelf ? Color.green : Color.red; + var tog = s_childListToggles[i]; + tog.isOn = obj.activeSelf; + var label = text.transform.parent.parent.gameObject; if (!label.activeSelf) { @@ -117,6 +123,18 @@ namespace UnityExplorer.Inspectors.GameObjects Instance.RefreshChildObjectList(); } + internal static void OnToggleClicked(int index, bool newVal) + { + if (GameObjectInspector.ActiveInstance == null) + return; + + if (index >= s_childrenShortlist.Count || !s_childrenShortlist[index]) + return; + + var obj = s_childrenShortlist[index]; + obj.SetActive(newVal); + } + #region UI CONSTRUCTION internal void ConstructChildList(GameObject parent) @@ -166,6 +184,15 @@ namespace UnityExplorer.Inspectors.GameObjects btnLayout.flexibleHeight = 0; btnGroupObj.AddComponent(); + var toggleObj = UIFactory.CreateToggle(btnGroupObj, out Toggle toggle, out Text toggleText, new Color(0.3f, 0.3f, 0.3f)); + var toggleLayout = toggleObj.AddComponent(); + toggleLayout.minHeight = 25; + toggleLayout.minWidth = 25; + toggleText.text = ""; + toggle.isOn = false; + s_childListToggles.Add(toggle); + toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); }); + GameObject mainButtonObj = UIFactory.CreateButton(btnGroupObj); LayoutElement mainBtnLayout = mainButtonObj.AddComponent(); mainBtnLayout.minHeight = 25; diff --git a/src/Inspectors/GameObjects/ComponentList.cs b/src/Inspectors/GameObjects/ComponentList.cs index 6d9a3a6..555c5ae 100644 --- a/src/Inspectors/GameObjects/ComponentList.cs +++ b/src/Inspectors/GameObjects/ComponentList.cs @@ -183,20 +183,14 @@ namespace UnityExplorer.Inspectors.GameObjects // Behaviour enabled toggle - var toggleObj = UIFactory.CreateToggle(btnGroupObj, out Toggle toggle, out Text toggleText); - var togBg = toggleObj.transform.Find("Background").GetComponent(); - togBg.color = new Color(0.1f, 0.1f, 0.1f, 1); + var toggleObj = UIFactory.CreateToggle(btnGroupObj, out Toggle toggle, out Text toggleText, new Color(0.3f, 0.3f, 0.3f)); var toggleLayout = toggleObj.AddComponent(); - toggleLayout.minWidth = 25; - toggleLayout.flexibleWidth = 0; toggleLayout.minHeight = 25; - toggleLayout.flexibleHeight = 0; - var checkImg = toggleObj.transform.Find("Background/Checkmark").GetComponent(); - checkImg.color = UISyntaxHighlight.Class_Instance.ToColor(); - checkImg.color *= 0.66f; - toggle.onValueChanged.AddListener((bool val) => { OnCompToggleClicked(thisIndex, val); }); + toggleLayout.minWidth = 25; toggleText.text = ""; + toggle.isOn = false; s_compToggles.Add(toggle); + toggle.onValueChanged.AddListener((bool val) => { OnCompToggleClicked(thisIndex, val); }); // Main component button diff --git a/src/Inspectors/GameObjects/GameObjectControls.cs b/src/Inspectors/GameObjects/GameObjectControls.cs index 57aa193..0b045db 100644 --- a/src/Inspectors/GameObjects/GameObjectControls.cs +++ b/src/Inspectors/GameObjects/GameObjectControls.cs @@ -314,15 +314,15 @@ namespace UnityExplorer.Inspectors.GameObjects } } - // set parent - ConstructSetParent(contentObj); - // transform controls ConstructVector3Editor(contentObj, "Position", ControlType.position, out s_positionControl); ConstructVector3Editor(contentObj, "Local Position", ControlType.localPosition, out s_localPosControl); ConstructVector3Editor(contentObj, "Rotation", ControlType.eulerAngles, out s_rotationControl); ConstructVector3Editor(contentObj, "Scale", ControlType.localScale, out s_scaleControl); + // set parent + ConstructSetParent(contentObj); + // bottom row buttons ConstructBottomButtons(contentObj); diff --git a/src/Inspectors/Reflection/CacheObject/CacheMember.cs b/src/Inspectors/Reflection/CacheObject/CacheMember.cs index 5d584ff..c2e75c6 100644 --- a/src/Inspectors/Reflection/CacheObject/CacheMember.cs +++ b/src/Inspectors/Reflection/CacheObject/CacheMember.cs @@ -86,9 +86,7 @@ namespace UnityExplorer.Inspectors.Reflection public object[] ParseArguments() { if (m_arguments.Length < 1) - { return new object[0]; - } var parsedArgs = new List(); for (int i = 0; i < m_arguments.Length; i++) @@ -97,9 +95,7 @@ namespace UnityExplorer.Inspectors.Reflection var type = m_arguments[i].ParameterType; if (type.IsByRef) - { type = type.GetElementType(); - } if (!string.IsNullOrEmpty(input)) { @@ -120,7 +116,7 @@ namespace UnityExplorer.Inspectors.Reflection } catch { - ExplorerCore.Log($"Argument #{i} '{m_arguments[i].Name}' ({type.Name}), could not parse input '{input}'."); + ExplorerCore.Log($"Could not parse input '{input}' for argument #{i} '{m_arguments[i].Name}' ({type.FullName})"); } } } @@ -300,46 +296,12 @@ namespace UnityExplorer.Inspectors.Reflection rightGroup.padding.top = 2; rightGroup.padding.bottom = 2; - // evaluate button - if (this is CacheMethod || HasParameters) - { - var color = HasParameters ? new Color(0.4f, 0.4f, 0.4f) : new Color(0.3f, 0.6f, 0.3f); + ConstructArgInput(out GameObject argsHolder); - var evalButtonObj = UIFactory.CreateButton(m_rightGroup, color); - var evalLayout = evalButtonObj.AddComponent(); - evalLayout.minWidth = 100; - evalLayout.minHeight = 22; - evalLayout.flexibleWidth = 0; - var evalText = evalButtonObj.GetComponentInChildren(); - evalText.text = HasParameters - ? $"Evaluate ({ParamCount})" - : "Evaluate"; - - var evalButton = evalButtonObj.GetComponent