Beispiel #1
0
        public static void Init()
        {
            if (isInitialized)
            {
                return;
            }

            // make sure the api url is set correctly before attempting to log in
            RefreshApiUrlSetting();

            if (!APIUser.IsLoggedInWithCredentials && ApiCredentials.Load())
            {
                APIUser.FetchCurrentUser((c) => AnalyticsSDK.LoggedInUserChanged(c.Model as APIUser), null);
            }

            clientInstallPath = SDKClientUtilities.GetSavedVRCInstallPath();
            if (string.IsNullOrEmpty(clientInstallPath))
            {
                clientInstallPath = SDKClientUtilities.LoadRegistryVRCInstallPath();
            }

            signingIn     = false;
            isInitialized = true;

            VRCContentManagerWindow.ClearContent();
        }
        new void Start()
        {
            if (!Application.isEditor || !Application.isPlaying)
            {
                return;
            }

            base.Start();

            IsCurrentWorldInCommunityLabs   = false;
            IsCurrentWorldUploaded          = false;
            IsCurrentWorldPubliclyPublished = false;


            var desc = pipelineManager.GetComponent <VRC_SceneDescriptor>();

            desc.PositionPortraitCamera(imageCapture.shotCamera.transform);

            Application.runInBackground       = true;
            UnityEngine.XR.XRSettings.enabled = false;

            uploadButton.onClick.AddListener(SetupUpload);

            openCommunityLabsDocsButton.onClick.AddListener(OpenCommunityLabsDocumentation);

            shouldUpdateImageToggle.onValueChanged.AddListener(ToggleUpdateImage);

            releasePublic.gameObject.SetActive(false);

            System.Action <string> onError = (err) => {
                VRC.Core.Logger.LogError("Could not authenticate - " + err, DebugLevel.Always);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(true);
            };

            if (!ApiCredentials.Load())
            {
                onError("Not logged in");
            }
            else
            {
                APIUser.FetchCurrentUser(
                    delegate(ApiModelContainer <APIUser> c)
                {
                    UserLoggedInCallback(c.Model as APIUser);
                },
                    delegate(ApiModelContainer <APIUser> c)
                {
                    onError(c.Error);
                }
                    );
            }

#if !COMMUNITY_LABS_SDK
            publishToCommunityLabsPanel.gameObject.SetActive(false);
#endif
        }
Beispiel #3
0
        private static void AuthenticateWithVRChat(System.Action <bool> onAuthed = null)
        {
            System.Action <ApiModelContainer <APIUser> > loginSuccessDelegate = (c) =>
            {
                if (c.Model == null || string.IsNullOrEmpty(c.Model.id))
                {
                    VRC.Core.Logger.LogError(string.Format("Failed to call login: invalid id received"));
                    Logout();
                }
                else
                {
                    VRC.Core.Logger.Log(
                        "User Authenticated: " + APIUser.CurrentUser.displayName + Environment.NewLine
                        );
                }
                signingIn = false;
                if (onAuthed != null)
                {
                    onAuthed(APIUser.IsLoggedInWithCredentials);
                }
            };
            System.Action <ApiModelContainer <APIUser> > loginFailureDelegate = (c) =>
            {
                VRC.Core.Logger.LogError(string.Format("Failed to call login: {0}", (c != null) ? c.Error : "error"));
                if (c != null)
                {
                    VRC.Core.Logger.Log(c.ToString());
                }
                // Unauthorized? Expired token.
                if ((c == null) || (c.Code == 401))
                {
                    APIUser.Logout();
                }
                signingIn = false;
                if (onAuthed != null)
                {
                    onAuthed(APIUser.IsLoggedInWithCredentials);
                }
            };

            APIUser.FetchCurrentUser(loginSuccessDelegate, loginFailureDelegate);
        }
Beispiel #4
0
 private static bool VerifyCredentials()
 {
     if (!RemoteConfig.IsInitialized())
     {
         RemoteConfig.Init((Action)null, (Action)null);
     }
     if (!APIUser.get_IsLoggedInWithCredentials() && ApiCredentials.Load())
     {
         APIUser.FetchCurrentUser((Action <ApiModelContainer <APIUser> >) delegate(ApiModelContainer <APIUser> c)
         {
             AnalyticsSDK.LoggedInUserChanged(c.get_Model() as APIUser);
         }, (Action <ApiModelContainer <APIUser> >)null);
     }
     if (!APIUser.get_IsLoggedInWithCredentials())
     {
         GUILayout.Label("Please use the \"VRChat SDK/Settings\" window to log in.", EditorStyles.get_boldLabel(), (GUILayoutOption[])new GUILayoutOption[0]);
         return(false);
     }
     return(true);
 }
Beispiel #5
0
        void Login()
        {
            if (!ApiCredentials.Load())
            {
                LoginErrorCallback("Not logged in");
            }
            else
            {
                APIUser.FetchCurrentUser(
                    delegate(ApiModelContainer <APIUser> c)
                {
                    pipelineManager.user = c.Model as APIUser;

                    ApiAvatar av = new ApiAvatar()
                    {
                        id = pipelineManager.blueprintId
                    };
                    av.Get(false,
                           (c2) =>
                    {
                        VRC.Core.Logger.Log("<color=magenta>Updating an existing avatar.</color>", DebugLevel.API);
                        apiAvatar = c2.Model as ApiAvatar;
                        pipelineManager.completedSDKPipeline = !string.IsNullOrEmpty(apiAvatar.authorId);
                        SetupUI();
                    },
                           (c2) =>
                    {
                        VRC.Core.Logger.Log("<color=magenta>Creating a new avatar.</color>", DebugLevel.API);
                        apiAvatar    = new ApiAvatar();
                        apiAvatar.id = pipelineManager.blueprintId;
                        pipelineManager.completedSDKPipeline = !string.IsNullOrEmpty(apiAvatar.authorId);
                        SetupUI();
                    });
                }, (c) => {
                    LoginErrorCallback(c.Error);
                });
            }
        }
Beispiel #6
0
    public static void InitAccount()
    {
        if (isInitialized)
        {
            return;
        }

        if (!APIUser.IsLoggedIn && ApiCredentials.Load())
        {
            APIUser.FetchCurrentUser((c) => AnalyticsSDK.LoggedInUserChanged(c.Model as APIUser), null);
        }

        clientInstallPath = SDKClientUtilities.GetSavedVRCInstallPath();
        if (string.IsNullOrEmpty(clientInstallPath))
        {
            clientInstallPath = SDKClientUtilities.LoadRegistryVRCInstallPath();
        }

        signingIn     = false;
        isInitialized = true;

        ClearContent();
    }
    public override void OnInspectorGUI()
    {
        //IL_01b5: Unknown result type (might be due to invalid IL or missing references)
        //IL_01cb: Unknown result type (might be due to invalid IL or missing references)
        PipelineManager pipeline = (PipelineManager)this.get_target();

        EditorGUILayout.LabelField("Unity Version", Application.get_unityVersion(), (GUILayoutOption[])new GUILayoutOption[0]);
        if (!loggingIn)
        {
            bool flag = ApiCredentials.IsLoaded();
            if (!flag)
            {
                flag = ApiCredentials.Load();
            }
            if (!APIUser.IsLoggedInWithCredentials && flag)
            {
                API.SetOnlineMode(online: true);
                loggingIn = true;
                APIUser.FetchCurrentUser(delegate(ApiModelContainer <APIUser> c)
                {
                    loggingIn     = false;
                    pipeline.user = (c.Model as APIUser);
                }, delegate
                {
                    loggingIn = false;
                });
            }
            else if (APIUser.IsLoggedInWithCredentials && !flag)
            {
                pipeline.user = null;
            }
        }
        pipeline.launchedFromSDKPipeline = launchedFromSDKPipeline;
        string text = (!APIUser.IsLoggedInWithCredentials) ? "None" : pipeline.blueprintId;

        if (string.IsNullOrEmpty(text))
        {
            tmpBlueprintId = EditorGUILayout.TextField("Blueprint ID (Optional)", tmpBlueprintId, (GUILayoutOption[])new GUILayoutOption[0]);
        }
        else
        {
            EditorGUILayout.PrefixLabel("Blueprint ID");
            EditorGUILayout.SelectableLabel(text, (GUILayoutOption[])new GUILayoutOption[0]);
        }
        string text2 = (!string.IsNullOrEmpty(text)) ? "Detach (Optional)" : "Attach (Optional)";

        if (APIUser.IsLoggedInWithCredentials && GUILayout.Button(text2, (GUILayoutOption[])new GUILayoutOption[0]))
        {
            if (string.IsNullOrEmpty(text))
            {
                text = (pipeline.blueprintId = tmpBlueprintId);
                pipeline.completedSDKPipeline = true;
            }
            else
            {
                pipeline.blueprintId          = string.Empty;
                pipeline.completedSDKPipeline = false;
            }
            EditorUtility.SetDirty(pipeline);
            EditorSceneManager.MarkSceneDirty(pipeline.get_gameObject().get_scene());
            EditorSceneManager.SaveScene(pipeline.get_gameObject().get_scene());
        }
        if (!APIUser.IsLoggedInWithCredentials)
        {
            GUILayout.Label("Use the settings menu to log in.", EditorStyles.get_boldLabel(), (GUILayoutOption[])new GUILayoutOption[0]);
        }
    }