예제 #1
0
 public void Set(CreateDeviceIdOptions other)
 {
     if (other != null)
     {
         m_ApiVersion = ConnectInterface.CreatedeviceidApiLatest;
         DeviceModel  = other.DeviceModel;
     }
 }
예제 #2
0
        /// <summary>
        ///     Initialize epic sdk.
        /// </summary>
        /// <returns>Returns back whether or not the engine initialized correctly.</returns>
        private void Initialize()
        {
            if (_enableDebugLogs)
            {
                DebugLogger.RegularDebugLog("[EpicManager] - Initializing epic services.");
            }

            InitializeOptions initializeOptions =
                new InitializeOptions {
                ProductName = _options.ProductName, ProductVersion = _options.ProductVersion
            };

            Result 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.
            bool isAlreadyConfiguredInEditor = Application.isEditor && initializeResult == Result.AlreadyConfigured;

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

            if (_enableDebugLogs)
            {
                LoggingInterface.SetLogLevel(LogCategory.AllCategories, _epicLoggingLevel);
                LoggingInterface.SetCallback(message => DebugLogger.EpicDebugLog(message));
            }

            ClientCredentials clientCredentials =
                new ClientCredentials {
                ClientId = _options.ClientId, ClientSecret = _options.ClientSecret
            };

            OnlineServices.Platform.Options options =
                new OnlineServices.Platform.Options
            {
                ProductId                = _options.ProductId,
                SandboxId                = _options.SandboxId,
                ClientCredentials        = clientCredentials,
                IsServer                 = false,
                DeploymentId             = _options.DeploymentId,
                TickBudgetInMilliseconds = (uint)_tickTime * 1000
            };

            Platform = PlatformInterface.Create(options);

            if (Platform != null)
            {
                if (_enableDebugLogs)
                {
                    DebugLogger.RegularDebugLog("[EpicManager] - Initialization of epic services complete.");
                }

                // Process epic services in a separate task.
                _ = UniTask.Run(Tick);

                // 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 == LoginCredentialType.Developer)
                    {
                        _authInterfaceLoginCredentialId = $"localhost:{_devAuthToolPort}";
                        _authInterfaceCredentialToken   = _devAuthToolName;
                    }

                    // Login to Auth Interface
                    LoginOptions loginOptions = new LoginOptions
                    {
                        Credentials = new OnlineServices.Auth.Credentials
                        {
                            Type  = _authInterfaceCredentialType,
                            Id    = _authInterfaceLoginCredentialId,
                            Token = _authInterfaceCredentialToken
                        },
                        ScopeFlags = AuthScopeFlags.BasicProfile | AuthScopeFlags.FriendsList | AuthScopeFlags.Presence
                    };

                    AuthInterface.Login(loginOptions, null, OnAuthInterfaceLogin);
                }
                else
                {
                    // Login to Connect Interface
                    if (_connectInterfaceCredentialType == ExternalCredentialType.DeviceidAccessToken)
                    {
                        CreateDeviceIdOptions createDeviceIdOptions =
                            new CreateDeviceIdOptions
                        {
                            DeviceModel = Application.platform.ToString()
                        };
                        ConnectInterface.CreateDeviceId(createDeviceIdOptions, null, OnCreateDeviceId);
                    }
                    else
                    {
                        ConnectInterfaceLogin();
                    }
                }

                OnInitialized?.Invoke();

                return;
            }

            DebugLogger.RegularDebugLog(
                $"[EpicManager] - Failed to create platform. Ensure the relevant {typeof(Options)} are set or passed into the application as arguments.");
        }