Skip to content

Commit 11a8bbf

Browse files
Merge pull request #4 from CoderGamester/develop
Release 0.2.1
2 parents 29f2911 + fbf3eac commit 11a8bbf

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ 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.2.1] - 2025-11-02
8+
9+
**New**:
10+
- Added the *TryGetConfig* for requesting singleton configs from the *ConfigProvider*.
11+
712
## [0.2.0] - 2025-09-24
813

914
**New**:

Runtime/ConfigProvider.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ public bool TryGetConfig<T>(int id, out T config)
2929
}
3030

3131
/// <inheritdoc />
32-
public T GetConfig<T>()
32+
public bool TryGetConfig<T>(out T config)
3333
{
3434
var dictionary = GetConfigsDictionary<T>();
3535

36-
if (!dictionary.TryGetValue(_singleConfigId, out var config))
36+
return dictionary.TryGetValue(_singleConfigId, out config);
37+
}
38+
39+
/// <inheritdoc />
40+
public T GetConfig<T>()
41+
{
42+
if (!TryGetConfig<T>(out var config))
3743
{
3844
throw new InvalidOperationException($"The Config container for {typeof(T)} is not a single config container. " +
3945
$"Use either 'GetConfig<T>(int id)' or 'GetConfigsList<T>()' to get your needed config");

Runtime/IConfigsProvider.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ public interface IConfigsProvider
2222
/// </summary>
2323
bool TryGetConfig<T>(int id, out T config);
2424

25+
/// <summary>
26+
/// Requests the single unique Config of <typeparamref name="T"/> type.
27+
/// Returns true if there is a <paramref name="config"/> of <typeparamref name="T"/> type, false otherwise.
28+
/// </summary>
29+
bool TryGetConfig<T>(out T config);
30+
2531
/// <summary>
2632
/// Requests the single unique Config of <typeparamref name="T"/> type
2733
/// </summary>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.gamelovers.configsprovider",
33
"displayName": "Configs Provider",
44
"author": "Miguel Tomas",
5-
"version": "0.2.0",
5+
"version": "0.2.1",
66
"unity": "6000.0",
77
"license": "MIT",
88
"type": "library",

0 commit comments

Comments
 (0)