private static void InitLicenseManager() { try { _IsDeveloperMode = false; _licenseManager = (LicenseManager)LicenseManager.GetInstance(); //path for registered license. var licenseFilePath = Path.Combine(Application.dataPath, "Plugins", "LicenseSpring", "License", $"{Application.productName}.bin"); //init extended options of License spring configs. LicenseSpringExtendedOptions licenseSpringExtendedOptions = new LicenseSpringExtendedOptions { HardwareID = SystemInfo.deviceUniqueIdentifier, EnableLogging = false, CollectHostNameAndLocalIP = true, LicenseFilePath = licenseFilePath }; if (Helpers.LicenseApiConfigurationHelper.IsExistDeveloperConfig()) { _licenseSpringLocalKey = Helpers.LicenseApiConfigurationHelper.ReadApiFileKey(Application.productName, true); } else if (Helpers.LicenseApiConfigurationHelper.IsExistDeployedConfig()) { _licenseSpringLocalKey = Helpers.LicenseApiConfigurationHelper.ReadApiFileKey(Application.productName, false); } else { throw new UnityEngine.UnityException("No Api Configuration detected, Contact your asset Developer"); } //HACK : if there is no baked credential read at files. if (_licenseSpringLocalKey != null) { _IsDeveloperMode = _licenseSpringLocalKey.IsDevelopment; var licenseConfig = new LicenseSpringConfiguration( _licenseSpringLocalKey.ApiKey, _licenseSpringLocalKey.SharedKey, _licenseSpringLocalKey.ProductCode, _licenseSpringLocalKey.ApplicationName, _licenseSpringLocalKey.ApplicationVersion, licenseSpringExtendedOptions); _licenseManager.Initialize(licenseConfig); } else { throw new UnityEngine.UnityException("No Api Configuration detected, Contact your asset Developer"); } } catch (Exception ex) { Debug.LogError(ex); } }
void Awake() { _licensePath = Path.Combine(Application.persistentDataPath, Application.productName, "lock.lic"); _apiPath = Path.Combine(Application.persistentDataPath, Application.productName, "app.lic"); _enumActiveStatus = ActivationStatus.Unknown; if (!File.Exists(_apiPath)) { _enumActiveStatus = ActivationStatus.Unknown; throw new LicenseConfigurationException("Configuration invalid"); } else { try { //extended configuration options. _lseo = new LicenseSpringExtendedOptions { HardwareID = this.HardwareId, LicenseFilePath = _licensePath, CollectHostNameAndLocalIP = true }; //local config decryptor _localKey = KeyStorage.ReadLocalKey(); //main configurations LicenseSpringConfiguration lsConfig = new LicenseSpringConfiguration(_localKey.ApiKey, _localKey.SharedKey, _localKey.ProductCode, _localKey.ApplicationName, _localKey.ApplicationVersion, _lseo); _internalLicenseManager = (LicenseManager)LicenseManager.GetInstance(); _internalLicenseManager.Initialize(_lsConfig); _installedLicense = (License)_internalLicenseManager.CurrentLicense(); SetLicenseStatus(); } catch (Exception ex) { Debug.LogError(ex.Message); } } DontDestroyOnLoad(this); }