void OnEnable()
        {
            // This is a workaround due to a very weird bug.
            // During OnEnable we may need to accesses singleton scriptable object associated with the package.
            // And looks like AssetDatabase could be not ready and we will recreate new empty settings objects
            // instead of getting existing one.
            EditorApplication.delayCall += () =>
            {
                var root = rootVisualElement;
                UIToolkitEditorUtility.CloneTreeAndApplyStyle(root, $"{m_WindowUIFilesRootPath}/PackageSettingsWindow");

                m_TabsContainer = root.Q <ScrollView>("tabs-container");

                var packageInfo = GetPackageInfo();
                root.Q <Label>("display-name").text = packageInfo.displayName.Remove(0, "Stans Assets - ".Length);
                root.Q <Label>("description").text  = packageInfo.description;
                root.Q <Label>("version").text      = $"Version: {packageInfo.version}";

                m_TabsButtons = root.Q <ButtonStrip>();
                m_TabsButtons.CleanUp();
                m_TabsButtons.OnButtonClick += ActivateTab;

                OnWindowEnable(root);
                ActivateTab();
            };
        }
        /// <summary>
        /// Creates LoadingSpinner control
        /// </summary>
        public LoadingSpinner()
        {
            AddToClassList(UssClassName);
            UIToolkitEditorUtility.ApplyStyleForInternalControl(this, nameof(LoadingSpinner));
            m_IsActive = false;

            // add child elements to set up centered spinner rotation
            var innerElement = new VisualElement();

            innerElement.AddToClassList("image");
            Add(innerElement);

            m_ScheduledUpdate = schedule.Execute(UpdateProgress).Every(k_RotationUpdateInterval);
            m_ScheduledUpdate.Pause();

            RegisterCallback <AttachToPanelEvent>(OnAttachToPanelEventHandler, TrickleDown.TrickleDown);
            RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanelEventHandler, TrickleDown.TrickleDown);
        }
Пример #3
0
        void OnEnable()
        {
            var root = rootVisualElement;

            UIToolkitEditorUtility.CloneTreeAndApplyStyle(root, $"{m_WindowUIFilesRootPath}/PackageSettingsWindow");

            m_TabsContainer = root.Q <ScrollView>("tabs-container");

            var packageInfo = GetPackageInfo();

            root.Q <Label>("display-name").text = packageInfo.displayName.Remove(0, "Stans Assets - ".Length);
            root.Q <Label>("description").text  = packageInfo.description;
            root.Q <Label>("version").text      = $"Version: {packageInfo.version}";

            m_TabsButtons = root.Q <ButtonStrip>();
            m_TabsButtons.CleanUp();
            m_TabsButtons.OnButtonClick += ActivateTab;

            OnWindowEnable(root);
            ActivateTab();
        }
Пример #4
0
        /// <summary>
        /// Creates ButtonStrip control with choices.
        /// </summary>
        /// <param name="choices">Available chaises.</param>
        public ButtonStrip(IEnumerable <string> choices)
        {
            AddToClassList(UssClassName);
            UIToolkitEditorUtility.ApplyStyleForInternalControl(this, nameof(ButtonStrip));

            var collection = choices.ToList();

            m_Choices.AddRange(collection);
            m_Labels.AddRange(collection);
            RecreateButtons();

            m_TextField = new TextField {
                viewDataKey = "view-data"
            };
            m_TextField.style.display = DisplayStyle.None;
            Add(m_TextField);

            // This is only possible when data is restored.
            m_TextField.RegisterValueChangedCallback(e =>
            {
                SetValue(e.newValue);
            });
        }
Пример #5
0
 /// <summary>
 /// Created tab with the content of provided uxml file.
 /// </summary>
 /// <param name="path">Project related uxml/uss file path without extensions.</param>
 protected BaseTab(string path)
 {
     UIToolkitEditorUtility.CloneTreeAndApplyStyle(this, path);
 }
        void BindVersionIncrementSection()
        {
            var incrementBuildNumberToggle = this.Q <Toggle>("incrementBuildNumber-toggle");

            incrementBuildNumberToggle.RegisterValueChangedCallback(e =>
            {
                BuildSystemSettings.Instance.AutomatedBuildNumberIncrement = e.newValue;
            });

            var automatedBuildNumber = BuildSystemSettings.Instance.AutomatedBuildNumberIncrement;

            incrementBuildNumberToggle.SetValueWithoutNotify(automatedBuildNumber);

            var googleDocMissingBlock   = this.Q("google-doc-missing-block");
            var googleDocInstalledBlock = this.Q("google-doc-installed-block");

            m_SpreadsheetsListContainer = this.Q <VisualElement>("list-spreadsheet");
            if (StanAssetsPackages.IsGoogleDocConnectorProInstalled)
            {
#if GOOGLE_DOC_CONNECTOR_PRO_ENABLED
                var versionIncrementBlock = this.Q("version-increment");
                UIToolkitEditorUtility.ApplyStyle(versionIncrementBlock, GoogleDocConnectorPackage.LocalizationTabPath);

                var openBtn = this.Q <Button>("openBtn");
                openBtn.clicked += () =>
                {
                    Application.OpenURL(BuildVersionsSpreadsheet.Url);
                };
                CreateListSpreadsheet();
#endif
                googleDocInstalledBlock.style.display = DisplayStyle.Flex;
                googleDocMissingBlock.style.display   = DisplayStyle.None;
            }
            else
            {
                googleDocInstalledBlock.style.display = DisplayStyle.None;
                googleDocMissingBlock.style.display   = DisplayStyle.Flex;
            }

            m_MaskText         = this.Q <TextField>("mask-text");
            m_ListMask         = this.Q <VisualElement>("listMask");
            m_MaskText.value   = k_MaskTextPlaceholder;
            m_MaskText.tooltip = k_MaskTextPlaceholder;
            m_ListMask.Clear();
            foreach (var mask in BuildSystemSettings.Instance.MaskList)
            {
                CreateMaskElement(mask);
            }

            var addMask = this.Q <Button>("add-mask");
            addMask.clicked += AddMask;

            var gitRepositoryName = this.Q <TextField>("git-repo-text");
            gitRepositoryName.SetValueWithoutNotify(BuildSystemSettings.Instance.GitHubRepository);
            gitRepositoryName.RegisterValueChangedCallback((e) =>
            {
                BuildSystemSettings.Instance.GitHubRepository = e.newValue;
            });


            RebindExtraFieldsList();
            var addExtraFiledButton = this.Q <Button>("add-extra-field");
            addExtraFiledButton.clicked += () =>
            {
                BuildSystemSettings.Instance.AddNewExtraField();
                RebindExtraFieldsList();
            };
        }