Esempio n. 1
0
 /// <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();
     }
 }
Esempio n. 2
0
 /// <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);
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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();
        }
Esempio n. 12
0
        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();
            }
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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;
                }
            }
        }
Esempio n. 15
0
 internal void EnableService(bool enable)
 {
     //Last minute check for services dependencies
     ServicesRepository.InitializeServicesHandlers();
     HandleProjectLink(enable);
 }
Esempio n. 16
0
 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();
            }
        }
Esempio n. 18
0
        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;
                }
            }
        }
Esempio n. 19
0
 internal void EnableService(bool enable, bool shouldUpdateApiFlag = true)
 {
     //Last minute check for services dependencies
     ServicesRepository.InitializeServicesHandlers();
     HandleProjectLink(enable, shouldUpdateApiFlag);
 }