/// <summary> /// Using this method to simulate a callback after binding a project for creation and making sure the /// project info are fully loaded in UnityConnect.instance.projectInfo /// </summary> /// <param name="projectInfo"></param> private void OnProjectStateChangedAfterCreation(ProjectInfo projectInfo) { if (UnityConnect.instance.projectInfo.valid) { UnityConnect.instance.ProjectStateChanged -= OnProjectStateChangedAfterCreation; ServicesRepository.EnableServicesOnProjectCreation(); } }
/// <summary> /// Using this method to simulate a callback after binding a project for rebinding an existing project /// and making sure the project info are fully loaded in UnityConnect.instance.projectInfo /// </summary> /// <param name="projectInfo"></param> private void OnProjectStateChangedAfterRebind(ProjectInfo projectInfo) { if (UnityConnect.instance.projectInfo.valid) { UnityConnect.instance.ProjectStateChanged -= OnProjectStateChangedAfterRebind; ServicesRepository.SyncServicesOnProjectRebind(); } }
BuildService() { name = "Build"; title = L10n.Tr("Cloud Build"); description = L10n.Tr("Build games faster"); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-Build.png"; projectSettingsPath = "Project/Services/Cloud Build"; displayToggle = true; packageId = null; ServicesRepository.AddService(this); }
AdsService() { name = "Unity Ads"; title = L10n.Tr("Ads"); description = L10n.Tr("Monetize your games"); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-Ads.png"; projectSettingsPath = "Project/Services/Ads"; displayToggle = true; packageId = "com.unity.ads"; ServicesRepository.AddService(this); }
CrashService() { name = "Game Performance"; title = L10n.Tr("Cloud Diagnostics"); description = L10n.Tr("Discover app errors and collect user feedback"); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-Crash.png"; displayToggle = false; packageName = null; serviceFlagName = "gameperf"; ServicesRepository.AddService(this); }
CollabService() { name = "Collab"; title = L10n.Tr("Collaborate"); description = L10n.Tr("Create together seamlessly"); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-Collab.png"; projectSettingsPath = "Project/Services/Collaborate"; displayToggle = true; packageId = "com.unity.collab-proxy"; ServicesRepository.AddService(this); }
UDPService() { name = "UDP"; title = L10n.Tr("Unity Distribution Portal"); description = L10n.Tr("Distribute to multiple app stores through a single hub."); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-UDP.png"; projectSettingsPath = "Project/Services/Unity Distribution Portal"; displayToggle = false; isPackage = true; packageId = "com.unity.purchasing.udp"; ServicesRepository.AddService(this); }
AnalyticsService() { const string serviceName = "Legacy Analytics"; name = serviceName; title = L10n.Tr(serviceName); description = L10n.Tr("Discover player insights"); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-Analytics.png"; displayToggle = true; packageName = "com.unity.analytics"; serviceFlagName = "analytics"; ServicesRepository.AddService(this); }
AnalyticsService() { string serviceName = L10n.Tr("Analytics"); name = serviceName; title = serviceName; description = L10n.Tr("Discover player insights"); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-Analytics.png"; projectSettingsPath = "Project/Services/Analytics"; displayToggle = true; packageId = "com.unity.analytics"; ServicesRepository.AddService(this); }
PurchasingService() { k_PackageUri = new Uri(PurchasingConfiguration.instance.purchasingPackageUrl); name = "Purchasing"; title = L10n.Tr("In-App Purchasing"); description = L10n.Tr("Simplify cross-platform IAP"); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-Purchasing.png"; projectSettingsPath = "Project/Services/In-App Purchasing"; displayToggle = true; packageId = "com.unity.purchasing"; ServicesRepository.AddService(this); }
AdsService() { name = "Unity Ads"; title = L10n.Tr("Ads"); description = L10n.Tr("Monetize your games"); pathTowardIcon = @"Builtin Skins\Shared\Images\ServicesWindow-ServiceIcon-Ads.png"; displayToggle = true; packageName = "com.unity.ads"; serviceFlagName = "ads"; ServicesRepository.AddService(this); InitializeService(); }
void UnbindProject() { if (EditorUtility.DisplayDialog(L10n.Tr(k_UnlinkProjectDialogTitle), L10n.Tr(k_UnlinkProjectDialogMessage), L10n.Tr(k_Yes), L10n.Tr(k_No))) { ServicesRepository.DisableAllServices(shouldUpdateApiFlag: false); string cachedProjectName = UnityConnect.instance.projectInfo.projectName; UnityConnect.instance.UnbindProject(); EditorAnalytics.SendProjectServiceBindingEvent(new ProjectBindManager.ProjectBindState() { bound = false, projectName = cachedProjectName }); NotificationManager.instance.Publish(Notification.Topic.ProjectBind, Notification.Severity.Info, L10n.Tr(k_ProjectUnlinkSuccessMessage)); ReinitializeSettings(); } }
void LoadWindow() { rootVisualElement.Clear(); var mainTemplate = EditorGUIUtility.Load(k_ServicesWindowUxmlPath) as VisualTreeAsset; var serviceTemplate = EditorGUIUtility.Load(k_ServiceTemplateUxmlPath) as VisualTreeAsset; rootVisualElement.AddStyleSheetPath(ServicesUtils.StylesheetPath.servicesWindowCommon); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? ServicesUtils.StylesheetPath.servicesWindowDark : ServicesUtils.StylesheetPath.servicesWindowLight); mainTemplate.CloneTree(rootVisualElement, new Dictionary <string, VisualElement>(), null); notificationSubscriber = new UIElementsNotificationSubscriber(rootVisualElement); notificationSubscriber.Subscribe( Notification.Topic.AdsService, Notification.Topic.AnalyticsService, Notification.Topic.BuildService, Notification.Topic.CollabService, Notification.Topic.CoppaCompliance, Notification.Topic.CrashService, Notification.Topic.ProjectBind, Notification.Topic.PurchasingService ); var scrollContainer = rootVisualElement.Q(className: k_ScrollContainerClassName); var settingsClickable = new Clickable(() => { SettingsService.OpenProjectSettings(GeneralProjectSettings.generalProjectSettingsPath); }); rootVisualElement.Q(k_ProjectSettingsLinkName).AddManipulator(settingsClickable); var dashboardClickable = new Clickable(() => { if (UnityConnect.instance.projectInfo.projectBound) { Application.OpenURL( string.Format(ServicesConfiguration.instance.GetCurrentProjectDashboardUrl(), UnityConnect.instance.projectInfo.organizationId, UnityConnect.instance.projectInfo.projectGUID)); } else { NotificationManager.instance.Publish(Notification.Topic.ProjectBind, Notification.Severity.Warning, L10n.Tr(k_ProjectNotBoundMessage)); SettingsService.OpenProjectSettings(GeneralProjectSettings.generalProjectSettingsPath); } }); rootVisualElement.Q(k_DashboardLinkName).AddManipulator(dashboardClickable); var sortedServices = new SortedList <string, SingleService>(); foreach (var service in ServicesRepository.GetServices()) { sortedServices.Add(service.title, service); } var footer = scrollContainer.Q(k_FooterName); scrollContainer.Remove(footer); foreach (var singleCloudService in sortedServices.Values) { SetupService(scrollContainer, serviceTemplate, singleCloudService); } scrollContainer.Add(footer); var privacyClickable = new Clickable(() => { Application.OpenURL(k_PrivacyPolicyUrl); }); scrollContainer.Q(k_PrivacyPolicyLinkName).AddManipulator(privacyClickable); }
void CreateOperationOnCompleted(AsyncOperation obj) { if (m_CurrentRequest == null) { //If we lost our m_CurrentRequest request reference, we can't risk doing anything. return; } if (m_CurrentRequest.result != UnityWebRequest.Result.ProtocolError) { var jsonParser = new JSONParser(m_CurrentRequest.downloadHandler.text); var json = jsonParser.Parse(); var abort = false; try { var projectInfo = ExtractProjectInfoFromJson(json); try { ServicesRepository.DisableAllServices(); BindProject(projectInfo); } catch (Exception ex) { if (exceptionCallback != null) { exceptionCallback.Invoke(ex); abort = true; } else { //If there is no exception callback, we have to at least log it Debug.LogException(ex); } } if (!abort) { createButtonCallback?.Invoke(projectInfo); } } finally { m_CurrentRequest?.Dispose(); m_CurrentRequest = null; } } else if (m_CurrentRequest.responseCode == k_HttpStatusCodeUnprocessableEntity) { m_CurrentRequest?.Dispose(); m_CurrentRequest = null; m_CreateIteration++; RequestCreateOperation(); } else { try { var ex = new UnityConnectWebRequestException(L10n.Tr(k_CouldNotCreateProjectMessage)) { error = m_CurrentRequest.error, method = m_CurrentRequest.method, timeout = m_CurrentRequest.timeout, url = m_CurrentRequest.url, responseHeaders = m_CurrentRequest.GetResponseHeaders(), responseCode = m_CurrentRequest.responseCode, isHttpError = (m_CurrentRequest.result == UnityWebRequest.Result.ProtocolError), isNetworkError = (m_CurrentRequest.result == UnityWebRequest.Result.ConnectionError), }; if (exceptionCallback != null) { exceptionCallback.Invoke(ex); } else { //If there is no exception callback, we have to at least log it Debug.LogException(ex); } } finally { m_CurrentRequest?.Dispose(); m_CurrentRequest = null; } } }
internal void EnableService(bool enable) { //Last minute check for services dependencies ServicesRepository.InitializeServicesHandlers(); HandleProjectLink(enable); }
static ServicesRepository() { k_Instance = new ServicesRepository(); }
void LoadWindow() { rootVisualElement.Clear(); var mainTemplate = EditorGUIUtility.Load(k_ServicesWindowUxmlPath) as VisualTreeAsset; rootVisualElement.AddStyleSheetPath(ServicesUtils.StylesheetPath.servicesWindowCommon); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? ServicesUtils.StylesheetPath.servicesWindowDark : ServicesUtils.StylesheetPath.servicesWindowLight); mainTemplate.CloneTree(rootVisualElement, new Dictionary <string, VisualElement>(), null); notificationSubscriber = new UIElementsNotificationSubscriber(rootVisualElement); notificationSubscriber.Subscribe( Notification.Topic.AdsService, Notification.Topic.AnalyticsService, Notification.Topic.BuildService, Notification.Topic.CollabService, Notification.Topic.CoppaCompliance, Notification.Topic.CrashService, Notification.Topic.ProjectBind, Notification.Topic.PurchasingService ); rootVisualElement.Q <Button>(k_ProjectSettingsBtnName).clicked += () => { SettingsService.OpenProjectSettings(GeneralProjectSettings.generalProjectSettingsPath); }; var dashboardClickable = new Clickable(() => { if (UnityConnect.instance.projectInfo.projectBound) { EditorAnalytics.SendOpenDashboardForService(new ServicesProjectSettings.OpenDashboardForService() { serviceName = k_WindowTitle, url = ServicesConfiguration.instance.baseDashboardUrl, organizationId = UnityConnect.instance.projectInfo.organizationId, projectId = UnityConnect.instance.projectInfo.projectId }); Application.OpenURL(ServicesConfiguration.instance.GetCurrentProjectDashboardUrl()); } else { NotificationManager.instance.Publish(Notification.Topic.ProjectBind, Notification.Severity.Warning, L10n.Tr(k_ProjectNotBoundMessage)); SettingsService.OpenProjectSettings(GeneralProjectSettings.generalProjectSettingsPath); } }); rootVisualElement.Q(k_DashboardLinkName).AddManipulator(dashboardClickable); m_SortedServices = new SortedList <string, SingleService>(); bool needProjectListOfPackage = false; foreach (var service in ServicesRepository.GetServices()) { m_SortedServices.Add(service.title, service); if (service.isPackage && service.packageId != null) { needProjectListOfPackage = true; } } // Only launch the listing if a service really needs the packages list... m_PackageCollection = null; if (needProjectListOfPackage) { m_ListRequestOfPackage = Client.List(); EditorApplication.update += ListingCurrentPackageProgress; } else { FinalizeServiceSetup(); } }
void CreateOperationOnCompleted(AsyncOperation obj) { if (m_CurrentRequest == null) { //If we lost our m_CurrentRequest request reference, we can't risk doing anything. return; } if (ServicesUtils.IsUnityWebRequestReadyForJsonExtract(m_CurrentRequest)) { var jsonParser = new JSONParser(m_CurrentRequest.downloadHandler.text); var json = jsonParser.Parse(); var abort = false; try { var projectInfo = ExtractProjectInfoFromJson(json); try { ServicesRepository.DisableAllServices(shouldUpdateApiFlag: false); //Only register before creation. Remove first in case it was already added. //TODO: Review to avoid dependency on project refreshed UnityConnect.instance.ProjectStateChanged -= OnProjectStateChangedAfterCreation; UnityConnect.instance.ProjectStateChanged += OnProjectStateChangedAfterCreation; BindProject(projectInfo); } catch (Exception ex) { if (exceptionCallback != null) { exceptionCallback.Invoke(ex); abort = true; } else { //If there is no exception callback, we have to at least log it Debug.LogException(ex); } } if (!abort) { createButtonCallback?.Invoke(projectInfo); } } finally { m_CurrentRequest?.Dispose(); m_CurrentRequest = null; } } else if (m_CurrentRequest.responseCode == k_HttpStatusCodeUnprocessableEntity) { m_CurrentRequest?.Dispose(); m_CurrentRequest = null; m_CreateIteration++; RequestCreateOperation(); } else { try { var ex = new UnityConnectWebRequestException(L10n.Tr(k_CouldNotCreateProjectMessage)) { error = m_CurrentRequest.error, method = m_CurrentRequest.method, timeout = m_CurrentRequest.timeout, url = m_CurrentRequest.url, responseHeaders = m_CurrentRequest.GetResponseHeaders(), responseCode = m_CurrentRequest.responseCode, isHttpError = (m_CurrentRequest.result == UnityWebRequest.Result.ProtocolError), isNetworkError = (m_CurrentRequest.result == UnityWebRequest.Result.ConnectionError), }; if (exceptionCallback != null) { exceptionCallback.Invoke(ex); } else { //If there is no exception callback, we have to at least log it Debug.LogException(ex); } } finally { m_CurrentRequest?.Dispose(); m_CurrentRequest = null; } } }
internal void EnableService(bool enable, bool shouldUpdateApiFlag = true) { //Last minute check for services dependencies ServicesRepository.InitializeServicesHandlers(); HandleProjectLink(enable, shouldUpdateApiFlag); }