Skip to content

Commit 6a8628d

Browse files
Merge pull request #22 from CoderGamester/develop
Release 0.13.0
2 parents 97e607d + 5bbcd79 commit 6a8628d

File tree

6 files changed

+731
-241
lines changed

6 files changed

+731
-241
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ All notable changes to this package will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
66

7+
## [0.13.0] - 2025-09-25
8+
9+
**New**:
10+
- Added *UiToolkitPresenter* script to allow UI Toolkit based UIs to work with the library
11+
12+
**Changed**:
13+
- Updated *README* to reflect the project structure
14+
- Adjusted the Editor tools and *UiService* to process UI Toolkit based views
15+
716
## [0.12.0] - 2025-01-08
817

918
**New**:
10-
- Added *InteractableTextView* script to allow linking text code execution, e.g open URLs in the broser
19+
- Added *InteractableTextView* script to allow linking text code execution, e.g open URLs in the browser
1120

1221
**Changed**:
1322
- Renamed *AdjustScreenSizeFitter* to *AdjustScreenSizeFitterView* to mark it as a View in the architecture conventions

Editor/UiConfigsEditor.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using UnityEditor.AddressableAssets.Settings;
77
using UnityEditorInternal;
88
using UnityEngine;
9+
using UnityEngine.UIElements;
910

1011
// ReSharper disable once CheckNamespace
1112

@@ -59,7 +60,7 @@ public abstract class UiConfigsEditor<TSet> : Editor
5960
"All the Addressable addresses for every UiPresenter in the game.\n" +
6061
"The second field is the layer where the UiPresenter should be shown. " +
6162
"The higher the value, the closer is the UiPresenter to the camera.\n" +
62-
"If the UiPresenter contains a Canvas in the root, the layer value is the same of the Canvas sorting order");
63+
"If the UiPresenter contains a Canvas/UIDocument in the root, the layer value is the same of the UI sorting order");
6364
private readonly GUIContent _uiSetConfigGuiContent = new GUIContent("Ui Set",
6465
"All the Ui Sets in the game.\n" +
6566
"A UiSet groups a list of UiConfigs and shows them all at the same time via the UiService.\n" +
@@ -171,13 +172,22 @@ private void InitConfigValues()
171172

172173
_assetsPath.Add(assetList[i].AssetPath);
173174

174-
var canvas = uiPresenter.GetComponent<Canvas>();
175+
var sortingOrder = -1;
176+
if (uiPresenter.TryGetComponent<Canvas>(out var canvas))
177+
{
178+
sortingOrder = canvas.sortingOrder;
179+
}
180+
else if (uiPresenter.TryGetComponent<UIDocument>(out var document))
181+
{
182+
sortingOrder = (int) document.sortingOrder;
183+
}
184+
175185
var indexMatch = configsCache.FindIndex(configCheck => configCheck.AddressableAddress == assetAddress);
176186
var type = uiPresenter.GetType();
177187
var config = new UiConfig
178188
{
179189
AddressableAddress = assetList[i].address,
180-
Layer = canvas == null ? 0 : canvas.sortingOrder,
190+
Layer = sortingOrder < 0 ? 0 : sortingOrder,
181191
UiType = type,
182192
LoadSynchronously = Attribute.IsDefined(type, typeof(LoadSynchronouslyAttribute))
183193

@@ -188,7 +198,7 @@ private void InitConfigValues()
188198
uiConfigsAddress.Add(config.AddressableAddress);
189199
_uiConfigsType.Add(config.UiType.AssemblyQualifiedName);
190200

191-
config.Layer = canvas == null ? configsCache[indexMatch].Layer : config.Layer;
201+
config.Layer = sortingOrder < 0 ? configsCache[indexMatch].Layer : config.Layer;
192202
}
193203

194204
configs.Add(config);
@@ -267,14 +277,21 @@ private void DrawUiConfigElement(Rect rect, int index, bool isActive, bool isFoc
267277

268278
layer.intValue = newLayer;
269279

270-
var canvas = AssetDatabase.LoadAssetAtPath<GameObject>(_assetsPath[index]).GetComponent<Canvas>();
271-
if (canvas != null)
280+
var ui = AssetDatabase.LoadAssetAtPath<GameObject>(_assetsPath[index]);
281+
if (ui.TryGetComponent<Canvas>(out var canvas))
272282
{
273283
canvas.sortingOrder = newLayer;
274284

275285
EditorUtility.SetDirty(canvas);
276286
AssetDatabase.SaveAssets();
277287
}
288+
else if (ui.TryGetComponent<UIDocument>(out var document))
289+
{
290+
document.sortingOrder = newLayer;
291+
292+
EditorUtility.SetDirty(document);
293+
AssetDatabase.SaveAssets();
294+
}
278295

279296
Resources.UnloadUnusedAssets();
280297
}

0 commit comments

Comments
 (0)