public override void EnterState()
            {
                var generalTemplate = EditorGUIUtility.Load(k_AdsDisabledUxmlPath) as VisualTreeAsset;
                var scrollContainer = provider.rootVisualElement.Q(null, k_ServiceScrollContainerClassName);

                scrollContainer.Clear();
                if (generalTemplate != null)
                {
                    var newVisual = generalTemplate.CloneTree().contentContainer;
                    ServicesUtils.TranslateStringsInTree(newVisual);
                    scrollContainer.Add(newVisual);

                    var gettingStarted = scrollContainer.Q(k_GettingStartedLink);
                    if (gettingStarted != null)
                    {
                        var clickable = new Clickable(() =>
                        {
                            Application.OpenURL(ServicesConfiguration.instance.adsGettingStartedUrl);
                        });
                        gettingStarted.AddManipulator(clickable);
                    }
                    provider.UpdateServiceToggleAndDashboardLink(provider.serviceInstance.IsServiceEnabled());
                }
                scrollContainer.Add(ServicesUtils.SetupSupportedPlatformsBlock(ServicesUtils.GetAdsSupportedPlatforms()));
                provider.HandlePermissionRestrictedControls();
            }
        public UIElementsNotificationSubscriber(VisualElement rootVisualElement)
        {
            if (rootVisualElement == null)
            {
                throw new ArgumentException(L10n.Tr(k_NullVisualElementExceptionMessage));
            }

            // This notification subscriber needs a specific container to work.
            // A specific service can create a container with the right class : notification-container
            var notificationContainer = rootVisualElement.Q(null, k_NotificationContainerClassName);

            if (notificationContainer == null)
            {
                // Since the container does not exist, it is created and inserted as the first element...
                notificationContainer = new VisualElement();
                notificationContainer.AddToClassList(k_NotificationContainerClassName);
                rootVisualElement.Insert(0, notificationContainer);
            }
            notificationContainer.Clear();
            var notificationTemplate = EditorGUIUtility.Load(k_NotificationTemplateUxmlPath) as VisualTreeAsset;

            m_NotificationRoot = notificationTemplate.CloneTree().contentContainer;
            ServicesUtils.TranslateStringsInTree(m_NotificationRoot);
            notificationContainer.Add(m_NotificationRoot);

            rootVisualElement.AddStyleSheetPath(k_NotificationTemplateCommonUssPath);
            rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin
                ? k_NotificationTemplateDarkUssPath : k_NotificationTemplateLightUssPath);

            InitializeNotification();
            InitializePager();
        }
            public override void EnterState()
            {
                CloudBuildPoller.instance.Disable(true);
                var generalTemplate = EditorGUIUtility.Load(k_CloudBuildDisabledUxmlPath) as VisualTreeAsset;
                var scrollContainer = m_Provider.rootVisualElement.Q(className: k_ServiceScrollContainerClassName);

                scrollContainer.Clear();
                if (generalTemplate != null)
                {
                    var disabledStateContent = generalTemplate.CloneTree().contentContainer;
                    ServicesUtils.TranslateStringsInTree(disabledStateContent);
                    scrollContainer.Add(disabledStateContent);
                }

                var startUsing = m_Provider.rootVisualElement.Q(k_StartUsingCloudBuildLink);

                if (startUsing != null)
                {
                    var clickable = new Clickable(() =>
                    {
                        Application.OpenURL(ServicesConfiguration.instance.GetCloudBuildTutorialUrl());
                    });
                    startUsing.AddManipulator(clickable);
                }

                m_Provider.HandlePermissionRestrictedControls();
            }
Ejemplo n.º 4
0
        void SetupCrashDiag()
        {
            var crashDiagContainer = rootVisualElement.Q(className: k_CloudDiagCrashContainerClassName);

            if (crashDiagContainer == null)
            {
                return;
            }

            var generalTemplate = EditorGUIUtility.Load(k_CloudDiagCrashCommonUxmlPath) as VisualTreeAsset;

            if (generalTemplate != null)
            {
                var newVisual = generalTemplate.CloneTree().contentContainer;
                ServicesUtils.TranslateStringsInTree(newVisual);
                crashDiagContainer.Clear();
                crashDiagContainer.Add(newVisual);
                crashDiagContainer.Add(ServicesUtils.SetupSupportedPlatformsBlock(ServicesUtils.GetCloudDiagCrashSupportedPlatforms()));

                m_CrashServiceGoToDashboard = rootVisualElement.Q(k_CloudDiagCrashGoToDashboardName);
                if (m_CrashServiceGoToDashboard != null)
                {
                    var clickable = new Clickable(() =>
                    {
                        ServicesConfiguration.instance.RequestBaseCloudDiagCrashesDashboardUrl(OpenDashboardOrgAndProjectIds);
                    });
                    m_CrashServiceGoToDashboard.AddManipulator(clickable);
                }

                m_CrashServiceToggle = rootVisualElement.Q <Toggle>(className: k_ServiceToggleClassName);
                SetupServiceToggle();
                RegisterEvent();
            }
        }
Ejemplo n.º 5
0
            public override void EnterState()
            {
                // If we haven't received new bound info, fetch them
                var generalTemplate     = EditorGUIUtility.Load(k_CloudBuildEnabledUxmlPath) as VisualTreeAsset;
                var scrollContainer     = m_Provider.rootVisualElement.Q(className: k_ServiceScrollContainerClassName);
                var enabledStateContent = generalTemplate.CloneTree().contentContainer;

                ServicesUtils.TranslateStringsInTree(enabledStateContent);
                scrollContainer.Clear();
                scrollContainer.Add(enabledStateContent);

                m_Provider.rootVisualElement.Q(className: k_ServiceCloudBuildContainerClassName).style.display = DisplayStyle.None;
                m_Provider.rootVisualElement.Q(k_PollFooterSectionName).style.display = DisplayStyle.None;

                var historyButton = m_Provider.rootVisualElement.Q <Button>(k_HistoryButtonName);

                if (historyButton != null)
                {
                    historyButton.clicked += () =>
                    {
                        Application.OpenURL(ServicesConfiguration.instance.GetCurrentCloudBuildProjectHistoryUrl());
                    };
                }

                var uploadButton = m_Provider.rootVisualElement.Q <Button>(k_UploadButtonName);

                if (uploadButton != null)
                {
                    uploadButton.clicked += () =>
                    {
                        Application.OpenURL(ServicesConfiguration.instance.GetCurrentCloudBuildProjectUploadUrl());
                    };
                }

                var manageTargetButton = m_Provider.rootVisualElement.Q <Button>(k_ManageTargetButton);

                if (manageTargetButton != null)
                {
                    manageTargetButton.clicked += () =>
                    {
                        Application.OpenURL(ServicesConfiguration.instance.GetCurrentCloudBuildProjectTargetUrl());
                    };
                    manageTargetButton.style.display = DisplayStyle.None;
                }
                var addTargetButton = m_Provider.rootVisualElement.Q <Button>(k_AddTargetButton);

                if (addTargetButton != null)
                {
                    addTargetButton.clicked += () =>
                    {
                        Application.OpenURL(ServicesConfiguration.instance.GetCloudBuildAddTargetUrl());
                    };
                }

                ResetData();
                GetProjectInfo();

                m_Provider.HandlePermissionRestrictedControls();
            }
        protected override void ActivateAction(string searchContext)
        {
            // Must reset properties every time this is activated
            var mainTemplate = EditorGUIUtility.Load(k_CloudBuildCommonUxmlPath) as VisualTreeAsset;

            // To allow the save using the view data, we must provide a key on the root element
            rootVisualElement.viewDataKey = "cloud-build-root-data-key";

            var mainTemplateContainer = mainTemplate.CloneTree().contentContainer;

            ServicesUtils.TranslateStringsInTree(mainTemplateContainer);
            rootVisualElement.Add(mainTemplateContainer);

            // Make sure to reset the state machine
            m_StateMachine.ClearCurrentState();

            // Make sure to activate the state machine to the current state...

            if (BuildService.instance.IsServiceEnabled())
            {
                m_StateMachine.Initialize(m_EnabledState);
            }
            else
            {
                m_StateMachine.Initialize(m_DisabledState);
            }

            // Register the events for enabling / disabling the service only once.
            RegisterEvent();
            // Moved the Go to dashboard link to the header title section.
            m_GoToDashboard = rootVisualElement.Q(k_GoToDashboardLink);
            if (m_GoToDashboard != null)
            {
                var clickable = new Clickable(() =>
                {
                    ServicesConfiguration.instance.RequestBaseCloudBuildDashboardUrl(baseCloudBuildDashboardUrl =>
                    {
                        OpenDashboardOrgAndProjectIds(baseCloudBuildDashboardUrl);
                    });
                });
                m_GoToDashboard.AddManipulator(clickable);
            }

            m_MainServiceToggle = rootVisualElement.Q <Toggle>(className: k_ServiceToggleClassName);
            SetupServiceToggle(BuildService.instance);

            var learnMore = rootVisualElement.Q(k_LearnMoreLink);

            if (learnMore != null)
            {
                var clickable = new Clickable(() =>
                {
                    Application.OpenURL(ServicesConfiguration.instance.GetUnityTeamInfoUrl());
                });
                learnMore.AddManipulator(clickable);
            }
        }
Ejemplo n.º 7
0
            public override void EnterState()
            {
                //If we haven't received new bound info, fetch them
                var generalTemplate = EditorGUIUtility.Load(k_CloudDiagCrashEnabledUxmlPath) as VisualTreeAsset;
                var crashContainer  = m_Provider.rootVisualElement.Q(k_CloudDiagCrashStateName);

                if ((generalTemplate != null) && (crashContainer != null))
                {
                    var newVisual = generalTemplate.CloneTree().contentContainer;
                    ServicesUtils.TranslateStringsInTree(newVisual);
                    crashContainer.Clear();
                    crashContainer.Add(newVisual);

                    var capturePlayMode = crashContainer.Q <Toggle>(k_CrashCapturePlayMode);
                    if (capturePlayMode != null)
                    {
                        capturePlayMode.SetValueWithoutNotify(CrashReportingSettings.captureEditorExceptions);
                        capturePlayMode.RegisterValueChangedCallback(evt =>
                        {
                            CrashReportingSettings.captureEditorExceptions = evt.newValue;
                        });
                    }

                    var logBufferSize = crashContainer.Q <IntegerField>(k_CrashBufferLogCount);
                    if (logBufferSize != null)
                    {
                        logBufferSize.SetValueWithoutNotify((int)CrashReportingSettings.logBufferSize);
                        logBufferSize.RegisterValueChangedCallback(evt =>
                        {
                            var newValue    = evt.newValue;
                            var updateValue = false;

                            if (evt.newValue < k_CrashBufferLogMinimum)
                            {
                                newValue    = k_CrashBufferLogMinimum;
                                updateValue = true;
                            }
                            else if (evt.newValue > k_CrashBufferLogMaximum)
                            {
                                newValue    = k_CrashBufferLogMaximum;
                                updateValue = true;
                            }

                            CrashReportingSettings.logBufferSize = (uint)newValue;
                            if (updateValue)
                            {
                                logBufferSize.SetValueWithoutNotify(newValue);
                            }
                        });
                        m_Provider.UpdateServiceToggleAndDashboardLink(CrashService.instance.IsServiceEnabled());
                    }

                    m_Provider.HandlePermissionRestrictedControls();
                }
            }
Ejemplo n.º 8
0
            public override void EnterState()
            {
                // Just get the latest state of the asset store package installation...
                VerifyAssetStorePackageInstallation();

                if (assetStorePackageInstalled && !m_AssetStoreWarningHasBeenShown)
                {
                    NotificationManager.instance.Publish(Notification.Topic.AdsService, Notification.Severity.Warning, L10n.Tr(k_AdsAssetStorePackageInstalledWarning));
                    m_AssetStoreWarningHasBeenShown = true;
                }

                // If we haven't received new bound info, fetch them
                var generalTemplate = EditorGUIUtility.Load(k_AdsEnabledUxmlPath) as VisualTreeAsset;
                var scrollContainer = provider.rootVisualElement.Q(null, k_ServiceScrollContainerClassName);

                if (generalTemplate != null)
                {
                    var newVisual = generalTemplate.CloneTree().contentContainer;
                    ServicesUtils.TranslateStringsInTree(newVisual);
                    scrollContainer.Clear();
                    scrollContainer.Add(newVisual);
                    var learnMore = scrollContainer.Q(k_LearnMoreLink);
                    if (learnMore != null)
                    {
                        var clickable = new Clickable(() =>
                        {
                            Application.OpenURL(ServicesConfiguration.instance.adsLearnMoreUrl);
                        });
                        learnMore.AddManipulator(clickable);
                    }
                    var toggleTestMode = scrollContainer.Q <Toggle>(k_ToggleTestModeName);
                    if (toggleTestMode != null)
                    {
                        toggleTestMode.SetValueWithoutNotify(AdvertisementSettings.testMode);
                        toggleTestMode.RegisterValueChangedCallback(evt =>
                        {
                            AdvertisementSettings.testMode = evt.newValue;
                        });
                    }

                    // Prepare the package section and update the package information
                    PreparePackageSection(scrollContainer);
                    UpdatePackageInformation();

                    // Getting the textfield for updates with the actual GameId values...
                    m_AppleGameIdTextField   = scrollContainer.Q <TextField>(k_AppleGameIdName);
                    m_AndroidGameIdTextField = scrollContainer.Q <TextField>(k_AndroidGameIdName);
                    provider.SetUpGameId();
                    scrollContainer.Add(ServicesUtils.SetupSupportedPlatformsBlock(ServicesUtils.GetAdsSupportedPlatforms()));

                    provider.HandlePermissionRestrictedControls();
                }
                // Refresh the game Id when entering the ON state...
                provider.RequestAdsGameIds();
            }
Ejemplo n.º 9
0
            protected void LoadScrollContainer()
            {
                var rootElement = provider.rootVisualElement;

                if (rootElement != null)
                {
                    var scrollContainer = provider.rootVisualElement.Q(className: k_ScrollContainerClass);
                    scrollContainer.Clear();
                    ServicesUtils.TranslateStringsInTree(provider.rootVisualElement);

                    provider.UpdateServiceToggleAndDashboardLink(provider.serviceInstance.IsServiceEnabled());
                }
            }
            protected void LoadTemplateIntoScrollContainer(string templatePath)
            {
                var generalTemplate = EditorGUIUtility.Load(templatePath) as VisualTreeAsset;
                var rootElement     = provider.rootVisualElement;

                if (rootElement != null)
                {
                    var scrollContainer = provider.rootVisualElement.Q(className: k_ScrollContainerClass);
                    scrollContainer.Clear();
                    scrollContainer.Add(generalTemplate.CloneTree().contentContainer);
                    ServicesUtils.TranslateStringsInTree(provider.rootVisualElement);
                }
            }
Ejemplo n.º 11
0
            public override void EnterState()
            {
                var generalTemplate = EditorGUIUtility.Load(k_CollaborateDisabledUxmlPath) as VisualTreeAsset;
                var scrollContainer = provider.rootVisualElement.Q(null, k_ServiceScrollContainerClassName);

                scrollContainer.Clear();
                if (generalTemplate != null)
                {
                    var newVisual = generalTemplate.CloneTree().contentContainer;
                    ServicesUtils.TranslateStringsInTree(newVisual);
                    scrollContainer.Add(newVisual);
                }

                provider.HandlePermissionRestrictedControls();
            }
Ejemplo n.º 12
0
            void SetupAdditionalEventsBlock()
            {
                var additionalEventsBlock = provider.rootVisualElement.Q(k_AdditionalEventsBlock);

                if (additionalEventsBlock != null)
                {
                    additionalEventsBlock.Clear();

                    var eventTemplate = EditorGUIUtility.Load(k_AdditionalEventsTemplatePath) as VisualTreeAsset;
                    if (eventTemplate != null)
                    {
                        foreach (var additionalEvent in m_AdditionalEvents)
                        {
                            var eventBlock = eventTemplate.CloneTree().contentContainer;
                            ServicesUtils.TranslateStringsInTree(eventBlock);
                            if (eventBlock != null)
                            {
                                //set icon visibility
                                var checkIcon = eventBlock.Q(className: k_CheckIconClass);
                                if (checkIcon != null)
                                {
                                    checkIcon.style.display = additionalEvent.Value.integrated ? DisplayStyle.Flex : DisplayStyle.None;
                                }
                                var preCheckIcon = eventBlock.Q(className: k_PreCheckIconClass);
                                if (preCheckIcon != null)
                                {
                                    preCheckIcon.style.display = !additionalEvent.Value.integrated ? DisplayStyle.Flex : DisplayStyle.None;
                                }

                                //set text
                                eventBlock.Q <Label>(k_AdditionalEventTitle).text = additionalEvent.Value.title;
                                eventBlock.Q <Label>(k_AdditionalEventDesc).text  = additionalEvent.Value.description;

                                // Setup link url
                                var learnMore = new Clickable(() =>
                                {
                                    Application.OpenURL(additionalEvent.Value.learnUrl);
                                });
                                eventBlock.Q(k_AdditionalEventLearnUrl).AddManipulator(learnMore);

                                additionalEventsBlock.Add(eventBlock);
                            }
                        }
                    }
                }
            }
Ejemplo n.º 13
0
        protected override void ActivateAction(string searchContext)
        {
            // Must reset properties every time this is activated
            var mainTemplate = EditorGUIUtility.Load(k_CloudDiagCommonUxmlPath) as VisualTreeAsset;
            var newVisual    = mainTemplate.CloneTree().contentContainer;

            ServicesUtils.TranslateStringsInTree(newVisual);
            rootVisualElement.Add(newVisual);
            rootVisualElement.AddStyleSheetPath(ServicesUtils.StylesheetPath.servicesWindowCommon);
            rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? ServicesUtils.StylesheetPath.servicesWindowDark : ServicesUtils.StylesheetPath.servicesWindowLight);
            rootVisualElement.AddStyleSheetPath(ServicesUtils.StylesheetPath.servicesCommon);
            rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? ServicesUtils.StylesheetPath.servicesDark : ServicesUtils.StylesheetPath.servicesLight);

            // Setup the crash reporting UI
            SetupCrashDiag();
            // User Reporting is handled without specific states...
            SetupUserReport();

            // The Crash Reporting is done with the state machine
            // Make sure to reset the state machine
            m_CrashStateMachine.ClearCurrentState();

            // Make sure to activate the state machine to the current state...
            if (CrashService.instance.IsServiceEnabled())
            {
                m_CrashStateMachine.Initialize(m_EnabledState);
            }
            else
            {
                m_CrashStateMachine.Initialize(m_DisabledState);
            }

            // This is for the learn more button
            var learnMore = rootVisualElement.Q(k_LearnMoreLink);

            if (learnMore != null)
            {
                var clickable = new Clickable(() =>
                {
                    Application.OpenURL(ServicesConfiguration.instance.GetUnityCloudDiagnosticInfoUrl());
                });
                learnMore.AddManipulator(clickable);
            }
        }
Ejemplo n.º 14
0
        protected override void ActivateAction(string searchContext)
        {
            // Must reset properties every time this is activated
            var mainTemplate = EditorGUIUtility.Load(k_AdsCommonUxmlPath) as VisualTreeAsset;
            var newVisual    = mainTemplate.CloneTree().contentContainer;

            ServicesUtils.TranslateStringsInTree(newVisual);
            rootVisualElement.Add(newVisual);

            // Make sure to activate the state machine to the current state...
            if (AdsService.instance.IsServiceEnabled())
            {
                m_StateMachine.Initialize(m_EnabledState);
            }
            else
            {
                m_StateMachine.Initialize(m_DisabledState);
            }

            // Register the events for enabling / disabling the service only once.
            RegisterEvent();

            // Moved the Go to dashboard link to the header title section.
            m_GoToDashboard = rootVisualElement.Q(k_GoToDashboardLinkName);
            if (m_GoToDashboard != null)
            {
                var clickable = new Clickable(() =>
                {
                    var adsDashboardUrl = ServicesConfiguration.instance.adsDashboardUrl;
                    EditorAnalytics.SendOpenDashboardForService(new OpenDashboardForService()
                    {
                        serviceName = AdsService.instance.name, url = adsDashboardUrl
                    });
                    Application.OpenURL(adsDashboardUrl);
                });
                m_GoToDashboard.AddManipulator(clickable);
            }

            m_MainServiceToggle = rootVisualElement.Q <Toggle>(className: k_ServiceToggleClassName);
            SetupServiceToggle(AdsService.instance);
        }
Ejemplo n.º 15
0
        void SetupUserReport()
        {
            var userReportContainer = rootVisualElement.Q(className: k_CloudDiagUserReportContainerClassName);
            var generalTemplate     = EditorGUIUtility.Load(k_CloudDiagUserReportUxmlPath) as VisualTreeAsset;

            if ((generalTemplate != null) && (userReportContainer != null))
            {
                var newVisual = generalTemplate.CloneTree().contentContainer;
                ServicesUtils.TranslateStringsInTree(newVisual);
                userReportContainer.Clear();
                userReportContainer.Add(newVisual);
                userReportContainer.Add(ServicesUtils.SetupSupportedPlatformsBlock(ServicesUtils.GetCloudDiagUserReportSupportedPlatforms()));

                var downloadSdkButtonLink = rootVisualElement.Q(k_UserReportingDownloadSdk);
                if (downloadSdkButtonLink != null)
                {
                    var clickable = new Clickable(() =>
                    {
                        Application.OpenURL(ServicesConfiguration.instance.GetUnityCloudDiagnosticUserReportingSdkUrl());
                    });
                    downloadSdkButtonLink.AddManipulator(clickable);
                }
            }
        }
Ejemplo n.º 16
0
            public override void EnterState()
            {
                //If we haven't received new bound info, fetch them
                var generalTemplate = EditorGUIUtility.Load(k_CollaborateEnabledUxmlPath) as VisualTreeAsset;
                var scrollContainer = provider.rootVisualElement.Q(null, k_ServiceScrollContainerClassName);
                var newVisual       = generalTemplate.CloneTree().contentContainer;

                ServicesUtils.TranslateStringsInTree(newVisual);
                scrollContainer.Clear();
                scrollContainer.Add(newVisual);

                m_CollabPublishSection = scrollContainer.Q(k_CollabPublishSection);
                m_CollabHistorySection = scrollContainer.Q(k_CollabHistorySection);
                // Don't show the Publish and History section by default
                if (m_CollabHistorySection != null)
                {
                    m_CollabHistorySection.style.display = DisplayStyle.None;
                }
                if (m_CollabPublishSection != null)
                {
                    m_CollabPublishSection.style.display = DisplayStyle.None;
                }

                var openHistory = provider.rootVisualElement.Q(k_OpenHistoryLink) as Button;

                if (openHistory != null)
                {
                    openHistory.clicked += () =>
                    {
                        if (Collab.ShowHistoryWindow != null)
                        {
                            Collab.ShowHistoryWindow();
                        }
                    };
                }

                Button openChangesLinkBtn = provider.rootVisualElement.Q(k_OpenChangesLink) as Button;

                if (openChangesLinkBtn != null)
                {
                    openChangesLinkBtn.clicked += () =>
                    {
                        if (Collab.ShowChangesWindow != null)
                        {
                            Collab.ShowChangesWindow();
                        }
                    };
                }

                var gotoWebDashboard = scrollContainer.Q(k_GoToWebDashboardLink);

                if (gotoWebDashboard != null)
                {
                    var clickable = new Clickable(() =>
                    {
                        ServicesConfiguration.instance.RequestBaseCloudUsageDashboardUrl(baseCloudUsageDashboardUrl =>
                        {
                            provider.OpenDashboardOrgAndProjectIds(baseCloudUsageDashboardUrl);
                        });
                    });
                    gotoWebDashboard.AddManipulator(clickable);
                }
                // Prepare the package section and update the package information
                PreparePackageSection(scrollContainer);
                UpdatePackageInformation();

                provider.HandlePermissionRestrictedControls();
            }