Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SignColorPicker v1.0.2
SignColorPicker.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SignColorPicker")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SignColorPicker")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("C15A2CCF-98B4-4765-88D2-0019FE7D5E35")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace SignColorPicker; [BepInPlugin("com.xtasy.ValheimSignColorPicker", "SignColorPicker", "1.0.2")] public sealed class SignColorPickerPlugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<Button, bool> <>9__34_0; public static UnityAction <>9__34_1; public static Func<TMP_Text, bool> <>9__35_1; public static UnityAction <>9__35_2; public static Func<Text, bool> <>9__48_0; public static Func<TMP_Text, bool> <>9__48_1; internal bool <AfterRequest>b__34_0(Button b) { <>c__DisplayClass34_0 CS$<>8__locals3 = new <>c__DisplayClass34_0 { b = b }; if (((UnityEventBase)CS$<>8__locals3.b.onClick).GetPersistentEventCount() > 0) { return Enumerable.Range(0, ((UnityEventBase)CS$<>8__locals3.b.onClick).GetPersistentEventCount()).Any((int i) => ((UnityEventBase)CS$<>8__locals3.b.onClick).GetPersistentMethodName(i) == "OnCancel"); } return false; } internal void <AfterRequest>b__34_1() { if ((Object)(object)symbolMenu != (Object)null) { symbolMenu.SetActive(false); } menu.SetActive(!menu.activeSelf); } internal bool <CreateSymbolPicker>b__35_1(TMP_Text t) { return (Object)(object)t.font != (Object)null; } internal void <CreateSymbolPicker>b__35_2() { menu.SetActive(false); symbolMenu.SetActive(!symbolMenu.activeSelf); } internal bool <CreateCaption>b__48_0(Text t) { return (Object)(object)t.font != (Object)null; } internal bool <CreateCaption>b__48_1(TMP_Text t) { return (Object)(object)t.font != (Object)null; } } [CompilerGenerated] private sealed class <>c__DisplayClass34_0 { public Button b; internal bool <AfterRequest>b__2(int i) { return ((UnityEventBase)b.onClick).GetPersistentMethodName(i) == "OnCancel"; } } public const string Guid = "com.xtasy.ValheimSignColorPicker"; public const string Name = "SignColorPicker"; public const string Version = "1.0.2"; private Harmony harmony; private static SignColorPickerPlugin instance; private static TextInput owner; private static GameObject root; private static GameObject menu; private static Button picker; private static Button symbolButton; private static GameObject symbolMenu; private static readonly List<Action> RestoreButtons = new List<Action>(); private static int symbolPage; private static TMP_FontAsset symbolFont; private static List<uint> availableSymbols = new List<uint>(); private static object input; private static int originalLimit; private static readonly Regex ColorTags = new Regex("</?color\\b[^>]*>", RegexOptions.IgnoreCase); private static readonly Regex OuterColor = new Regex("^\\s*<color\\s*=\\s*[\"']?([^>\"'\\s]+)[\"']?\\s*>", RegexOptions.IgnoreCase); private ConfigEntry<string> customColors; private DateTime configWriteTime; private float nextConfigCheck; private bool paletteDirty; private static Button paletteTemplate; private static string captionLanguage; private static readonly string[] Values = new string[20] { "", "#FFFFFF", "#FF4040", "#FF8800", "#FFFF00", "#40FF40", "#00FFFF", "#4080FF", "#B060FF", "#FF80C0", "#C0C0C0", "#808080", "#800000", "#FF6347", "#FFD700", "#808000", "#008000", "#008080", "#000080", "#FF00FF" }; private static bool Russian { get { if (Localization.instance != null) { return string.Equals(Localization.instance.GetSelectedLanguage(), "Russian", StringComparison.OrdinalIgnoreCase); } return false; } } private void Awake() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown instance = this; customColors = ((BaseUnityPlugin)this).Config.Bind<string>("Palette", "CustomColorsHex", "#FFAA00, #66CCFF", "Extra HEX colors separated by commas: #RRGGBB or #RRGGBBAA. Empty = no extras. / Дополнительные HEX-цвета через запятую. Пустая строка отключает дополнительные цвета."); configWriteTime = File.GetLastWriteTimeUtc(((BaseUnityPlugin)this).Config.ConfigFilePath); ((BaseUnityPlugin)this).Config.SettingChanged += OnConfigSettingChanged; harmony = new Harmony("com.xtasy.ValheimSignColorPicker"); harmony.PatchAll(typeof(SignColorPickerPlugin)); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.SettingChanged -= OnConfigSettingChanged; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } Cleanup(); instance = null; } private static object Field(object target, string name) { return AccessTools.Field(target.GetType(), name).GetValue(target); } private static object Get(string name) { return AccessTools.Property(input.GetType(), name).GetValue(input, null); } private static void Set(string name, object value) { AccessTools.Property(input.GetType(), name).SetValue(input, value, null); } private static void Cleanup() { foreach (Action restoreButton in RestoreButtons) { restoreButton(); } RestoreButtons.Clear(); if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); } root = null; menu = null; picker = null; symbolButton = null; symbolMenu = null; paletteTemplate = null; input = null; owner = null; captionLanguage = null; } [HarmonyPatch(typeof(TextInput), "RequestText")] [HarmonyPostfix] private static void AfterRequest(TextInput __instance, TextReceiver sign, int charLimit) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown Cleanup(); if (!(sign is Sign)) { return; } try { owner = __instance; input = Field(__instance, "m_inputField"); originalLimit = charLimit; Set("characterLimit", (charLimit > 0) ? (charLimit + 64) : 0); GameObject val = (GameObject)Field(__instance, "m_panel"); Button val2 = ((IEnumerable<Button>)val.GetComponentsInChildren<Button>(true)).FirstOrDefault((Func<Button, bool>)((Button b) => ((UnityEventBase)b.onClick).GetPersistentEventCount() > 0 && Enumerable.Range(0, ((UnityEventBase)b.onClick).GetPersistentEventCount()).Any((int i) => ((UnityEventBase)b.onClick).GetPersistentMethodName(i) == "OnCancel"))); if ((Object)(object)val2 == (Object)null) { throw new InvalidOperationException("Cancel button (OnCancel) not found"); } root = new GameObject("SignColorPicker", new Type[1] { typeof(RectTransform) }); RectTransform val3 = (RectTransform)root.transform; ((Transform)val3).SetParent(((Component)val2).transform.parent, false); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.offsetMin = Vector2.zero; val3.offsetMax = Vector2.zero; picker = CloneButton(val2, (Transform)(object)val3, "SignColorButton"); RectTransform val4 = (RectTransform)((Component)val2).transform; RectTransform val5 = (RectTransform)((Component)picker).transform; Vector2 anchorMin = (val5.anchorMax = new Vector2(0.5f, 0.5f)); val5.anchorMin = anchorMin; val5.pivot = new Vector2(0.5f, 0.5f); Rect rect = val4.rect; val5.sizeDelta = new Vector2(115f, ((Rect)(ref rect)).height); Caption(picker, Russian ? "Цвет" : "Color"); Canvas.ForceUpdateCanvases(); PositionPicker(val, val2, val3, val5); ButtonClickedEvent onClick = picker.onClick; object obj = <>c.<>9__34_1; if (obj == null) { UnityAction val7 = delegate { if ((Object)(object)symbolMenu != (Object)null) { symbolMenu.SetActive(false); } menu.SetActive(!menu.activeSelf); }; <>c.<>9__34_1 = val7; obj = (object)val7; } ((UnityEvent)onClick).AddListener((UnityAction)obj); menu = new GameObject("SignColorMenu", new Type[2] { typeof(RectTransform), typeof(Image) }); RectTransform val8 = (RectTransform)menu.transform; ((Transform)val8).SetParent(((Component)picker).transform, false); anchorMin = (val8.anchorMax = new Vector2(0f, 0f)); val8.anchorMin = anchorMin; val8.pivot = new Vector2(0f, 1f); val8.anchoredPosition = new Vector2(0f, -5f); ((Graphic)menu.GetComponent<Image>()).color = new Color(0.12f, 0.09f, 0.06f, 0.98f); paletteTemplate = val2; ConfigReload(); RebuildPalette(); captionLanguage = (Russian ? "Russian" : "English"); menu.SetActive(false); MarkCurrent(); CreateSymbolPicker(val, val2, val3); } catch (Exception ex) { SignColorPickerPlugin signColorPickerPlugin = instance; if (signColorPickerPlugin != null) { ((BaseUnityPlugin)signColorPickerPlugin).Logger.LogError((object)("Cannot create sign color picker: " + ex)); } if (input != null) { Set("characterLimit", originalLimit); } Cleanup(); } } private static void CreateSymbolPicker(GameObject panel, Button cancel, RectTransform rootRect) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Expected O, but got Unknown symbolButton = CloneButton(cancel, (Transform)(object)rootRect, "SignSmileButton"); Caption(symbolButton, Russian ? "Символы" : "Symbols"); SetCaptionColor(symbolButton, new Color(1f, 0.8f, 0.35f)); Button val = ((IEnumerable<Button>)panel.GetComponentsInChildren<Button>(true)).FirstOrDefault((Func<Button, bool>)((Button b) => (Object)(object)b != (Object)(object)cancel && Enumerable.Range(0, ((UnityEventBase)b.onClick).GetPersistentEventCount()).Any((int i) => ((UnityEventBase)b.onClick).GetPersistentMethodName(i) == "OnInput" || ((UnityEventBase)b.onClick).GetPersistentMethodName(i) == "OnEnter"))); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("OK button not found"); } ArrangeButtonRow(rootRect, cancel, val); symbolMenu = new GameObject("SignSmileMenu", new Type[2] { typeof(RectTransform), typeof(Image) }); RectTransform val2 = (RectTransform)symbolMenu.transform; ((Transform)val2).SetParent(((Component)symbolButton).transform, false); Vector2 anchorMin = (val2.anchorMax = Vector2.zero); val2.anchorMin = anchorMin; val2.pivot = new Vector2(0f, 1f); val2.anchoredPosition = new Vector2(0f, -5f); val2.sizeDelta = new Vector2(292f, 298f); ((Graphic)symbolMenu.GetComponent<Image>()).color = new Color(0.12f, 0.09f, 0.06f, 0.98f); symbolPage = 0; object obj = Field(owner, "m_queuedSign"); Sign val3 = (Sign)((obj is Sign) ? obj : null); TMP_Text val4 = (TMP_Text)(((Object)(object)val3 != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); TMP_Text val5 = ((IEnumerable<TMP_Text>)((Component)cancel).GetComponentsInChildren<TMP_Text>(false)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => (Object)(object)t.font != (Object)null)); symbolFont = (((Object)(object)val4 != (Object)null && (Object)(object)val4.font != (Object)null) ? val4.font : (((Object)(object)val5 != (Object)null) ? val5.font : TMP_Settings.defaultFontAsset)); CollectSymbols(); BuildSymbols(cancel); symbolMenu.SetActive(false); ButtonClickedEvent onClick = symbolButton.onClick; object obj2 = <>c.<>9__35_2; if (obj2 == null) { UnityAction val6 = delegate { menu.SetActive(false); symbolMenu.SetActive(!symbolMenu.activeSelf); }; <>c.<>9__35_2 = val6; obj2 = (object)val6; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); } private static void CollectSymbols() { availableSymbols = new List<uint>(); if ((Object)(object)symbolFont == (Object)null) { return; } int[] array = new int[4] { 9728, 9983, 9984, 10175 }; for (int i = 0; i < array.Length; i += 2) { for (int j = array[i]; j <= array[i + 1]; j++) { char c = (char)j; if (symbolFont.HasCharacter(c, true, true)) { availableSymbols.Add((uint)j); } } } } private static void BuildSymbols(Button template) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Expected O, but got Unknown RectTransform val = (RectTransform)symbolMenu.transform; foreach (Transform item in (Transform)val) { ((Component)item).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)item).gameObject); } int pages = Math.Max(1, (availableSymbols.Count + 63) / 64); symbolPage = Math.Max(0, Math.Min(symbolPage, pages - 1)); int num = Math.Min(64, availableSymbols.Count - symbolPage * 64); int num2 = Math.Max(1, (num + 7) / 8); val.sizeDelta = new Vector2(292f, 20f + (float)num2 * 31f + 30f); AddMenuFrame(template, val); Vector2 val5 = default(Vector2); for (int i = 0; i < num; i++) { uint num3 = availableSymbols[symbolPage * 64 + i]; string symbol = char.ConvertFromUtf32((int)num3); Button source = template; int num4 = (int)num3; Button val3 = CloneButton(source, (Transform)(object)val, "Symbol_" + num4.ToString("X4")); RectTransform val4 = (RectTransform)((Component)val3).transform; ((Vector2)(ref val5))..ctor(0f, 1f); val4.anchorMax = val5; val4.anchorMin = val5; val4.pivot = new Vector2(0f, 1f); val4.sizeDelta = new Vector2(32f, 29f); val4.anchoredPosition = new Vector2(10f + (float)(i % 8) * 34f, -10f - (float)(i / 8) * 31f); Graphic[] components = ((Component)((Component)val3).transform.Find("PickerCaption")).GetComponents<Graphic>(); foreach (Graphic obj in components) { ((Behaviour)obj).enabled = false; Object.Destroy((Object)(object)obj); } GameObject val6 = new GameObject("UnicodeCaption", new Type[1] { typeof(RectTransform) }); val6.SetActive(false); RectTransform val7 = (RectTransform)val6.transform; ((Transform)val7).SetParent(((Component)val3).transform, false); val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = Vector2.zero; val7.offsetMax = Vector2.zero; TextMeshProUGUI obj2 = val6.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj2).font = symbolFont; ((TMP_Text)obj2).fontSize = 23f; ((TMP_Text)obj2).alignment = (TextAlignmentOptions)514; ((Graphic)obj2).color = Color.white; ((Graphic)obj2).raycastTarget = false; ((TMP_Text)obj2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj2).text = symbol; val6.SetActive(true); ((UnityEvent)val3.onClick).AddListener((UnityAction)delegate { InsertSymbol(symbol); }); } for (int num5 = 0; num5 < 3; num5++) { int control = num5; Button val8 = CloneButton(template, (Transform)(object)val, "SymbolPage_" + num5); RectTransform val9 = (RectTransform)((Component)val8).transform; ((Vector2)(ref val5))..ctor(0f, 1f); val9.anchorMax = val5; val9.anchorMin = val5; val9.pivot = new Vector2(0f, 1f); val9.sizeDelta = new Vector2((num5 == 1) ? 104f : 74f, 28f); val9.anchoredPosition = new Vector2(num5 switch { 1 => 88f, 0 => 10f, _ => 196f, }, -10f - (float)num2 * 31f); Caption(val8, num5 switch { 2 => ">", 0 => "<", _ => symbolPage + 1 + " / " + pages, }); if (num5 == 1 || pages == 1) { ((Selectable)val8).interactable = false; continue; } ((UnityEvent)val8.onClick).AddListener((UnityAction)delegate { symbolPage = (symbolPage + ((control != 0) ? 1 : (pages - 1))) % pages; BuildSymbols(template); }); } } private static void ArrangeButtonRow(RectTransform parent, Button cancel, Button ok) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)((Component)picker).transform; RectTransform val2 = (RectTransform)((Component)ok).transform; Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); float num = array.Min((Vector3 c) => ((Transform)parent).InverseTransformPoint(c).x); val2.GetWorldCorners(array); float num2 = array.Max((Vector3 c) => ((Transform)parent).InverseTransformPoint(c).x); RectTransform obj = parent; Rect rect = val.rect; float y = ((Transform)obj).InverseTransformPoint(((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center))).y; rect = val.rect; float height = ((Rect)(ref rect)).height; float num3 = num2 - num - 24f; Button[] array2 = (Button[])(object)new Button[4] { picker, symbolButton, cancel, ok }; float[] array3 = new float[4] { 0.2f, 0.25f, 0.33f, 0.22f }; Vector2 val3 = default(Vector2); for (int num4 = 0; num4 < array2.Length; num4++) { RectTransform rect2 = (RectTransform)((Component)array2[num4]).transform; if ((Object)(object)array2[num4] == (Object)(object)cancel || (Object)(object)array2[num4] == (Object)(object)ok) { Vector2 min = rect2.anchorMin; Vector2 max = rect2.anchorMax; Vector2 pivot = rect2.pivot; Vector2 size = rect2.sizeDelta; Vector3 position = rect2.anchoredPosition3D; RestoreButtons.Add(delegate { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rect2 == (Object)null)) { rect2.anchorMin = min; rect2.anchorMax = max; rect2.pivot = pivot; rect2.sizeDelta = size; rect2.anchoredPosition3D = position; } }); } float num5 = num3 * array3[num4]; Vector3 position2 = ((Transform)parent).TransformPoint(new Vector3(num + num5 * 0.5f, y, 0f)); RectTransform obj2 = rect2; RectTransform obj3 = rect2; ((Vector2)(ref val3))..ctor(0.5f, 0.5f); obj3.anchorMax = val3; obj2.anchorMin = val3; rect2.pivot = new Vector2(0.5f, 0.5f); rect2.sizeDelta = new Vector2(num5, height); ((Transform)rect2).position = position2; num += num5 + 8f; } } private static void InsertSymbol(string value) { string text = (string)Get("text"); PropertyInfo propertyInfo = AccessTools.Property(input.GetType(), "stringPosition") ?? AccessTools.Property(input.GetType(), "caretPosition"); int num = text.Length; Match match = Regex.Match(text, "</color>\\s*$", RegexOptions.IgnoreCase); if (match.Success) { num = match.Index; } int num2 = (int)Get("characterLimit"); if (num2 <= 0 || text.Length + value.Length <= num2) { Set("text", text.Insert(num, value)); if (propertyInfo != null && propertyInfo.CanWrite) { propertyInfo.SetValue(input, num + value.Length, null); } PropertyInfo propertyInfo2 = AccessTools.Property(input.GetType(), "stringSelectPosition"); if (propertyInfo2 != null && propertyInfo2.CanWrite) { propertyInfo2.SetValue(input, num + value.Length, null); } symbolMenu.SetActive(false); AccessTools.Method(input.GetType(), "ActivateInputField", Type.EmptyTypes, (Type[])null)?.Invoke(input, null); } } private void OnConfigSettingChanged(object sender, SettingChangedEventArgs args) { paletteDirty = true; } private void Update() { if (Time.unscaledTime >= nextConfigCheck) { nextConfigCheck = Time.unscaledTime + 0.5f; try { DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(((BaseUnityPlugin)this).Config.ConfigFilePath); if (File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath) && lastWriteTimeUtc != configWriteTime) { ((BaseUnityPlugin)this).Config.Reload(); configWriteTime = lastWriteTimeUtc; paletteDirty = true; } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Cannot reload palette config: " + ex.Message)); } } if (paletteDirty) { paletteDirty = false; if ((Object)(object)menu != (Object)null && (Object)(object)paletteTemplate != (Object)null) { RebuildPalette(); } } if (!((Object)(object)picker != (Object)null)) { return; } string text = (Russian ? "Russian" : "English"); if (text != captionLanguage) { captionLanguage = text; Caption(picker, Russian ? "Цвет" : "Color"); if ((Object)(object)symbolButton != (Object)null) { Caption(symbolButton, Russian ? "Символы" : "Symbols"); } MarkCurrent(); } } private static void RebuildPalette() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown if ((Object)(object)menu == (Object)null || (Object)(object)paletteTemplate == (Object)null) { return; } RectTransform val = (RectTransform)menu.transform; foreach (Transform item in (Transform)val) { ((Component)item).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)item).gameObject); } string[] array = Values.Concat(CustomHexColors()).ToArray(); int num = (array.Length + 4) / 5; val.sizeDelta = new Vector2(196f, 22f + (float)num * 36f); AddMenuFrame(paletteTemplate, val); Vector2 val5 = default(Vector2); for (int i = 0; i < array.Length; i++) { string selectedValue = array[i]; GameObject val3 = new GameObject("Color_" + i, new Type[3] { typeof(RectTransform), typeof(Image), typeof(Button) }); RectTransform val4 = (RectTransform)val3.transform; ((Transform)val4).SetParent((Transform)(object)val, false); ((Vector2)(ref val5))..ctor(0f, 1f); val4.anchorMax = val5; val4.anchorMin = val5; val4.pivot = new Vector2(0f, 1f); val4.sizeDelta = new Vector2(30f, 30f); val4.anchoredPosition = new Vector2(11f + (float)(i % 5) * 36f, -11f - (float)(i / 5) * 36f); Color black = Color.black; if (selectedValue.Length > 0) { ColorUtility.TryParseHtmlString(selectedValue, ref black); } Image component = val3.GetComponent<Image>(); ((Graphic)component).color = black; Button component2 = val3.GetComponent<Button>(); ((Selectable)component2).targetGraphic = (Graphic)(object)component; ((Selectable)component2).transition = (Transition)0; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)component2).navigation = navigation; ((UnityEvent)component2.onClick).AddListener((UnityAction)delegate { Apply(selectedValue); }); } } private static void ConfigReload() { try { ((BaseUnityPlugin)instance).Config.Reload(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)("Cannot reload palette config: " + ex.Message)); } } private static IEnumerable<string> CustomHexColors() { string[] array = instance.customColors.Value.Split(new char[6] { ',', ';', ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); Color val = default(Color); foreach (string text in array) { string text2 = text.Trim(); if (!text2.StartsWith("#")) { text2 = "#" + text2; } if (Regex.IsMatch(text2, "^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$") && ColorUtility.TryParseHtmlString(text2, ref val)) { yield return text2.ToUpperInvariant(); } else { ((BaseUnityPlugin)instance).Logger.LogWarning((object)("Skipping invalid custom HEX color: " + text)); } } } private static void AddMenuFrame(Button source, RectTransform parent) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PaletteFrame", new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)parent, false); Dictionary<Transform, Transform> mapping = new Dictionary<Transform, Transform>(); CopyVisuals(((Component)source).transform, val.transform, mapping); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.pivot = new Vector2(0.5f, 0.5f); val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; ((Transform)val2).localScale = Vector3.one; Image[] componentsInChildren = val.GetComponentsInChildren<Image>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Graphic)componentsInChildren[i]).raycastTarget = false; } } private static Button CloneButton(Button source, Transform parent, string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); Dictionary<Transform, Transform> dictionary = new Dictionary<Transform, Transform>(); CopyVisuals(((Component)source).transform, val.transform, dictionary); Button val2 = val.AddComponent<Button>(); ((Selectable)val2).transition = ((Selectable)source).transition; ((Selectable)val2).colors = ((Selectable)source).colors; ((Selectable)val2).spriteState = ((Selectable)source).spriteState; if ((Object)(object)((Selectable)source).targetGraphic != (Object)null && dictionary.TryGetValue(((Component)((Selectable)source).targetGraphic).transform, out var value)) { ((Selectable)val2).targetGraphic = ((Component)value).GetComponent<Graphic>(); } Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)val2).navigation = navigation; CreateCaption(source, val2); val.SetActive(true); return val2; } private static void CopyVisuals(Transform source, Transform target, Dictionary<Transform, Transform> mapping) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown mapping[source] = target; RectTransform val = (RectTransform)(object)((source is RectTransform) ? source : null); RectTransform val2 = (RectTransform)(object)((target is RectTransform) ? target : null); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { val2.anchorMin = val.anchorMin; val2.anchorMax = val.anchorMax; val2.pivot = val.pivot; val2.sizeDelta = val.sizeDelta; val2.anchoredPosition3D = val.anchoredPosition3D; ((Transform)val2).localRotation = ((Transform)val).localRotation; ((Transform)val2).localScale = ((Transform)val).localScale; } Image component = ((Component)source).GetComponent<Image>(); if ((Object)(object)component != (Object)null) { Image obj = ((Component)target).gameObject.AddComponent<Image>(); obj.sprite = component.sprite; obj.type = component.type; ((Graphic)obj).color = ((Graphic)component).color; ((Graphic)obj).material = ((Graphic)component).material; obj.preserveAspect = component.preserveAspect; obj.fillCenter = component.fillCenter; obj.pixelsPerUnitMultiplier = component.pixelsPerUnitMultiplier; ((Graphic)obj).raycastTarget = ((Graphic)component).raycastTarget; } foreach (Transform item in source) { Transform val3 = item; GameObject val4 = new GameObject(((Object)val3).name, new Type[1] { typeof(RectTransform) }); val4.transform.SetParent(target, false); CopyVisuals(val3, val4.transform, mapping); val4.SetActive(((Component)val3).gameObject.activeSelf); } } private static void CreateCaption(Button source, Button button) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PickerCaption", new Type[1] { typeof(RectTransform) }); val.SetActive(false); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(((Component)button).transform, false); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = new Vector2(5f, 2f); val2.offsetMax = new Vector2(-5f, -2f); Text val3 = ((IEnumerable<Text>)((Component)source).GetComponentsInChildren<Text>(false)).FirstOrDefault((Func<Text, bool>)((Text t) => (Object)(object)t.font != (Object)null)); if ((Object)(object)val3 != (Object)null) { Text obj = val.AddComponent<Text>(); obj.font = val3.font; obj.fontSize = val3.fontSize; obj.fontStyle = val3.fontStyle; obj.alignment = (TextAnchor)4; obj.supportRichText = true; ((Graphic)obj).raycastTarget = false; obj.horizontalOverflow = (HorizontalWrapMode)1; obj.verticalOverflow = (VerticalWrapMode)1; ((Graphic)obj).color = Color.white; } else { TMP_Text val4 = ((IEnumerable<TMP_Text>)((Component)source).GetComponentsInChildren<TMP_Text>(false)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => (Object)(object)t.font != (Object)null)); if ((Object)(object)val4 == (Object)null) { throw new InvalidOperationException("Button font not found"); } TextMeshProUGUI obj2 = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj2).font = val4.font; Material val5 = new Material(val4.fontSharedMaterial); if (val5.HasProperty("_FaceColor")) { val5.SetColor("_FaceColor", Color.white); } ((TMP_Text)obj2).fontMaterial = val5; ((TMP_Text)obj2).fontSize = val4.fontSize; ((TMP_Text)obj2).fontStyle = val4.fontStyle; ((TMP_Text)obj2).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj2).enableAutoSizing = true; ((TMP_Text)obj2).fontSizeMin = 12f; ((TMP_Text)obj2).fontSizeMax = val4.fontSize; ((TMP_Text)obj2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj2).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj2).richText = true; ((Graphic)obj2).color = Color.white; ((Graphic)obj2).raycastTarget = false; ((TMP_Text)obj2).enableVertexGradient = false; } val.SetActive(true); } private static void SetCaptionColor(Button button, Color color) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)button).transform.Find("PickerCaption"); if (!((Object)(object)val == (Object)null)) { string text = ColorUtility.ToHtmlStringRGB(color); TMP_Text[] components = ((Component)val).GetComponents<TMP_Text>(); foreach (TMP_Text val2 in components) { string text2 = ColorTags.Replace(val2.text, ""); ((Graphic)val2).color = Color.white; val2.text = "<color=#" + text + ">" + text2 + "</color>"; } Text[] components2 = ((Component)val).GetComponents<Text>(); foreach (Text val3 in components2) { string text3 = ColorTags.Replace(val3.text, ""); ((Graphic)val3).color = Color.white; val3.text = "<color=#" + text + ">" + text3 + "</color>"; } } } private static void Caption(Button button, string text) { Transform val = ((Component)button).transform.Find("PickerCaption"); if (!((Object)(object)val == (Object)null)) { TMP_Text[] components = ((Component)val).GetComponents<TMP_Text>(); for (int i = 0; i < components.Length; i++) { components[i].text = text; } Text[] components2 = ((Component)val).GetComponents<Text>(); for (int i = 0; i < components2.Length; i++) { components2[i].text = text; } } } private static void Apply(string value) { string text = ColorTags.Replace((string)Get("text"), ""); Set("text", (value.Length == 0) ? text : ("<color=" + value + ">" + text + "</color>")); menu.SetActive(false); MarkCurrent(); AccessTools.Method(input.GetType(), "ActivateInputField", Type.EmptyTypes, (Type[])null)?.Invoke(input, null); } private static void MarkCurrent() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) Match match = OuterColor.Match((string)Get("text")); string obj = (match.Success ? match.Groups[1].Value : ""); Color black = Color.black; if (!ColorUtility.TryParseHtmlString(obj, ref black)) { black = Color.black; } SetCaptionColor(picker, black); } private static void PositionPicker(GameObject panel, Button cancel, RectTransform rootRect, RectTransform rect) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) Button val = ((IEnumerable<Button>)panel.GetComponentsInChildren<Button>(true)).FirstOrDefault((Func<Button, bool>)((Button b) => (Object)(object)b != (Object)(object)cancel && Enumerable.Range(0, ((UnityEventBase)b.onClick).GetPersistentEventCount()).Any((int i) => ((UnityEventBase)b.onClick).GetPersistentMethodName(i) == "OnInput" || ((UnityEventBase)b.onClick).GetPersistentMethodName(i) == "OnEnter"))); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("OK button not found"); } RectTransform frame = default(RectTransform); ref RectTransform reference = ref frame; Transform parent = ((Component)cancel).transform.parent; reference = (RectTransform)(object)((parent is RectTransform) ? parent : null); Transform parent2 = ((Component)cancel).transform.parent; while ((Object)(object)parent2 != (Object)null) { if ((Object)(object)((Component)parent2).GetComponent<Image>() != (Object)null && ((Component)val).transform.IsChildOf(parent2)) { frame = (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); break; } if ((Object)(object)parent2 == (Object)(object)panel.transform) { break; } parent2 = parent2.parent; } if ((Object)(object)frame == (Object)null) { throw new InvalidOperationException("Dialog frame not found"); } Vector3[] array = (Vector3[])(object)new Vector3[4]; ((RectTransform)((Component)val).transform).GetWorldCorners(array); float num = array.Max((Vector3 c) => ((Transform)frame).InverseTransformPoint(c).x); Rect rect2 = frame.rect; float num2 = ((Rect)(ref rect2)).xMax - num; RectTransform val2 = (RectTransform)((Component)cancel).transform; RectTransform obj = frame; rect2 = val2.rect; Vector3 val3 = ((Transform)obj).InverseTransformPoint(((Transform)val2).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect2)).center))); rect2 = frame.rect; float num3 = ((Rect)(ref rect2)).xMin + num2; rect2 = rect.rect; val3.x = num3 + ((Rect)(ref rect2)).width * 0.5f; ((Transform)rect).localPosition = ((Transform)rootRect).InverseTransformPoint(((Transform)frame).TransformPoint(val3)); } [HarmonyPatch(typeof(TextInput), "Hide")] [HarmonyPostfix] private static void AfterHide(TextInput __instance) { if ((Object)(object)owner == (Object)(object)__instance) { Cleanup(); } } }