/// <summary>
        /// Load the asset for settings, or create one if it doesn't already exist
        /// </summary>
        /// <returns>The loaded settings</returns>
        internal static HierarchyDecoratorSettings GetOrCreateSettings()
        {
            //Find the asset
            HierarchyDecoratorSettings settings = AssetDatabase.LoadAssetAtPath <HierarchyDecoratorSettings> (Constants.SETTINGS_ASSET_PATH);

            //Create the asset if it doesn't exist
            if (settings == null)
            {
                //Create and setup defaults
                settings = CreateInstance <HierarchyDecoratorSettings> ();
                settings.SetDefaults();

                //Create folder
                if (!Directory.Exists(Constants.SETTINGS_ASSET_FOLDER))
                {
                    Directory.CreateDirectory(Constants.SETTINGS_ASSET_FOLDER);
                }

                //Create and save
                AssetDatabase.CreateAsset(settings, Constants.SETTINGS_ASSET_PATH);
                AssetDatabase.SaveAssets();

                Debug.Log($"Hiearchy Decorator found no previous settings, creating one at {Constants.SETTINGS_ASSET_PATH}.");
            }

            return(settings);
        }
Ejemplo n.º 2
0
        private static void GetSettings()
        {
            //Cache Styles
            settings = Constants.Settings;
            styles   = Constants.Settings.prefixes.ToArray();

            //Call to make sure it updates without requiring the SO to be opened
            settings.UpdateSettings();
        }
Ejemplo n.º 3
0
        // On Load of Window
        public override void OnActivate(System.String searchContext, VisualElement rootElement)
        {
            base.OnActivate(searchContext, rootElement);

            if (settings == null)
            {
                settings           = HierarchyDecoratorSettings.GetOrCreateSettings();
                serializedSettings = HierarchyDecoratorSettings.GetSerializedSettings();
            }
        }
        private void OnEnable()
        {
            t = target as HierarchyDecoratorSettings;

            generalTab = new GeneralTab();
            prefixTab  = new PrefixTab();
            styleTab   = new StyleTab();
            iconTab    = new IconTab();
            infoTab    = new InfoTab();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor used to cache the data required
        /// </summary>
        /// <param name="settings">Current settings used for the hierarchy</param>
        public SettingsTab()
        {
            this.settings           = HierarchyDecoratorSettings.GetOrCreateSettings();
            this.serializedSettings = HierarchyDecoratorSettings.GetSerializedSettings();

            if (this.settings == null)
            {
                Debug.LogError("Cannot find settings in project!");
            }
        }
 private void OnEnable()
 {
     t = target as HierarchyDecoratorSettings;
 }