Added option to enable/disable max-height of unity-collection-view

This commit is contained in:
Anders Ejlersen 2025-06-21 23:06:42 +02:00
commit 78adbc46af
21 changed files with 265 additions and 0 deletions

8
CHANGELOG.md Normal file
View file

@ -0,0 +1,8 @@
# Change Log
All notable changes to this project will be documented in this file.
## [0.1.0] - 2025-06-21
### Added
- Added option to enable/disable max-height of unity-collection-view

7
CHANGELOG.md.meta Normal file
View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d37237c964a5fa54bbd12eac4bfef86f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Editor.meta Normal file
View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dc1db355d0b00714bb21ab7e65f50b80
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,70 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace Module.UIToolkit.Editor
{
internal static class EditorUIToolkitCustomization
{
private static StyleSheet _ussCollectionView;
[InitializeOnLoadMethod]
private static void Initialize()
{
EditorApplication.update -= EditorTick;
EditorApplication.update += EditorTick;
}
private static void EditorTick()
{
ApplyChanges();
}
private static void InitializeStyleSheets()
{
if (_ussCollectionView == null)
_ussCollectionView = FindStyleSheet("editor-collection-view");
}
internal static void ApplyChanges()
{
InitializeStyleSheets();
var settings = Settings.Load();
var windows = GetAllOpenEditorWindows();
for (var i = 0; i < windows.Length; i++)
{
var window = windows[i];
var ve = window.rootVisualElement;
if (ve == null)
continue;
if (_ussCollectionView != null)
{
if (settings.listViewDisableMaxHeight)
ve.styleSheets.Add(_ussCollectionView);
else
ve.styleSheets.Remove(_ussCollectionView);
}
}
}
private static StyleSheet FindStyleSheet(string name)
{
var guids = AssetDatabase.FindAssets($"t:{nameof(StyleSheet)} {name}");
if (guids.Length == 0)
return null;
var path = AssetDatabase.GUIDToAssetPath(guids[0]);
return AssetDatabase.LoadAssetAtPath<StyleSheet>(path);
}
private static EditorWindow[] GetAllOpenEditorWindows()
{
return Resources.FindObjectsOfTypeAll<EditorWindow>();
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 98c22645c5bc08b4f9da6f90d01b76ec

View file

@ -0,0 +1,16 @@
{
"name": "Module.UIToolkit.Editor",
"rootNamespace": "Module.UIToolkit.Editor",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ba4dfb528ba3137409017f4dfbc4c8d7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Editor/Settings.meta Normal file
View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 188e9f5b1ca5190469d4327259c28d55
timeCreated: 1749398664

View 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);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 38bf3b0d567162d488a2dc66f0514dcd
timeCreated: 1749398672

View 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();
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cb3cf13736e25ce46a3eae1332f5cc8f
timeCreated: 1749397903

3
Editor/StyleSheets.meta Normal file
View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1f126b6ba5fb4d49b319e262fb961a87
timeCreated: 1750537625

View file

@ -0,0 +1,3 @@
.unity-collection-view {
max-height: none;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8bf186d8caf1cd44f86f09dc65d7e37c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0

9
LICENSE Normal file
View file

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2025 ejlersen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

7
LICENSE.meta Normal file
View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: afccc865be88fe54cbde565c04bd724e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

2
README.md Normal file
View file

@ -0,0 +1,2 @@
# module-menu-item-tool

7
README.md.meta Normal file
View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cd1776d4d90ac8c49984a56392f0a196
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

17
package.json Normal file
View file

@ -0,0 +1,17 @@
{
"name": "com.module.uitoolkit",
"version": "0.1.0",
"displayName": "Module.UIToolkit.Editor",
"description": "Modify editor ui",
"unity": "6000.0",
"unityRelease": "1f1",
"keywords": [
"ui",
"toolkit"
],
"author": {
"name": "Anders Ejlersen",
"email": "anders@ejlersen.info",
"url": "https://www.ejlersen.info"
}
}

7
package.json.meta Normal file
View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7b225aef32c94bf4f8bd649e56c95c05
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: