#if UNITY_2019_4_OR_NEWER using System; using System.Linq; using StansAssets.Foundation.Editor; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; using PackageInfo = UnityEditor.PackageManager.PackageInfo; namespace StansAssets.Plugins.Editor { /// /// Base class for Plugin Settings Window /// /// public abstract class PackageSettingsWindow : EditorWindow where TWindow : EditorWindow { protected abstract PackageInfo GetPackageInfo(); protected abstract void OnWindowEnable(VisualElement root); TabController m_TabController; readonly string m_WindowUIFilesRootPath = $"{PluginsDevKitPackage.UIToolkitPath}/SettingsWindow"; /// /// Set/Get the flexible growth property of tabs content container /// public StyleFloat ContentFlexGrow { get => m_TabController.ContainerFlexGrow; set => m_TabController.ContentContainerFlexGrow(value); } 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_TabController = new TabController(root); var packageInfo = GetPackageInfo(); root.Q