Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)

## [0.13.0] - 2025-09-25

**New**:
- Added *UiToolkitPresenter* script to allow UI Toolkit based UIs to work with the library

**Changed**:
- Updated *README* to reflect the project structure
- Adjusted the Editor tools and *UiService* to process UI Toolkit based views

## [0.12.0] - 2025-01-08

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

**Changed**:
- Renamed *AdjustScreenSizeFitter* to *AdjustScreenSizeFitterView* to mark it as a View in the architecture conventions
Expand Down
29 changes: 23 additions & 6 deletions Editor/UiConfigsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UnityEditor.AddressableAssets.Settings;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.UIElements;

// ReSharper disable once CheckNamespace

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

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

var canvas = uiPresenter.GetComponent<Canvas>();
var sortingOrder = -1;
if (uiPresenter.TryGetComponent<Canvas>(out var canvas))
{
sortingOrder = canvas.sortingOrder;
}
else if (uiPresenter.TryGetComponent<UIDocument>(out var document))
{
sortingOrder = (int) document.sortingOrder;
}

var indexMatch = configsCache.FindIndex(configCheck => configCheck.AddressableAddress == assetAddress);
var type = uiPresenter.GetType();
var config = new UiConfig
{
AddressableAddress = assetList[i].address,
Layer = canvas == null ? 0 : canvas.sortingOrder,
Layer = sortingOrder < 0 ? 0 : sortingOrder,
UiType = type,
LoadSynchronously = Attribute.IsDefined(type, typeof(LoadSynchronouslyAttribute))

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

config.Layer = canvas == null ? configsCache[indexMatch].Layer : config.Layer;
config.Layer = sortingOrder < 0 ? configsCache[indexMatch].Layer : config.Layer;
}

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

layer.intValue = newLayer;

var canvas = AssetDatabase.LoadAssetAtPath<GameObject>(_assetsPath[index]).GetComponent<Canvas>();
if (canvas != null)
var ui = AssetDatabase.LoadAssetAtPath<GameObject>(_assetsPath[index]);
if (ui.TryGetComponent<Canvas>(out var canvas))
{
canvas.sortingOrder = newLayer;

EditorUtility.SetDirty(canvas);
AssetDatabase.SaveAssets();
}
else if (ui.TryGetComponent<UIDocument>(out var document))
{
document.sortingOrder = newLayer;

EditorUtility.SetDirty(document);
AssetDatabase.SaveAssets();
}

Resources.UnloadUnusedAssets();
}
Expand Down
Loading