private void LoadUserInfoScreen() { // Refresh Button VRCEUiButton btnRefresh = new VRCEUiButton("refresh", new Vector2(0f, 0f), "Refresh"); btnRefresh.OnClick += () => { if (string.IsNullOrEmpty(PageUserInfo.userIdOfLastUserPageInfoViewed)) { return; } string id = PageUserInfo.userIdOfLastUserPageInfoViewed; ApiCache.Invalidate <APIUser>(id); APIUser.FetchUser(id, user => { PageUserInfo pageUserInfo = VRCEUi.UserInfoScreen.GetComponent <PageUserInfo>(); if (pageUserInfo != null) { pageUserInfo.SetupUserInfo(user); } }, error => VRCModLogger.LogError($"Failed to fetch user of id {id}: {error}")); }; VRCMenuUtilsAPI.AddUserInfoButton(btnRefresh); }
public IEnumerator Setup() { yield return(VRCMenuUtilsAPI.WaitForInit()); var DropPortalButton = new VRCEUiButton("Portal", Vector2.zero, "Drop Portal"); DropPortalButton.OnClick += () => { //VRCMenuUtilsAPI.GetPage(VRCEUi.UserInfoScreen.name).GetComponentInChildren<PageUserInfo>().user; APIUser usr = VRCEUi.UserInfoScreen.GetComponentInChildren <PageUserInfo>().user; if (usr.id == APIUser.CurrentUser.id) { VRCMenuUtilsAPI.VRCUiPopupManager.ShowAlert("Error", "You cannot drop a portal to yourself!"); return; } else if (string.IsNullOrEmpty(usr.location)) { VRCMenuUtilsAPI.VRCUiPopupManager.ShowAlert("Error", usr.displayName + " has no valid location!"); return; } else if (usr.location.ToLower() == "private") { VRCMenuUtilsAPI.VRCUiPopupManager.ShowAlert("Error", usr.displayName + " is in a private world!"); return; } else if (usr.location.ToLower() == "offline") { VRCMenuUtilsAPI.VRCUiPopupManager.ShowAlert("Error", usr.displayName + " is offline!"); return; } string id = usr.location; string[] instance = id.Split(':'); if (instance.Length == 2) { DropPortalToWorld(instance[0], instance[1]); } else { DropPortalToWorld(id); } }; VRCMenuUtilsAPI.AddUserInfoButton(DropPortalButton); }