Skip to content

Commit 3658334

Browse files
Merge pull request #9 from CoderGamester/develop
Release 0.4.0
2 parents a7ab646 + 963e96e commit 3658334

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ 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.4.0] - 2020-07-13
8+
9+
**Changed**:
10+
- Removed the *UiService* dependency from the *Addressables*
11+
- Modified the *UiService* to be testable and injectable into other systems
12+
713
## [0.3.2] - 2020-04-18
814

915
- Moved interface *IUiService* to a separate file to improve the code readability

Runtime/UiService.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Threading.Tasks;
44
using GameLovers.AssetLoader;
55
using UnityEngine;
6-
using Object = UnityEngine.Object;
76

87
// ReSharper disable CheckNamespace
98

@@ -12,12 +11,18 @@ namespace GameLovers.UiService
1211
/// <inheritdoc />
1312
public class UiService : IUiService
1413
{
14+
private readonly IAssetLoader _assetLoader;
1515
private readonly IDictionary<Type, UiReference> _uiViews = new Dictionary<Type, UiReference>();
1616
private readonly IDictionary<Type, UiConfig> _uiConfigs = new Dictionary<Type, UiConfig>();
1717
private readonly IDictionary<int, UiSetConfig> _uiSets = new Dictionary<int, UiSetConfig>();
1818
private readonly IList<Type> _visibleUiList = new List<Type>();
1919
private readonly IList<Canvas> _layers = new List<Canvas>();
2020

21+
public UiService(IAssetLoader assetLoader)
22+
{
23+
_assetLoader = assetLoader;
24+
}
25+
2126
/// <summary>
2227
/// Initialize the service with the proper <paramref name="configs"/>
2328
/// </summary>
@@ -140,7 +145,7 @@ public async Task<UiPresenter> LoadUiAsync(Type type, bool openAfter = false)
140145
throw new KeyNotFoundException($"The UiConfig of type {type} was not added to the service. Call {nameof(AddUiConfig)} first");
141146
}
142147

143-
var gameObject = await AssetLoaderService.InstantiatePrefabAsync(config.AddressableAddress);
148+
var gameObject = await _assetLoader.InstantiatePrefabAsync(config.AddressableAddress);
144149
var uiPresenter = gameObject.GetComponent<UiPresenter>();
145150

146151
gameObject.SetActive(false);
@@ -161,7 +166,7 @@ public void UnloadUi(Type type)
161166
{
162167
var gameObject = RemoveUi(type).gameObject;
163168

164-
AssetLoaderService.UnloadAsset(gameObject);
169+
_assetLoader.UnloadAsset(gameObject);
165170
}
166171

167172
/// <inheritdoc />
@@ -367,7 +372,7 @@ public Task<Task<UiPresenter>>[] LoadUiSetAsync(int setId)
367372
uiTasks.Add(LoadUiAsync(set.UiConfigsType[i]));
368373
}
369374

370-
return AssetLoaderService.Interleaved(uiTasks);
375+
return AssetLoaderUtils.Interleaved(uiTasks);
371376
}
372377

373378
/// <inheritdoc />

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"unity": "2019.3",
66
"description": "This package provides a service to help manage an Unity's, game UI.\nIt allows to open, close, load, unload and request any Ui Configured in the game.\nThe package provides a Ui Set that allows to group a set of Ui Presenters to help load, open and close multiple Uis at the same time.\n\nTo help configure the game's UI you need to create a UiConfigs Scriptable object by:\n- Right Click on the Project View > Create > ScriptableObjects > Configs > UiConfigs",
77
"dependencies": {
8-
"com.unity.addressables": "1.6.0",
9-
"com.gamelovers.assetloader": "0.1.1"
8+
"com.gamelovers.assetloader": "0.3.0"
109
},
1110
"type": "library",
1211
"hideInEditor": false

0 commit comments

Comments
 (0)