Skip to content

Commit 2eb3cbb

Browse files
Merge pull request #7 from CoderGamester/develop
0.3.1
2 parents 968c374 + bc09dcc commit 2eb3cbb

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

CHANGELOG.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ 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.3.1] - 2020-02-15
8+
9+
- Updated dependency packages
10+
711
## [0.3.0] - 2020-02-11
812

913
- Added new *UiPresenterData* class for the case where the *UiPresenter* needs to be initialized with a default data value
1014
- Added new *OnInitialize* method that is invoked after the *UiPresenter* is initialized
1115

12-
## [0.2.0] - 2020-01-19
13-
1416
## [0.2.1] - 2020-02-09
1517

1618
- Added the possibility to open the ui after adding or loading it to the *UiService*
@@ -22,25 +24,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2224

2325
## [0.2.0] - 2020-01-19
2426

25-
- Added easy selection of the UiConfigs.asset file. Just go to Tools > Select UiConfigs.asset. If the UiConfigs.asset does not exist, it will create a new one in the Assets folder
26-
- Added the protected Close() method to directly allow to close the UiPresenter from the UiPresenter object file without needing to call the UiService. Also now is possible to close an Ui in the service by referencing the object directly without needing to reference the object type by calling CloseUi<T>(T presenter)
27-
- Now the UnloadUi & UnloadUiSet properly unloads the ui from memory and removes it from the service
28-
- Added RemoveUi & RemoveUiPresentersFromSet to allow the ui to be removed from the service without being unloaded from memory
27+
- Added easy selection of the *UiConfigs.asset* file. Just go to *Tools > Select UiConfigs.asset*. If the *UiConfigs.asset* does not exist, it will create a new one in the Assets folder
28+
- Added the protected *Close()* method to directly allow to close the *UiPresenter* from the *UiPresenter* object file without needing to call the *UiService*. Also now is possible to close an Ui in the service by referencing the object directly without needing to reference the object type by calling *CloseUi<T>(T presenter)*
29+
- Now the *UnloadUi* & *UnloadUiSet* properly unloads the ui from memory and removes it from the service
30+
- Added *RemoveUi* & *RemoveUiPresentersFromSet* to allow the ui to be removed from the service without being unloaded from memory
2931
- Improved documentation
3032

3133
**Changed**
32-
- Now the Refresh method on the UiPresenter is public and can be called from any object that has asset to it. The UiService will not call this method anymore if trying to Open the same UiPresenter twice without closing
33-
- In the UiService, IsUiLoaded changed to HasUiPresenter
34-
- In the UiService IsAllUiLoadedInSet changed to HasAllUiPresentersInSet
35-
- Unified AddUi methods
34+
- Now the Refresh method on the *UiPresenter* is public and can be called from any object that has asset to it. The *UiService* will not call this method anymore if trying to open the same *UiPresenter* twice without closing
35+
- *UiService.IsUiLoaded* changed to *HasUiPresenter*
36+
- *UiService.IsAllUiLoadedInSet* changed to *HasAllUiPresentersInSet*
37+
- Unified *AddUi* methods
3638

3739
**Fixed**:
38-
- Fixed bug that sometimes don't save the UiConfigs state correctly
40+
- Fixed bug that sometimes don't save the *UiConfigs* state correctly
3941

4042
## [0.1.3] - 2020-01-09
4143

4244
**Fixed**:
43-
- Bug that sometimes was not save+ing the UiConfigs state correctly
45+
- Bug that sometimes was not save+ing the *UiConfigs* state correctly
4446

4547
## [0.1.2] - 2020-01-09
4648

@@ -50,7 +52,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5052
## [0.1.1] - 2020-01-09
5153

5254
**Fixed**:
53-
- The state of a the UiPresenter when loaded. Now the UiPresenters are always disabled when loaded
55+
- The state of a the *UiPresenter* when loaded. Now the *UiPresenters* are always disabled when loaded
5456

5557
## [0.1.0] - 2020-01-05
5658

Runtime/GameLovers.UiService.asmdef

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"references": [
44
"GUID:84651a3751eca9349aac36a66bba901b",
55
"GUID:9e24947de15b9834991c9d8411ea37cf",
6-
"GUID:11ee0f4d04f11419d8a55b1b6d7c2c1d"
6+
"GUID:ebfc05ee5a737f94d8b07099524dab77"
77
],
88
"includePlatforms": [],
99
"excludePlatforms": [],

Runtime/UiService.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
4-
using GameLovers.LoaderExtension;
4+
using GameLovers.AssetLoader;
55
using UnityEngine;
6-
using UnityEngine.AddressableAssets;
7-
using UnityEngine.ResourceManagement.AsyncOperations;
86
using Object = UnityEngine.Object;
97

108
// ReSharper disable CheckNamespace
@@ -423,23 +421,15 @@ public async Task<T> LoadUiAsync<T>(bool openAfter = false) where T : UiPresente
423421
/// <inheritdoc />
424422
public async Task<UiPresenter> LoadUiAsync(Type type, bool openAfter = false)
425423
{
426-
if (!_uiConfigs.TryGetValue(type, out UiConfig config))
424+
if (!_uiConfigs.TryGetValue(type, out var config))
427425
{
428426
throw new KeyNotFoundException($"The UiConfig of type {type} was not added to the service. Call {nameof(AddUiConfig)} first");
429427
}
430428

431-
var operation = Addressables.InstantiateAsync(config.AddressableAddress);
432-
433-
await operation.Task;
434-
435-
if (operation.Status != AsyncOperationStatus.Succeeded)
436-
{
437-
throw operation.OperationException;
438-
}
439-
440-
var uiPresenter = operation.Result.GetComponent<UiPresenter>();
429+
var gameObject = await AssetLoaderService.InstantiatePrefabAsync(config.AddressableAddress);
430+
var uiPresenter = gameObject.GetComponent<UiPresenter>();
441431

442-
uiPresenter.gameObject.SetActive(false);
432+
gameObject.SetActive(false);
443433

444434
AddUi(uiPresenter, config.Layer, openAfter);
445435

@@ -457,8 +447,7 @@ public void UnloadUi(Type type)
457447
{
458448
var gameObject = RemoveUi(type).gameObject;
459449

460-
Addressables.ReleaseInstance(gameObject);
461-
Object.Destroy(gameObject);
450+
AssetLoaderService.UnloadAsset(gameObject);
462451
}
463452

464453
/// <inheritdoc />
@@ -664,7 +653,7 @@ public Task<Task<UiPresenter>>[] LoadUiSetAsync(int setId)
664653
uiTasks.Add(LoadUiAsync(set.UiConfigsType[i]));
665654
}
666655

667-
return LoaderUtil.Interleaved(uiTasks);
656+
return AssetLoaderService.Interleaved(uiTasks);
668657
}
669658

670659
/// <inheritdoc />

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "com.gamelovers.uiservice",
33
"displayName": "UiService",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
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.5.1"
8+
"com.unity.addressables": "1.6.0",
9+
"com.gamelovers.assetloader": "0.1.1"
910
},
1011
"type": "library",
1112
"hideInEditor": false

0 commit comments

Comments
 (0)