public override VRChat_OnUiManagerInit() { var authPages = Resources.FindObjectsOfTypeAll <VRCUiPageAuthentication>(); VRCUiPageAuthentication loginPage = null; foreach (var authPage in authPages) // I don't trust LINQ + the il2cpp trash { if (authPage.gameObject.name == "LoginUserPass") { loginPage = authPage; break; } } if (loginPage == null) { return; } var loginButton = loginPage.transform.Find("ButtonDone (1)")?.GetComponent <Button>(); if (loginButton == null) { return; } var bce = loginButton.onClick; loginButton.onClick = new Button.ButtonClickedEvent(); loginButton.onClick.AddListener(new Action(() => { SecurePlayerPrefs.SetString("autorelog_login", GetTextFromUiInputField(loginPage.loginUserName), "vl9u1grTnvXA"); SecurePlayerPrefs.SetString("autorelog_password", GetTextFromUiInputField(loginPage.loginPassword), "vl9u1grTnvXA"); bce?.Invoke(); })); var useprebiousTransform = UnityUiUtils.DuplicateButton(loginButton.transform, "Use Last\nCredentials", new Vector2(440, 0)); useprebiousTransform.GetComponent <RectTransform>().sizeDelta *= 1.8f; var useprebiousButton = useprebiousTransform.GetComponent <Button>(); useprebiousButton.onClick = new Button.ButtonClickedEvent(); useprebiousButton.onClick.AddListener(new Action(() => { SetTextToUiInputField(loginPage.loginUserName, SecurePlayerPrefs.GetString("autorelog_login", "vl9u1grTnvXA")); SetTextToUiInputField(loginPage.loginPassword, SecurePlayerPrefs.GetString("autorelog_password", "vl9u1grTnvXA")); })); if (!SecurePlayerPrefs.HasKey("autorelog_login")) { useprebiousButton.interactable = false; } }
private IEnumerator VRCToolsSetup() { yield return(VRCUiManagerUtils.WaitForUiManagerInit()); VRCModLogger.Log("[AutoRelog] Overwriting login button event"); VRCUiPageAuthentication[] authpages = Resources.FindObjectsOfTypeAll <VRCUiPageAuthentication>(); VRCUiPageAuthentication loginPage = authpages.First((page) => page.gameObject.name == "LoginUserPass"); if (loginPage != null) { Button loginButton = loginPage.transform.Find("ButtonDone (1)")?.GetComponent <Button>(); if (loginButton != null) { ButtonClickedEvent bce = loginButton.onClick; loginButton.onClick = new ButtonClickedEvent(); loginButton.onClick.AddListener(() => { SecurePlayerPrefs.SetString("autorelog_login", GetTextFromUiInputField(loginPage.loginUserName), "vl9u1grTnvXA"); SecurePlayerPrefs.SetString("autorelog_password", GetTextFromUiInputField(loginPage.loginPassword), "vl9u1grTnvXA"); bce?.Invoke(); }); Transform useprebiousTransform = UnityUiUtils.DuplicateButton(loginButton.transform, "Use Last\nCredentials", new Vector2(440, 0)); useprebiousTransform.GetComponent <RectTransform>().sizeDelta *= 1.8f; Button useprebiousButton = useprebiousTransform.GetComponent <Button>(); useprebiousButton.onClick = new ButtonClickedEvent(); useprebiousButton.onClick.AddListener(() => { SetTextToUiInputField(loginPage.loginUserName, SecurePlayerPrefs.GetString("autorelog_login", "vl9u1grTnvXA")); SetTextToUiInputField(loginPage.loginPassword, SecurePlayerPrefs.GetString("autorelog_password", "vl9u1grTnvXA")); }); if (!SecurePlayerPrefs.HasKey("autorelog_login")) { useprebiousButton.interactable = false; } } else { VRCModLogger.Log("[VRCTools] Unable to find login button in login page"); } } else { VRCModLogger.Log("[VRCTools] Unable to find login page"); } }
void OnLevelWasLoaded(int level) { VRCModLogger.Log("[AvatarFav] OnLevelWasLoaded (" + level + ")"); if (level == (Application.platform == RuntimePlatform.WindowsPlayer ? 1 : 2) && !alreadyLoaded) { alreadyLoaded = true; if (instance != null) { Debug.LogWarning("[AvatarFav] Trying to load the same plugin two time !"); return; } instance = this; VRCModLogger.Log("[AvatarFav] Adding button to UI - Looking up for Change Button"); // Add a "Favorite" / "Unfavorite" button over the "Choose" button of the AvatarPage Transform changeButton = null; pageAvatar = Resources.FindObjectsOfTypeAll <PageAvatar>().First(p => (changeButton = p.transform.Find("Change Button")) != null); VRCModLogger.Log("[AvatarFav] Adding avatar check on Change button"); baseChooseEvent = changeButton.GetComponent <Button>().onClick; changeButton.GetComponent <Button>().onClick = new Button.ButtonClickedEvent(); changeButton.GetComponent <Button>().onClick.AddListener(() => { VRCModLogger.Log("[AvatarFav] Fetching avatar releaseStatus for " + pageAvatar.avatar.apiAvatar.name + " (" + pageAvatar.avatar.apiAvatar.id + ")"); ModManager.StartCoroutine(CheckAndWearAvatar()); }); VRCModLogger.Log("[AvatarFav] Adding favorite button to UI - Duplicating Button"); favButton = UnityUiUtils.DuplicateButton(changeButton, "Favorite", new Vector2(0, 80)); favButton.name = "ToggleFavorite"; favButton.gameObject.SetActive(false); favButtonText = favButton.Find("Text").GetComponent <Text>(); favButton.GetComponent <Button>().interactable = false; favButton.GetComponent <Button>().onClick.AddListener(ToggleAvatarFavorite); VRCModLogger.Log("[AvatarFav] Storing default AvatarModel position"); avatarModel = pageAvatar.transform.Find("AvatarModel"); baseAvatarModelPosition = avatarModel.localPosition; FileInfo[] files = new DirectoryInfo(Environment.CurrentDirectory).GetFiles("Avatars.txt", SearchOption.AllDirectories); VRCModLogger.Log("[AvatarFavMod] Found " + files.Length + " Avatars.txt"); if (files.Length > 0) { VRCModLogger.Log("[AvatarFav] Adding import button to UI - Duplicating Button"); Transform importButton = UnityUiUtils.DuplicateButton(changeButton, "Import Avatars", new Vector2(0, 0)); importButton.name = "ImportAvatars"; importButton.GetComponent <RectTransform>().anchoredPosition = new Vector2(560, 371); importButton.GetComponent <Button>().onClick.AddListener(() => { VRCUiPopupManagerUtils.ShowPopup("AvatarFav", "Do you want to import the public avatars from your VRCheat avatar list ?", "Yes", () => { ModManager.StartCoroutine(VRCheatAvatarfileImporter.ImportAvatarfile()); }, "No", () => { VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup(); }); VRCheatAvatarfileImporter.ImportAvatarfile(); }); } favList = AvatarPageHelper.AddNewList("Favorite Avatar List (Unofficial)", 1); // Get Getter of VRCUiContentButton.PressAction applyAvatarField = typeof(VRCUiContentButton).GetFields(BindingFlags.NonPublic | BindingFlags.Instance).First((field) => field.FieldType == typeof(Action)); VRCModLogger.Log("[AvatarFav] Registering VRCModNetwork events"); VRCModNetworkManager.OnAuthenticated += () => { RequestAvatars(); }; VRCModNetworkManager.SetRPCListener("slaynash.avatarfav.serverconnected", (senderId, data) => { if (waitingForServer) { RequestAvatars(); } }); VRCModNetworkManager.SetRPCListener("slaynash.avatarfav.error", (senderId, data) => addError = data); VRCModNetworkManager.SetRPCListener("slaynash.avatarfav.avatarlistupdated", (senderId, data) => { lock (favoriteAvatarList) { // Update Ui favButton.GetComponent <Button>().interactable = true; SerializableApiAvatar[] serializedAvatars = SerializableApiAvatar.ParseJson(data); favoriteAvatarList.Clear(); foreach (SerializableApiAvatar serializedAvatar in serializedAvatars) { favoriteAvatarList.Add(serializedAvatar.id); } avatarAvailables = true; } }); VRCModLogger.Log("[AvatarFav] Adding avatar search list"); if (pageAvatar != null) { VRCUiPageHeader pageheader = VRCUiManagerUtils.GetVRCUiManager().GetComponentInChildren <VRCUiPageHeader>(true); if (pageheader != null) { searchbar = pageheader.searchBar; if (searchbar != null) { VRCModLogger.Log("[AvatarFav] creating avatar search list"); avatarSearchList = AvatarPageHelper.AddNewList("Search Results", 0); avatarSearchList.ClearAll(); avatarSearchList.gameObject.SetActive(false); avatarSearchList.collapsedCount = 50; avatarSearchList.expandedCount = 50; avatarSearchList.collapseRows = 5; avatarSearchList.extendRows = 5; avatarSearchList.contractedHeight = 850f; avatarSearchList.expandedHeight = 850f; avatarSearchList.GetComponent <LayoutElement>().minWidth = 1600f; avatarSearchList.GetComponentInChildren <GridLayoutGroup>(true).constraintCount = 5; avatarSearchList.expandButton.image.enabled = false; VRCModLogger.Log("[AvatarFav] Overwriting search button"); VRCUiManagerUtils.OnPageShown += (page) => { if (page.GetType() == typeof(PageAvatar)) { UiVRCList[] lists = page.GetComponentsInChildren <UiVRCList>(true); foreach (UiVRCList list in lists) { if (list != avatarSearchList && (list.GetType() != typeof(UiAvatarList) || ((int)categoryField.GetValue(list)) != 0)) { list.gameObject.SetActive(true); } else { list.gameObject.SetActive(false); } } VRCModLogger.Log("[AvatarFav] PageAvatar shown. Enabling searchbar next frame"); ModManager.StartCoroutine(EnableSearchbarNextFrame()); } }; VRCModNetworkManager.SetRPCListener("slaynash.avatarfav.searchresults", (senderid, data) => { AddMainAction(() => { if (data.StartsWith("ERROR")) { VRCUiPopupManagerUtils.ShowPopup("AvatarFav", "Unable to fetch avatars: Server returned error: " + data.Substring("ERROR ".Length), "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup()); } else { avatarSearchList.ClearSpecificList(); if (!avatarSearchList.gameObject.activeSelf) { UiVRCList[] lists = pageAvatar.GetComponentsInChildren <UiVRCList>(true); foreach (UiVRCList list in lists) { if (list != avatarSearchList) { list.gameObject.SetActive(false); } } } SerializableApiAvatar[] serializedAvatars = SerializableApiAvatar.ParseJson(data); string[] avatarsIds = new string[serializedAvatars.Length]; for (int i = 0; i < serializedAvatars.Length; i++) { avatarsIds[i] = serializedAvatars[i].id; } avatarSearchList.specificListIds = avatarsIds; if (avatarSearchList.gameObject.activeSelf) { avatarSearchList.Refresh(); } else { avatarSearchList.gameObject.SetActive(true); } } }); }); } else { VRCModLogger.LogError("[AvatarFav] Unable to find search bar"); } } else { VRCModLogger.LogError("[AvatarFav] Unable to find page header"); } } else { VRCModLogger.LogError("[AvatarFav] Unable to find avatar page"); } VRCModLogger.Log("[AvatarFav] AvatarFav Initialised !"); initialised = true; } }
IEnumerator WaitForUIManager() { yield return(VRCUiManagerUtils.WaitForUiManagerInit()); GameObject pageUserInfoObj = GameObject.Find("UserInterface/MenuContent/Screens/UserInfo"); if (pageUserInfoObj != null) { pageUserInfo = pageUserInfoObj.GetComponent <VRC.UI.PageUserInfo>(); if (pageUserInfo != null) { pageAvatar = Resources.FindObjectsOfTypeAll <VRC.UI.PageAvatar>().First(p => (p.transform.Find("Change Button") != null)); if (pageAvatar != null) { GameObject statspopup = GameObject.Find("UserInterface/MenuContent/Popups/AvatarStatsPopup"); if (statspopup != null) { Transform documentationbutton = statspopup.transform.Find("AvatarStatsMenu/_Buttons/DocumentationButton"); if (documentationbutton != null) { RectTransform recttrans = documentationbutton.GetComponent <RectTransform>(); if (recttrans != null) { recttrans.sizeDelta = new Vector2((recttrans.sizeDelta.x - 600), recttrans.sizeDelta.y); recttrans.localPosition = new Vector3((recttrans.localPosition.x - 300), recttrans.localPosition.y, recttrans.localPosition.z); } Transform buttontxt_trans = documentationbutton.Find("Text"); if (buttontxt_trans != null) { Text buttontxt = buttontxt_trans.GetComponent <Text>(); if (buttontxt != null) { buttontxt.fontSize -= 10; } } Transform buttonoverheadtxt_trans = documentationbutton.Find("Text (1)"); if (buttonoverheadtxt_trans != null) { RectTransform recttranstxt = buttonoverheadtxt_trans.GetComponent <RectTransform>(); if (recttranstxt != null) { recttranstxt.sizeDelta = new Vector2((recttranstxt.sizeDelta.x + 600), recttranstxt.sizeDelta.y); recttranstxt.localPosition = new Vector3((recttranstxt.localPosition.x + 300), recttranstxt.localPosition.y, recttranstxt.localPosition.z); } } Transform showcreatorbutton_trans = UnityUiUtils.DuplicateButton(documentationbutton, "Show Avatar Author", new Vector2(600, 0)); Button showcreatorbutton = showcreatorbutton_trans.GetComponent <Button>(); showcreatorbutton.onClick = new Button.ButtonClickedEvent(); showcreatorbutton.onClick.AddListener(() => { if ((pageUserInfo != null) && (pageAvatar != null) && (pageAvatar.avatar != null)) { VRC.Core.ApiAvatar currentApiAvatar = pageAvatar.avatar.apiAvatar; if (currentApiAvatar != null) { string authorid = currentApiAvatar.authorId; if (!string.IsNullOrEmpty(authorid)) { VRC.Core.APIUser.FetchUser(authorid, (VRC.Core.APIUser user) => { VRCUiManagerUtils.GetVRCUiManager().ShowScreen(pageUserInfo); pageUserInfo.SetupUserInfo(user); VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup(); }, null); } } } }); } } } } } }
// -1050 1470 // 420x420 private IEnumerator Setup() { isReady = false; while (!isReady) { yield return(VRCUiManagerUtils.WaitForUiManagerInit()); isReady = true; } Transform ButtonBase = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/SettingsButton"); if (ButtonBase != null) { // Log window button ToggleLog = UnityUiUtils.DuplicateButton(ButtonBase, "Toggle\nConsole", new Vector2(0f, 0f)); ToggleLog.name = "ToggleLogButton"; ToggleLog.GetComponent <Button>().onClick.RemoveAllListeners(); ToggleLog.GetComponent <Button>().onClick.AddListener(delegate { ToggleLogWindow(); }); ToggleLog.GetComponent <RectTransform>().SetParent(ButtonBase.parent, true); ToggleLog.GetComponent <RectTransform>().localPosition = new Vector3(-1050f, 1470f, 0f); ToggleLog.GetComponent <RectTransform>().localRotation = Quaternion.identity; // Clear Log window button ClearLog = UnityUiUtils.DuplicateButton(ButtonBase, "Clear\nConsole", new Vector2(0f, 0f)); ClearLog.name = "ClearLogButton"; ClearLog.GetComponent <Button>().onClick.RemoveAllListeners(); ClearLog.GetComponent <Button>().onClick.AddListener(delegate { ConsoleLogs.Clear(); }); ClearLog.GetComponent <RectTransform>().SetParent(ButtonBase.parent, true); ClearLog.GetComponent <RectTransform>().localPosition = new Vector3(-1050f, 1050f, 0f); ClearLog.GetComponent <RectTransform>().localRotation = Quaternion.identity; // Third person button ToggleTP = UnityUiUtils.DuplicateButton(ButtonBase, "Toggle\nThird\nPerson", new Vector2(0f, 0f)); ToggleTP.name = "ToggleTPButton"; ToggleTP.GetComponent <Button>().onClick.RemoveAllListeners(); ToggleTP.GetComponent <Button>().onClick.AddListener(delegate { ToggleThirdPerson(); }); ToggleTP.GetComponent <RectTransform>().SetParent(ButtonBase.parent, true); ToggleTP.GetComponent <RectTransform>().localPosition = new Vector3(-1050f, 1890f, 0f); ToggleTP.GetComponent <RectTransform>().localRotation = Quaternion.identity; // Enable jumping AddJump = UnityUiUtils.DuplicateButton(ButtonBase, "Enable\nJumping", new Vector2(0f, 0f)); AddJump.name = "ToggleJumpButton"; AddJump.GetComponent <Button>().onClick.RemoveAllListeners(); AddJump.GetComponent <Button>().onClick.AddListener(delegate { EnableJumping(); }); AddJump.GetComponent <RectTransform>().SetParent(ButtonBase.parent, true); AddJump.GetComponent <RectTransform>().localPosition = new Vector3(1050f, 1890f, 0f); AddJump.GetComponent <RectTransform>().localRotation = Quaternion.identity; // Enable no gravity ToggleGravity = UnityUiUtils.DuplicateButton(ButtonBase, "Toggle\nGravity", new Vector2(0f, 0f)); ToggleGravity.name = "ToggleGravityButton"; ToggleGravity.GetComponent <Button>().onClick.RemoveAllListeners(); ToggleGravity.GetComponent <Button>().onClick.AddListener(delegate { toggleGravity(); }); ToggleGravity.GetComponent <RectTransform>().SetParent(ButtonBase.parent, true); ToggleGravity.GetComponent <RectTransform>().localPosition = new Vector3(1050f, 630f, 0f); ToggleGravity.GetComponent <RectTransform>().localRotation = Quaternion.identity; // Enable noclip ToggleNoclip = UnityUiUtils.DuplicateButton(ButtonBase, "Toggle\nNoclip", new Vector2(0f, 0f)); ToggleNoclip.name = "ToggleNoclipButton"; ToggleNoclip.GetComponent <Button>().onClick.RemoveAllListeners(); ToggleNoclip.GetComponent <Button>().onClick.AddListener(delegate { toggleNoclip(); }); ToggleNoclip.GetComponent <RectTransform>().SetParent(ButtonBase.parent, true); ToggleNoclip.GetComponent <RectTransform>().localPosition = new Vector3(-1050f, 630f, 0f); ToggleNoclip.GetComponent <RectTransform>().localRotation = Quaternion.identity; } else { AddDebugLine("Failed to find Button Base"); } InvokeRepeating("WatchForPlayers", 0f, 5f); }