Beispiel #1
0
        void OnEnable()
        {
            var root = rootVisualElement;

            // Import UXML
            var uxmlPath   = $"{m_WindowUIFilesRootPath}/PackageSettingsWindow.uxml";
            var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(uxmlPath);
            var template   = visualTree.CloneTree();

            m_WindowRoot = template[0];
            root.Add(m_WindowRoot);

            var packageInfo = GetPackageInfo();

            root.Q <Label>("displayName").text = packageInfo.displayName.TrimStart("Stans Assets - ");
            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();
        }
        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();
            };
        }
        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();
        }