// When you release and shutdown the SDK library, you cannot initialize it again. // Make sure this is done at a relevant time in your game's lifecycle. // If you are working in editor, it is advised you do not release and shutdown the SDK // as you would be required to restart Unity to initialize the SDK again. private void OnDestroy() { if (EOS == null) { return; } if (Application.isEditor) { if (autoLogoutInEditor) { Epic.OnlineServices.Auth.LogoutOptions logoutOptions = new Epic.OnlineServices.Auth.LogoutOptions(); logoutOptions.LocalUserId = LocalUserAccountId; // Callback might not be called since we call Logout in OnDestroy() EOS.GetAuthInterface().Logout(logoutOptions, null, OnAuthInterfaceLogout); } } else { EOS.Release(); EOS = null; PlatformInterface.Shutdown(); } }
// When you release and shutdown the SDK library, you cannot initialize it again. // Make sure this is done at a relevant time in your game's lifecycle. // If you are working in editor, it is advised you do not release and shutdown the SDK // as you would be required to restart Unity to initialize the SDK again. private void OnDestroy() { if (!Application.isEditor && EOS != null) { EOS.Release(); EOS = null; PlatformInterface.Shutdown(); } }
protected IEnumerator DoLightningStrike() { AkSoundEngine.PostEvent("Play_ENV_thunder_flash_01", GameManager.Instance.PrimaryPlayer.gameObject); PlatformInterface.SetAlienFXColor(new Color(1f, 1f, 1f, 1f), 0.25f); yield return(new WaitForSeconds(0.25f)); GameManager.Instance.MainCameraController.DoScreenShake(ThunderShake, null, false); yield break; }
/// <summary> /// On Quit /// </summary> void OnApplicationQuit() { // * Does not work properly in Unity Editor. #if !UNITY_EDITOR m_platformInterface?.Release(); m_platformInterface = null; PlatformInterface.Shutdown(); #endif }
public static void Init(ProductUserId user, PlatformInterface platform, string displayName) { platformInterface = platform; LocalUserProductId = user; user.ToString(out var buffer); LocalUserProductIdString = buffer; P2PInterface = platformInterface.GetP2PInterface(); MetricsInterface = platformInterface.GetMetricsInterface(); DisplayName = displayName; ChangeRelayStatus(); }
/// <summary> /// First frame /// </summary> void Start() { _ins = this; var initializeOptions = new InitializeOptions(); initializeOptions.ProductName = productName; initializeOptions.ProductVersion = productVersion; var result = PlatformInterface.Initialize(initializeOptions); // * Unity Editor becomes AlreadyConfigured after the second time. if (result == Result.Success #if UNITY_EDITOR || result == Result.AlreadyConfigured #endif ) { var clientCredentials = new ClientCredentials(); clientCredentials.ClientId = clientId; clientCredentials.ClientSecret = clientSecret; var options = new Options(); options.ClientCredentials = clientCredentials; options.ProductId = productId; options.SandboxId = sandboxId; options.DeploymentId = deploymentId; m_platformInterface = PlatformInterface.Create(options); if (m_platformInterface == null) { throw new Exception("Failed to create platform"); } } else { throw new Exception("Failed to initialize platform:" + result); } Debug.Log($"Login:{result}"); }
public IEnumerator Vanish(PlayerController p) { AkSoundEngine.PostEvent("Play_ENM_darken_world_01", base.gameObject); while (this.baseSprite.renderer.material.GetFloat("_Opacity") > 0) { this.baseSprite.renderer.material.SetFloat("_Opacity", this.baseSprite.renderer.material.GetFloat("_Opacity") - BraveTime.DeltaTime / 2); for (int i = 0; i < this.layers.Length; i++) { this.layers[i].sprite.renderer.material.SetFloat("_Opacity", this.baseSprite.renderer.material.GetFloat("_Opacity")); } this.poopil.GetComponent <tk2dBaseSprite>().renderer.material.SetFloat("_Opacity", this.baseSprite.renderer.material.GetFloat("_Opacity")); yield return(null); } Destroy(base.gameObject); PlatformInterface.SetAlienFXColor(new Color(1f, 0f, 0f, 1f), 1f); p.DoVibration(Vibration.Time.Quick, Vibration.Strength.Medium); Pixelator.Instance.HandleDamagedVignette(Vector2.zero); ScreenShakeSettings shakesettings = new ScreenShakeSettings(0.25f, 7f, 0.1f, 0.3f); GameManager.Instance.MainCameraController.DoScreenShake(shakesettings, new Vector2?(p.specRigidbody.UnitCenter), false); AkSoundEngine.PostEvent("Play_WPN_kthulu_blast_01", p.gameObject); yield break; }
/// <summary> /// Shutdown epic services. /// </summary> public void OnDestroy() { if (_enableDebugLogs) { DebugLogger.RegularDebugLog("[EpicManager] - Releasing epic resources and shutting down epic services."); } if (Application.isEditor) { LogoutOptions logoutOptions = new LogoutOptions { LocalUserId = AccountId.EpicAccountId }; // Callback might not be called since we call Logout in OnDestroy() AuthInterface.Logout(logoutOptions, null, OnAuthInterfaceLogout); } else { Platform.Release(); Platform = null; PlatformInterface.Shutdown(); } }
/// <summary> /// 開始 /// </summary> void Start() { _ins = this; var initializeOptions = new InitializeOptions(); initializeOptions.ProductName = settings.ProductName; initializeOptions.ProductVersion = settings.ProductVersion; var result = PlatformInterface.Initialize(initializeOptions); // ※ Unity Editor は AlreadyConfigured を飛ばさないとアプリが動かない。 if (result == Result.Success || result == Result.AlreadyConfigured) { var clientCredentials = new ClientCredentials(); clientCredentials.ClientId = settings.ClientId; clientCredentials.ClientSecret = settings.ClientSecret; var options = new Options(); options.ClientCredentials = clientCredentials; options.ProductId = settings.ProductId; options.SandboxId = settings.SandboxId; options.DeploymentId = settings.DeploymentId; m_platformInterface = PlatformInterface.Create(options); if (m_platformInterface == null) { throw new Exception("Failed to create platform"); } } else { throw new Exception("Failed to initialize platform:" + result); } Debug.Log($"Init:{result}"); }
private void OnApplicationQuit() { if (EOS != null) { EOS.Release(); EOS = null; PlatformInterface.Shutdown(); } // Unhook the library in the editor, this makes it possible to load the library again after stopping to play #if UNITY_EDITOR if (libraryPointer != IntPtr.Zero) { Bindings.Unhook(); // Free until the module ref count is 0 while (FreeLibrary(libraryPointer) != 0) { } libraryPointer = IntPtr.Zero; } #endif }
void Awake() { 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, LogLevel.VeryVerbose); LoggingInterface.SetCallback((LogMessage logMessage) => { Debug.Log(logMessage.Message); }); var options = new Options() { ProductId = epicProductId, SandboxId = epicSandboxId, DeploymentId = epicDeploymentId, ClientCredentials = new ClientCredentials() { ClientId = epicClientId, ClientSecret = epicClientSecret } }; EOS = PlatformInterface.Create(options); if (EOS == null) { throw new System.Exception("Failed to create platform"); } //Login to the Connect Interface Epic.OnlineServices.Connect.CreateDeviceIdOptions createDeviceIdOptions = new Epic.OnlineServices.Connect.CreateDeviceIdOptions(); createDeviceIdOptions.DeviceModel = "PC Windows 64bit"; EOS.GetConnectInterface().CreateDeviceId(createDeviceIdOptions, null, (Epic.OnlineServices.Connect.CreateDeviceIdCallbackInfo createDeviceIdCallbackInfo) => { if (createDeviceIdCallbackInfo.ResultCode == Result.Success || createDeviceIdCallbackInfo.ResultCode == Result.DuplicateNotAllowed) { var loginOptions = new Epic.OnlineServices.Connect.LoginOptions(); loginOptions.UserLoginInfo = new Epic.OnlineServices.Connect.UserLoginInfo(); loginOptions.UserLoginInfo.DisplayName = "Justin"; loginOptions.Credentials = new Epic.OnlineServices.Connect.Credentials(); loginOptions.Credentials.Type = Epic.OnlineServices.Connect.ExternalCredentialType.DeviceidAccessToken; loginOptions.Credentials.Token = null; EOS.GetConnectInterface().Login(loginOptions, null, (Epic.OnlineServices.Connect.LoginCallbackInfo loginCallbackInfo) => { if (loginCallbackInfo.ResultCode == Result.Success) { Debug.Log("Login succeeded"); string productIdString; Result result = loginCallbackInfo.LocalUserId.ToString(out productIdString); if (Result.Success == result) { Debug.Log("EOS User Product ID:" + productIdString); localUserProductIdString = productIdString; localUserProductId = loginCallbackInfo.LocalUserId; } Initialized = true; IsConnecting = false; } else { Debug.Log("Login returned " + loginCallbackInfo.ResultCode); } }); } else { Debug.Log("Device ID creation returned " + createDeviceIdCallbackInfo.ResultCode); } }); }
/// <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."); }
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(); } } }