private void GetSuggestions(string value) { suggestions.Clear(); suggestedNames.Clear(); if (BaseType == null) { ExplorerCore.LogWarning("Autocompleter Base type is null!"); return; } // Check for exact match first if (ReflectionUtility.AllTypes.TryGetValue(value, out Type t) && allowedTypes.Contains(t)) { AddSuggestion(t); } foreach (var entry in allowedTypes) { if (entry.FullName.ContainsIgnoreCase(value)) { AddSuggestion(entry); } } }
internal void GetNames() { var type = Value?.GetType() ?? FallbackType; if (m_lastEnumType == type) { return; } m_lastEnumType = type; if (m_subContentConstructed) { DestroySubContent(); } if (!s_enumNamesCache.ContainsKey(type)) { // using GetValues not GetNames, to catch instances of weird enums (eg CameraClearFlags) var values = Enum.GetValues(type); var list = new List <KeyValuePair <int, string> >(); var set = new HashSet <string>(); foreach (var value in values) { var name = value.ToString(); if (set.Contains(name)) { continue; } set.Add(name); var backingType = Enum.GetUnderlyingType(type); int intValue; try { // this approach is necessary, a simple '(int)value' is not sufficient. var unbox = Convert.ChangeType(value, backingType); intValue = (int)Convert.ChangeType(unbox, typeof(int)); } catch (Exception ex) { ExplorerCore.LogWarning("[InteractiveEnum] Could not Unbox underlying type " + backingType.Name + " from " + type.FullName); ExplorerCore.Log(ex.ToString()); continue; } list.Add(new KeyValuePair <int, string>(intValue, name)); } s_enumNamesCache.Add(type, list.ToArray()); } m_values = s_enumNamesCache[type]; }
internal static void OnSetParentClicked() { var go = GameObjectInspector.ActiveInstance.TargetGO; if (!go) { return; } var input = s_setParentInput.text; if (string.IsNullOrEmpty(input)) { go.transform.parent = null; } else { if (GameObject.Find(input) is GameObject newParent) { go.transform.parent = newParent.transform; } else { ExplorerCore.Log($"Could not find any GameObject from name or path '{input}'! Note: The target must be enabled."); } } }
// --------- GUI Draw Function --------- // public override void DrawWindow() { try { DrawHeaderArea(); GUIUnstrip.BeginVertical(GUIContent.none, GUI.skin.box, null); DrawPageButtons(); if (!m_searching) { DrawGameObjectList(); } else { DrawSearchResultsList(); } GUILayout.EndVertical(); } catch (Exception e) { if (!e.Message.Contains("in a group with only")) { ExplorerCore.Log(e.ToString()); } } }
private IEnumerable <Transform> GetRootObjectsManual_Impl() { try { var array = Resources.FindObjectsOfTypeAll(ReflectionHelpers.TransformType); var list = new List <Transform>(); foreach (var obj in array) { #if CPP var transform = obj.TryCast <Transform>(); #else var transform = obj as Transform; #endif if (transform.parent == null && transform.gameObject.scene.name == m_currentScene) { list.Add(transform); } } return(list); } catch (Exception e) { ExplorerCore.Log("Exception getting root scene objects (manual): " + e.GetType() + ", " + e.Message + "\r\n" + e.StackTrace); return(new Transform[0]); } }
private void OnInputChanged(string val, int fieldIndex) { try { float f; if (IsValueColor32) { byte value = byte.Parse(val); m_sliders[fieldIndex].value = value; f = (float)((decimal)value / 255); } else { f = float.Parse(val); m_sliders[fieldIndex].value = f; } SetColorField(f, fieldIndex); } catch (ArgumentException) { } // ignore bad user input catch (FormatException) { } catch (OverflowException) { } catch (Exception ex) { ExplorerCore.LogWarning("InteractiveColor OnInput: " + ex.ToString()); } }
public override void Update() { try { if (Target == null) { ExplorerCore.Log("Target is null!"); DestroyWindow(); return; } if (!TargetGO && !GetObjectAsGameObject()) { ExplorerCore.Log("Target was destroyed!"); DestroyWindow(); return; } if (m_freeze) { if (m_localContext) { TargetGO.transform.localPosition = m_frozenPosition; TargetGO.transform.localRotation = m_frozenRotation; } else { TargetGO.transform.position = m_frozenPosition; TargetGO.transform.rotation = m_frozenRotation; } TargetGO.transform.localScale = m_frozenScale; } // update child objects var childList = new List <Transform>(); for (int i = 0; i < TargetGO.transform.childCount; i++) { childList.Add(TargetGO.transform.GetChild(i)); } childList.Sort((a, b) => b.childCount.CompareTo(a.childCount)); m_children = childList.ToArray(); ChildPages.ItemCount = m_children.Length; // update components #if CPP var compList = new Il2CppSystem.Collections.Generic.List <Component>(); TargetGO.GetComponentsInternal(ReflectionHelpers.ComponentType, true, false, true, false, compList); m_components = compList.ToArray(); #else m_components = TargetGO.GetComponents <Component>(); #endif CompPages.ItemCount = m_components.Length; } catch (Exception e) { DestroyOnException(e); } }
public static void Initialize() { Instance = new ExplorerEditorLoader(); OnLog += LogHandler; Instance.configHandler = new StandaloneConfigHandler(); ExplorerCore.Init(Instance); }
private void InvokeOnValueChanged(string value) { if (value.Length == UIManager.MAX_INPUTFIELD_CHARS) { ExplorerCore.LogWarning($"Reached maximum InputField character length! ({UIManager.MAX_INPUTFIELD_CHARS})"); } OnInputChanged?.Invoke(value); }
internal static void Init() { #if ML MelonLoader.MelonCoroutines.Start(Update()); #else ExplorerCore.LogError("Execute in main not supported yet."); return; #endif }
public object[] ParseArguments() { if (m_arguments.Length < 1) { return(new object[0]); } var parsedArgs = new List <object>(); for (int i = 0; i < m_arguments.Length; i++) { var input = m_argumentInput[i]; var type = m_arguments[i].ParameterType; if (type.IsByRef) { type = type.GetElementType(); } if (!string.IsNullOrEmpty(input)) { if (type == typeof(string)) { parsedArgs.Add(input); continue; } else { try { var arg = type.GetMethod("Parse", new Type[] { typeof(string) }) .Invoke(null, new object[] { input }); parsedArgs.Add(arg); continue; } catch { ExplorerCore.Log($"Could not parse input '{input}' for argument #{i} '{m_arguments[i].Name}' ({type.FullName})"); } } } // No input, see if there is a default value. if (m_arguments[i].IsOptional) { parsedArgs.Add(m_arguments[i].DefaultValue); continue; } // Try add a null arg I guess parsedArgs.Add(null); } return(parsedArgs.ToArray()); }
public override void OnBeginMouseInspect() { MainCamera = Camera.main; if (!MainCamera) { ExplorerCore.LogWarning("No MainCamera found! Cannot inspect world!"); return; } }
public virtual void OnBorrowed(CacheObjectBase owner) { if (this.m_owner != null) { ExplorerCore.LogWarning("Setting an IValue's owner but there is already one set. Maybe it wasn't cleaned up?"); ReleaseFromOwner(); } this.m_owner = owner; }
public override void Init() { ExplorerCore.Log("Initializing Legacy Input support..."); _mousePositionProp = TInput.GetProperty("mousePosition"); _getKeyMethod = TInput.GetMethod("GetKey", new Type[] { typeof(KeyCode) }); _getKeyDownMethod = TInput.GetMethod("GetKeyDown", new Type[] { typeof(KeyCode) }); _getMouseButtonMethod = TInput.GetMethod("GetMouseButton", new Type[] { typeof(int) }); _getMouseButtonDownMethod = TInput.GetMethod("GetMouseButtonDown", new Type[] { typeof(int) }); }
public static object CurrentTarget() { if (!WindowManager.TabView) { ExplorerCore.Log("CurrentTarget() is only a valid method when in Tab View mode!"); return(null); } return(WindowManager.Windows.ElementAt(TabViewWindow.Instance.TargetTabID).Target); }
private void OnGameObjectButtonClicked() { if (!ComponentRef) { ExplorerCore.LogWarning("Component reference is null or destroyed!"); return; } InspectorManager.Inspect(ComponentRef.gameObject); }
public static void Init() { InitEventSystemPropertyHandlers(); // Make sure console is supported on this platform try { ResetConsole(false); // ensure the compiler is supported (if this fails then SRE is probably stubbed) Evaluator.Compile("0 == 0"); } catch (Exception ex) { DisableConsole(ex); return; } // Setup console Lexer = new LexerBuilder(); Completer = new CSAutoCompleter(); SetupHelpInteraction(); Panel.OnInputChanged += OnInputChanged; Panel.InputScroller.OnScroll += OnInputScrolled; Panel.OnCompileClicked += Evaluate; Panel.OnResetClicked += ResetConsole; Panel.OnHelpDropdownChanged += HelpSelected; Panel.OnAutoIndentToggled += OnToggleAutoIndent; Panel.OnCtrlRToggled += OnToggleCtrlRShortcut; Panel.OnSuggestionsToggled += OnToggleSuggestions; Panel.OnPanelResized += OnInputScrolled; // Run startup script try { if (!Directory.Exists(ScriptsFolder)) { Directory.CreateDirectory(ScriptsFolder); } var startupPath = Path.Combine(ScriptsFolder, "startup.cs"); if (File.Exists(startupPath)) { ExplorerCore.Log($"Executing startup script from '{startupPath}'..."); var text = File.ReadAllText(startupPath); Input.Text = text; Evaluate(); } } catch (Exception ex) { ExplorerCore.LogWarning($"Exception executing startup script: {ex}"); } }
private void SetValueFromDropdown() { try { CurrentOwner.SetUserValue(ValueAtIdx(enumDropdown.value).ActualValue); } catch (Exception ex) { ExplorerCore.LogWarning("Exception setting from dropdown: " + ex); } }
protected override void TrySetValue(object value) { try { FieldInfo.SetValue(DeclaringInstance, value); } catch (Exception ex) { ExplorerCore.LogWarning(ex); } }
public void OnMainButtonClicked() { if (cachedTransform.Value) { OnGameObjectClicked?.Invoke(cachedTransform.Value.gameObject); } else { ExplorerCore.LogWarning("The object was destroyed!"); } }
private void DestroyOnException(Exception e) { if (pendingDestroy) { return; } ExplorerCore.Log($"Exception drawing GameObject Window: {e.GetType()}, {e.Message}"); pendingDestroy = true; DestroyWindow(); }
public static void SetCurrentPage(int index) { if (index < 0 || Pages.Count <= index) { ExplorerCore.Log("cannot set page " + index); return; } m_currentPage = index; GUIHelper.BringWindowToFront(MainWindowID); GUI.FocusWindow(MainWindowID); }
public static void Create() { if (Instance != null) { ExplorerCore.LogWarning("An instance of MainMenu already exists, cannot create another!"); return; } Instance = new MainMenu(); Instance.Init(); }
public override void SetConfigValue <T>(ConfigElement <T> element, T value) { if (Config.TryGetEntry(CTG_NAME, element.Name, out ConfigEntry <T> configEntry)) { configEntry.Value = value; } else { ExplorerCore.Log("Could not get config entry '" + element.Name + "'"); } }
public override void SetupEvents() { try { Application.add_logMessageReceived(new Action <string, string, LogType>(Application_logMessageReceived)); } catch (Exception ex) { ExplorerCore.LogWarning("Exception setting up Unity log listener, make sure Unity libraries have been unstripped!"); ExplorerCore.Log(ex); } }
internal static void Init() { try { ExplorerCore.Harmony.PatchAll(typeof(UnityCrashPrevention)); ExplorerCore.Log("Initialized UnityCrashPrevention."); } catch //(Exception ex) { //ExplorerCore.Log($"Exception setting up Canvas crash prevention patch: {ex}"); } }
// setting UI state for value private void SetDropdownForValue(object value) { if (CurrentValues.Contains(value)) { var cached = ValueAtKey(value); enumDropdown.value = cached.EnumIndex; enumDropdown.RefreshShownValue(); } else { ExplorerCore.LogWarning("CurrentValues does not contain key '" + value?.ToString() ?? "<null>" + "'"); } }
public static void GetVars() { var vars = Evaluator.GetVars()?.Trim(); if (string.IsNullOrEmpty(vars)) { ExplorerCore.LogWarning("No variables seem to be defined!"); } else { Log(vars); } }
internal void OnApplyClicked() { try { Value = ParseMethod.Invoke(null, new object[] { m_valueInput.text }); Owner.SetValue(); RefreshUIForValue(); } catch (Exception e) { ExplorerCore.LogWarning("Could not parse input! " + ReflectionUtility.ReflectionExToString(e, true)); } }
public void Patch() { try { patchProcessor.Patch(); Enabled = true; } catch (Exception ex) { ExplorerCore.LogWarning($"Exception hooking method!\r\n{ex}"); } }