public static void Postfix(OptionsMenuBehaviour __instance) { if (__instance.CensorChatButton != null) { if (origin == null) { origin = __instance.CensorChatButton.transform.localPosition + Vector3.up * 0.25f; } __instance.CensorChatButton.transform.localPosition = origin.Value + Vector3.left * 1.3f; } if ((streamerModeButton == null || streamerModeButton.gameObject == null)) { streamerModeButton = createCustomToggle("Hide Code: ", StreamHatsPlugin.HideCode.Value, Vector3.right * 1.3f, (UnityEngine.Events.UnityAction)streamerModeToggle, __instance); void streamerModeToggle() { StreamHatsPlugin.HideCode.Value = !StreamHatsPlugin.HideCode.Value; updateToggle(streamerModeButton, "Hide Code: ", StreamHatsPlugin.HideCode.Value); } } if ((ghostsSeeTasksandRolesButton == null || ghostsSeeTasksandRolesButton.gameObject == null)) { ghostsSeeTasksandRolesButton = createCustomToggle("Ghosts See Other's Roles and Tasks: ", StreamHatsPlugin.ghostsSeeTasksandRoles.Value, new Vector2(0.0f, -0.5f), (UnityEngine.Events.UnityAction)ghostsSeeTaskToggle, __instance); void ghostsSeeTaskToggle() { StreamHatsPlugin.ghostsSeeTasksandRoles.Value = !StreamHatsPlugin.ghostsSeeTasksandRoles.Value; MapOptions.ghostsSeeTasksandRoles = StreamHatsPlugin.ghostsSeeTasksandRoles.Value; updateToggle(ghostsSeeTasksandRolesButton, "Ghosts See Other's Roles and Tasks: ", StreamHatsPlugin.ghostsSeeTasksandRoles.Value); } } }
private static void updateToggle(ToggleButtonBehaviour button, string text, bool on) { if (button == null || button.gameObject == null) { return; } Color color = on ? new Color(0f, 1f, 0.16470589f, 1f) : Color.white; button.Background.color = color; button.Text.text = $"{text}{(on ? "On" : "Off")}"; if (button.Rollover) { button.Rollover.ChangeOutColor(color); } }
public static void Postfix(OptionsMenuBehaviour __instance) { if ((streamerModeButton == null || streamerModeButton.gameObject == null) && __instance.CensorChatButton != null) { streamerModeButton = UnityEngine.Object.Instantiate(__instance.CensorChatButton, __instance.CensorChatButton.transform.parent); streamerModeButton.transform.localPosition += Vector3.down * 0.25f; __instance.CensorChatButton.transform.localPosition += Vector3.up * 0.25f; PassiveButton button = streamerModeButton.GetComponent <PassiveButton>(); button.OnClick = new Button.ButtonClickedEvent(); button.OnClick.AddListener((UnityEngine.Events.UnityAction)onClick); updateStreamerModeButton(); } void onClick() { TheOtherRolesPlugin.StreamerMode.Value = !TheOtherRolesPlugin.StreamerMode.Value; updateStreamerModeButton(); } }
private static void InitializeMoreButton(OptionsMenuBehaviour __instance) { __instance.BackButton.transform.localPosition += Vector3.right * 1.8f; moreOptions = Object.Instantiate(buttonPrefab, __instance.CensorChatButton.transform.parent); moreOptions.transform.localPosition = __instance.CensorChatButton.transform.localPosition + Vector3.down * 0.5f; moreOptions.gameObject.SetActive(true); moreOptions.Text.text = ModTranslation.getString("modOptionsText"); var moreOptionsButton = moreOptions.GetComponent <PassiveButton>(); moreOptionsButton.OnClick = new ButtonClickedEvent(); moreOptionsButton.OnClick.AddListener((Action)(() => { if (!popUp) { return; } if (__instance.transform.parent && __instance.transform.parent == HudManager.Instance.transform) { popUp.transform.SetParent(HudManager.Instance.transform); popUp.transform.localPosition = new Vector3(0, 0, -800f); } else { popUp.transform.SetParent(null); Object.DontDestroyOnLoad(popUp); } CheckSetTitle(); RefreshOpen(); })); var leaveGameButton = GameObject.Find("LeaveGameButton"); if (leaveGameButton != null) { leaveGameButton.transform.localPosition += (Vector3.right * 1.3f); } }
public static void OptionsMenuBehaviour_StartPostfix(OptionsMenuBehaviour __instance) { if (!__instance.CensorChatButton) { return; } if (!popUp) { CreateCustom(__instance); } if (!buttonPrefab) { buttonPrefab = Object.Instantiate(__instance.CensorChatButton); Object.DontDestroyOnLoad(buttonPrefab); buttonPrefab.name = "CensorChatPrefab"; buttonPrefab.gameObject.SetActive(false); } SetUpOptions(); InitializeMoreButton(__instance); }