using System; using UnityEngine; using UnityEngine.UIElements; namespace UnityEditor.Purchasing { internal class GooglePlayConfigurationSettingsBlock : IPurchasingSettingsUIBlock { const string k_UpdateGooglePlayKeyBtn = "UpdateGooglePlayKeyBtn"; const string k_GooglePlayLink = "GooglePlayLink"; const string k_GooglePlayKeyEntry = "GooglePlayKeyEntry"; const string k_VerifiedMode = "verified-mode"; const string k_UnverifiedMode = "unverified-mode"; const string k_ErrorKeyFormat = "error-key-format"; const string k_ErrorUnauthorized = "error-unauthorized-user"; const string k_ErrorServer = "error-server-error"; const string k_ErrorFetchKey = "error-fetch-key"; const string k_GooglePlayKeyBtnUpdateLabel = "Update"; const string k_GooglePlayKeyBtnVerifyLabel = "Verify"; readonly GoogleConfigurationData m_GooglePlayDataRef; readonly GoogleConfigurationWebRequests m_WebRequests; VisualElement m_ConfigurationBlock; readonly GoogleObfuscatorSection m_ObfuscatorSection; internal GooglePlayConfigurationSettingsBlock() { m_GooglePlayDataRef = GoogleConfigService.Instance().GoogleConfigData; m_WebRequests = new GoogleConfigurationWebRequests(m_GooglePlayDataRef, OnGetGooglePlayKey, OnUpdateGooglePlayKey); m_ObfuscatorSection = new GoogleObfuscatorSection(m_GooglePlayDataRef); } public VisualElement GetUIBlockElement() { return SetupConfigurationBlock(); } VisualElement SetupConfigurationBlock() { m_ConfigurationBlock = SettingsUIUtils.CloneUIFromTemplate(UIResourceUtils.googlePlayConfigUxmlPath); SetupStyleSheets(); PopulateConfigBlock(); m_ObfuscatorSection.SetupObfuscatorBlock(m_ConfigurationBlock); return m_ConfigurationBlock; } void SetupStyleSheets() { m_ConfigurationBlock.AddStyleSheetPath(UIResourceUtils.purchasingCommonUssPath); m_ConfigurationBlock.AddStyleSheetPath(EditorGUIUtility.isProSkin ? UIResourceUtils.purchasingDarkUssPath : UIResourceUtils.purchasingLightUssPath); } void PopulateConfigBlock() { ObtainExistingGooglePlayKey(); ToggleGoogleKeyStateDisplay(); SetupButtonActions(); } void ObtainExistingGooglePlayKey() { if (m_GooglePlayDataRef.revenueTrackingState != GooglePlayRevenueTrackingKeyState.Verified) { m_WebRequests.RequestRetrieveKeyOperation(); } else { SetGooglePlayKeyText(m_GooglePlayDataRef.googlePlayKey); ToggleGoogleKeyStateDisplay(); } } void SetupButtonActions() { m_ConfigurationBlock.Q