예제 #1
0
        public void GetUserFromPlatformID(PlayerInfoViewController vc)
        {
            //StopAllCoroutines();
            StopCoroutine(GetUserEnumerator(null, null, null));
            //StartCoroutine(GetUserEnumerator("cc0d001a-9441-4768-a5e8-56f0e2e612a4", vc));
            string id = GetUserInfo.GetUserID().ToString();

            if (id.StartsWith("7656"))
            {
                //STEAM
                StartCoroutine(GetUserEnumerator(id, vc, "steamId"));
            }
            else if (id.Length == 16)
            {
                //OCULUS
                StartCoroutine(GetUserEnumerator(id, vc, "oculusId"));
            }
        }
예제 #2
0
        private IEnumerator GetUserEnumerator(string platformID, PlayerInfoViewController playerInfoViewController, string type)
        {
            User            currentPlayer = new User();
            UnityWebRequest www           = UnityWebRequest.Get(Global.BeatBoardsAPIURL + "/users" + $"?{type}=" + platformID);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Logger.Log.Error(www.error);
                yield return(new WaitForSeconds(.05f));
            }
            else
            {
                currentPlayer = JsonConvert.DeserializeObject <List <User> >(www.downloadHandler.text).FirstOrDefault();
                playerInfoViewController.activeUser = currentPlayer;
                playerInfoViewController.LoadData();
            }
            yield break;
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                title = "Beat Boards Menu";

                _playerInfoViewController  = BeatSaberUI.CreateViewController <PlayerInfoViewController>();
                _friendsListViewController = BeatSaberUI.CreateViewController <FriendsListViewController>();

                _playerInfoViewController.NameButtonPressed  += _playerInfoViewController_editNameButtonPressed;
                _playerInfoViewController.ImageButtonPressed += _playerInfoViewController_editImageButtonPressed;

                _friendsListViewController.AddFriendButtonPressed += _friendsListViewController_addFriendButtonPressed;

                LoadData();
            }

            SetViewControllersToNavigationConctroller(_beatBoardsMenuNavigationController, new VRUIViewController[]
            {
                _playerInfoViewController
            });
            ProvideInitialViewControllers(_beatBoardsMenuNavigationController, _friendsListViewController);
        }