Documentation: Updated README.md and added a small demo gif
This commit is contained in:
parent
f1e33f5e6b
commit
5f37c59a79
7 changed files with 168 additions and 23 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
|
@ -20,12 +21,6 @@ namespace Module.UIToolkit.Editor
|
|||
ApplyChanges();
|
||||
}
|
||||
|
||||
private static void InitializeStyleSheets()
|
||||
{
|
||||
if (_ussCollectionView == null)
|
||||
_ussCollectionView = FindStyleSheet("editor-collection-view");
|
||||
}
|
||||
|
||||
internal static void ApplyChanges()
|
||||
{
|
||||
InitializeStyleSheets();
|
||||
|
|
@ -38,19 +33,24 @@ namespace Module.UIToolkit.Editor
|
|||
var window = windows[i];
|
||||
var ve = window.rootVisualElement;
|
||||
|
||||
if (ve == null)
|
||||
if (ve == null || _ussCollectionView == null)
|
||||
continue;
|
||||
|
||||
if (_ussCollectionView != null)
|
||||
{
|
||||
if (settings.collectionViewDisableMaxHeight)
|
||||
ve.styleSheets.Add(_ussCollectionView);
|
||||
else
|
||||
ve.styleSheets.Remove(_ussCollectionView);
|
||||
}
|
||||
|
||||
if (settings.collectionViewDisableMaxHeight)
|
||||
ve.styleSheets.Add(_ussCollectionView);
|
||||
else
|
||||
ve.styleSheets.Remove(_ussCollectionView);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static void InitializeStyleSheets()
|
||||
{
|
||||
if (_ussCollectionView == null)
|
||||
_ussCollectionView = FindStyleSheet("editor-collection-view");
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static StyleSheet FindStyleSheet(string name)
|
||||
{
|
||||
var guids = AssetDatabase.FindAssets($"t:{nameof(StyleSheet)} {name}");
|
||||
|
|
@ -62,6 +62,7 @@ namespace Module.UIToolkit.Editor
|
|||
return AssetDatabase.LoadAssetAtPath<StyleSheet>(path);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static EditorWindow[] GetAllOpenEditorWindows()
|
||||
{
|
||||
return Resources.FindObjectsOfTypeAll<EditorWindow>();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,13 @@ namespace Module.UIToolkit.Editor
|
|||
public bool collectionViewDisableMaxHeight = true;
|
||||
|
||||
private static Settings _settings;
|
||||
|
||||
|
||||
internal void Save()
|
||||
{
|
||||
var json = JsonUtility.ToJson(this);
|
||||
EditorPrefs.SetString(nameof(Settings), json);
|
||||
}
|
||||
|
||||
internal static Settings Load()
|
||||
{
|
||||
if (_settings != null)
|
||||
|
|
@ -24,11 +30,5 @@ namespace Module.UIToolkit.Editor
|
|||
|
||||
return _settings;
|
||||
}
|
||||
|
||||
internal void Save()
|
||||
{
|
||||
var json = JsonUtility.ToJson(this);
|
||||
EditorPrefs.SetString(nameof(Settings), json);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue