Added option to enable/disable max-height of unity-collection-view
This commit is contained in:
commit
78adbc46af
21 changed files with 265 additions and 0 deletions
34
Editor/Settings/Settings.cs
Normal file
34
Editor/Settings/Settings.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.UIToolkit.Editor
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class Settings
|
||||
{
|
||||
public bool listViewDisableMaxHeight;
|
||||
|
||||
private static Settings _settings;
|
||||
|
||||
internal static Settings Load()
|
||||
{
|
||||
if (_settings != null)
|
||||
return _settings;
|
||||
|
||||
_settings = new Settings();
|
||||
var json = EditorPrefs.GetString(nameof(Settings), string.Empty);
|
||||
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
JsonUtility.FromJsonOverwrite(json, _settings);
|
||||
|
||||
return _settings;
|
||||
}
|
||||
|
||||
internal void Save()
|
||||
{
|
||||
var json = JsonUtility.ToJson(this);
|
||||
EditorPrefs.SetString(nameof(Settings), json);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Settings/Settings.cs.meta
Normal file
3
Editor/Settings/Settings.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38bf3b0d567162d488a2dc66f0514dcd
|
||||
timeCreated: 1749398672
|
||||
38
Editor/Settings/SettingsProvider.cs
Normal file
38
Editor/Settings/SettingsProvider.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Module.UIToolkit.Editor
|
||||
{
|
||||
internal static class SettingsProvider
|
||||
{
|
||||
[SettingsProvider]
|
||||
public static UnityEditor.SettingsProvider GetProvider()
|
||||
{
|
||||
return new UnityEditor.SettingsProvider("Module/Editor UIToolkit", SettingsScope.User)
|
||||
{
|
||||
label = "Editor UIToolkit",
|
||||
keywords = new List<string> { "UI", "Toolkit" },
|
||||
guiHandler = OnGui
|
||||
};
|
||||
}
|
||||
|
||||
private static void OnGui(string searchContext)
|
||||
{
|
||||
var settings = Settings.Load();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
EditorGUILayout.LabelField("List View", EditorStyles.boldLabel);
|
||||
settings.listViewDisableMaxHeight = EditorGUILayout.Toggle("Disable Max Height", settings.listViewDisableMaxHeight);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (!EditorGUI.EndChangeCheck())
|
||||
return;
|
||||
|
||||
settings.Save();
|
||||
EditorUIToolkitCustomization.ApplyChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Settings/SettingsProvider.cs.meta
Normal file
3
Editor/Settings/SettingsProvider.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cb3cf13736e25ce46a3eae1332f5cc8f
|
||||
timeCreated: 1749397903
|
||||
Loading…
Add table
Add a link
Reference in a new issue