private void CacheResults(IEnumerable results, bool isStaticClasses = false) { m_searchResults = new List <CacheObjectBase>(); foreach (var obj in results) { var toCache = obj; #if CPP if (toCache is Il2CppSystem.Object ilObject) { toCache = ilObject.TryCast <GameObject>() ?? ilObject.TryCast <Transform>()?.gameObject ?? ilObject; } #else if (toCache is GameObject || toCache is Transform) { toCache = toCache as GameObject ?? (toCache as Transform).gameObject; } #endif var cache = CacheFactory.GetCacheObject(toCache); cache.IsStaticClassSearchResult = isStaticClasses; m_searchResults.Add(cache); } Pages.ItemCount = m_searchResults.Count; Pages.PageOffset = 0; }
private void Update_Impl() { List <Transform> allTransforms = new List <Transform>(); // get current list of all transforms (either scene root or our current transform children) if (m_currentTransform) { for (int i = 0; i < m_currentTransform.childCount; i++) { allTransforms.Add(m_currentTransform.GetChild(i)); } } else { for (int i = 0; i < SceneManager.sceneCount; i++) { var scene = SceneManager.GetSceneAt(i); if (scene.name == m_currentScene) { var rootObjects = #if CPP Unstrip.Scenes.SceneUnstrip.GetRootGameObjects(scene) .Select(it => it.transform); #else scene.GetRootGameObjects().Select(it => it.transform); #endif allTransforms.AddRange(rootObjects); break; } } } Pages.ItemCount = allTransforms.Count; int offset = Pages.CalculateOffsetIndex(); // sort by childcount allTransforms.Sort((a, b) => b.childCount.CompareTo(a.childCount)); m_objectList.Clear(); for (int i = offset; i < offset + Pages.ItemsPerPage && i < Pages.ItemCount; i++) { var child = allTransforms[i]; m_objectList.Add(CacheFactory.GetCacheObject(child)); } }
public override void Init() { toggleKeyInputString = ModConfig.Instance.Main_Menu_Toggle.ToString(); toggleKeyInput = CacheFactory.GetCacheObject(typeof(OptionsPage).GetField("toggleKeyInputString"), this); defaultSizeInputVector = ModConfig.Instance.Default_Window_Size; defaultSizeInput = CacheFactory.GetCacheObject(typeof(OptionsPage).GetField("defaultSizeInputVector"), this); defaultPageLimit = ModConfig.Instance.Default_Page_Limit; defaultPageLimitInput = CacheFactory.GetCacheObject(typeof(OptionsPage).GetField("defaultPageLimit"), this); bitwiseSupport = ModConfig.Instance.Bitwise_Support; bitwiseSupportInput = CacheFactory.GetCacheObject(typeof(OptionsPage).GetField("bitwiseSupport"), this); tabView = ModConfig.Instance.Tab_View; tabViewInput = CacheFactory.GetCacheObject(typeof(OptionsPage).GetField("tabView"), this); }
private void CacheResults(IEnumerable results, bool isStaticClasses = false) { //m_cachingResults = true; m_searchResults = new List <CacheObjectBase>(); foreach (var obj in results) { var toCache = obj; #if CPP if (toCache is Il2CppSystem.Object ilObject) { var type = ReflectionHelpers.GetActualType(ilObject); ilObject = (Il2CppSystem.Object)ilObject.Il2CppCast(type); toCache = ilObject.TryCast <GameObject>() ?? ilObject.TryCast <Transform>()?.gameObject ?? ilObject; } #else if (toCache is GameObject || toCache is Transform) { toCache = toCache as GameObject ?? (toCache as Transform).gameObject; } #endif if (toCache is TextAsset textAsset) { if (string.IsNullOrEmpty(textAsset.text)) { continue; } } var cache = CacheFactory.GetCacheObject(toCache); cache.IsStaticClassSearchResult = isStaticClasses; m_searchResults.Add(cache); } Pages.ItemCount = m_searchResults.Count; Pages.PageOffset = 0; results = null; //m_cachingResults = false; }
public List <CacheObjectBase> SearchSceneObjects(string _search) { var matches = new List <CacheObjectBase>(); foreach (var obj in ResourcesUnstrip.FindObjectsOfTypeAll(ReflectionHelpers.GameObjectType)) { #if CPP var go = obj.TryCast <GameObject>(); #else var go = obj as GameObject; #endif if (go.name.ToLower().Contains(_search.ToLower()) && go.scene.name == m_currentScene) { matches.Add(CacheFactory.GetCacheObject(go)); } } return(matches); }
public void Evaluate() { MethodInfo mi; if (GenericArgs.Length > 0) { mi = MakeGenericMethodFromInput(); if (mi == null) { return; } } else { mi = MemInfo as MethodInfo; } object ret = null; try { ret = mi.Invoke(mi.IsStatic ? null : DeclaringInstance, ParseArguments()); m_evaluated = true; m_isEvaluating = false; } catch (Exception e) { ExplorerCore.LogWarning($"Exception evaluating: {e.GetType()}, {e.Message}"); ReflectionException = ReflectionHelpers.ExceptionToString(e); } if (ret != null) { //m_cachedReturnValue = CacheFactory.GetTypeAndCacheObject(ret); m_cachedReturnValue = CacheFactory.GetCacheObject(ret, IValue.ValueType); m_cachedReturnValue.UpdateValue(); } else { m_cachedReturnValue = null; } }
private void CacheMembers(Type[] types) { var list = new List <CacheMember>(); var cachedSigs = new HashSet <string>(); foreach (var declaringType in types) { MemberInfo[] infos; try { infos = declaringType.GetMembers(ReflectionHelpers.CommonFlags); } catch { ExplorerCore.Log($"Exception getting members for type: {declaringType.FullName}"); continue; } var target = Target; #if CPP try { target = target.Il2CppCast(declaringType); } catch //(Exception e) { //ExplorerCore.LogWarning("Excepting casting " + target.GetType().FullName + " to " + declaringType.FullName); } #endif foreach (var member in infos) { try { // make sure member type is Field, Method or Property (4 / 8 / 16) int m = (int)member.MemberType; if (m < 4 || m > 16) { continue; } var pi = member as PropertyInfo; var mi = member as MethodInfo; if (IsStaticInspector) { if (member is FieldInfo fi && !fi.IsStatic) { continue; } else if (pi != null && !pi.GetAccessors(true)[0].IsStatic) { continue; } else if (mi != null && !mi.IsStatic) { continue; } } // check blacklisted members var sig = $"{member.DeclaringType.Name}.{member.Name}"; if (_typeAndMemberBlacklist.Any(it => it == sig)) { continue; } if (_methodStartsWithBlacklist.Any(it => member.Name.StartsWith(it))) { continue; } if (mi != null) { AppendParams(mi.GetParameters()); } else if (pi != null) { AppendParams(pi.GetIndexParameters()); } void AppendParams(ParameterInfo[] _args) { sig += " ("; foreach (var param in _args) { sig += $"{param.ParameterType.Name} {param.Name}, "; } sig += ")"; } if (cachedSigs.Contains(sig)) { continue; } try { // ExplorerCore.Log($"Trying to cache member {sig}..."); var cached = CacheFactory.GetCacheObject(member, target); if (cached != null) { cachedSigs.Add(sig); list.Add(cached); } } catch (Exception e) { ExplorerCore.LogWarning($"Exception caching member {sig}!"); ExplorerCore.Log(e.ToString()); } }
private void Update_Impl(bool manual = false) { List <Transform> allTransforms = new List <Transform>(); // get current list of all transforms (either scene root or our current transform children) if (m_currentTransform) { for (int i = 0; i < m_currentTransform.childCount; i++) { allTransforms.Add(m_currentTransform.GetChild(i)); } } else { if (!m_getRootObjectsFailed) { try { for (int i = 0; i < SceneManager.sceneCount; i++) { var scene = SceneManager.GetSceneAt(i); if (scene.name == m_currentScene) { allTransforms.AddRange(scene.GetRootGameObjects() .Select(it => it.transform)); break; } } } catch { ExplorerCore.Log("Exception getting root scene objects, falling back to backup method..."); m_getRootObjectsFailed = true; allTransforms.AddRange(GetRootObjectsManual_Impl()); } } else { if (!manual) { return; } allTransforms.AddRange(GetRootObjectsManual_Impl()); } } Pages.ItemCount = allTransforms.Count; int offset = Pages.CalculateOffsetIndex(); // sort by childcount allTransforms.Sort((a, b) => b.childCount.CompareTo(a.childCount)); m_objectList.Clear(); for (int i = offset; i < offset + Pages.ItemsPerPage && i < Pages.ItemCount; i++) { var child = allTransforms[i]; m_objectList.Add(CacheFactory.GetCacheObject(child)); } }