コード例 #1
0
        private void ConnectInterfaceLogin()
        {
            var loginOptions = new Epic.OnlineServices.Connect.LoginOptions();

            if (connectInterfaceCredentialType == Epic.OnlineServices.Connect.ExternalCredentialType.Epic)
            {
                Epic.OnlineServices.Auth.Token token;
                Result result = EOS.GetAuthInterface().CopyUserAuthToken(new Epic.OnlineServices.Auth.CopyUserAuthTokenOptions(), localUserAccountId, out token);

                if (result == Result.Success)
                {
                    connectInterfaceCredentialToken = token.AccessToken;
                }
                else
                {
                    Debug.LogError("Failed to retrieve User Auth Token");
                }
            }
            else if (connectInterfaceCredentialType == Epic.OnlineServices.Connect.ExternalCredentialType.DeviceidAccessToken)
            {
                loginOptions.UserLoginInfo             = new Epic.OnlineServices.Connect.UserLoginInfo();
                loginOptions.UserLoginInfo.DisplayName = displayName;
            }

            loginOptions.Credentials       = new Epic.OnlineServices.Connect.Credentials();
            loginOptions.Credentials.Type  = connectInterfaceCredentialType;
            loginOptions.Credentials.Token = connectInterfaceCredentialToken;

            EOS.GetConnectInterface().Login(loginOptions, null, OnConnectInterfaceLogin);
        }
コード例 #2
0
        protected void InitializeImplementation()
        {
            isConnecting = true;

            var initializeOptions = new InitializeOptions()
            {
                ProductName    = epicProductName,
                ProductVersion = epicProductVersion
            };

            var initializeResult = PlatformInterface.Initialize(initializeOptions);

            // This code is called each time the game is run in the editor, so we catch the case where the SDK has already been initialized in the editor.
            var isAlreadyConfiguredInEditor = Application.isEditor && initializeResult == Result.AlreadyConfigured;

            if (initializeResult != Result.Success && !isAlreadyConfiguredInEditor)
            {
                throw new System.Exception("Failed to initialize platform: " + initializeResult);
            }

            // The SDK outputs lots of information that is useful for debugging.
            // Make sure to set up the logging interface as early as possible: after initializing.
            LoggingInterface.SetLogLevel(LogCategory.AllCategories, epicLoggerLevel);
            LoggingInterface.SetCallback(message => Logger.EpicDebugLog(message));

            var options = new Options()
            {
                ProductId         = epicProductId,
                SandboxId         = epicSandboxId,
                DeploymentId      = epicDeploymentId,
                ClientCredentials = new ClientCredentials()
                {
                    ClientId     = epicClientId,
                    ClientSecret = epicClientSecret
                },
                TickBudgetInMilliseconds = tickBudgetInMilliseconds
            };

            EOS = PlatformInterface.Create(options);
            if (EOS == null)
            {
                throw new System.Exception("Failed to create platform");
            }

            if (checkForEpicLauncherAndRestart)
            {
                Result result = EOS.CheckForLauncherAndRestart();

                // If not started through epic launcher the app will be restarted and we can quit
                if (result != Result.NoChange)
                {
                    // Log error if launcher check failed, but still quit to prevent hacking
                    if (result == Result.UnexpectedError)
                    {
                        Debug.LogError("Unexpected Error while checking if app was started through epic launcher");
                    }

                    Application.Quit();
                }
            }

            // If we use the Auth interface then only login into the Connect interface after finishing the auth interface login
            // If we don't use the Auth interface we can directly login to the Connect interface
            if (authInterfaceLogin)
            {
                if (authInterfaceCredentialType == Epic.OnlineServices.Auth.LoginCredentialType.Developer)
                {
                    authInterfaceLoginCredentialId = "localhost:" + devAuthToolPort;
                    authInterfaceCredentialToken   = devAuthToolCredentialName;
                }

                // Login to Auth Interface
                Epic.OnlineServices.Auth.LoginOptions loginOptions = new Epic.OnlineServices.Auth.LoginOptions()
                {
                    Credentials = new Epic.OnlineServices.Auth.Credentials()
                    {
                        Type  = authInterfaceCredentialType,
                        Id    = authInterfaceLoginCredentialId,
                        Token = authInterfaceCredentialToken
                    },
                    ScopeFlags = Epic.OnlineServices.Auth.AuthScopeFlags.BasicProfile | Epic.OnlineServices.Auth.AuthScopeFlags.FriendsList | Epic.OnlineServices.Auth.AuthScopeFlags.Presence
                };

                EOS.GetAuthInterface().Login(loginOptions, null, OnAuthInterfaceLogin);
            }
            else
            {
                // Login to Connect Interface
                if (connectInterfaceCredentialType == Epic.OnlineServices.Connect.ExternalCredentialType.DeviceidAccessToken)
                {
                    Epic.OnlineServices.Connect.CreateDeviceIdOptions createDeviceIdOptions = new Epic.OnlineServices.Connect.CreateDeviceIdOptions();
                    createDeviceIdOptions.DeviceModel = deviceModel;
                    EOS.GetConnectInterface().CreateDeviceId(createDeviceIdOptions, null, OnCreateDeviceId);
                }
                else
                {
                    ConnectInterfaceLogin();
                }
            }
        }