Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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.2.1] - 2025-11-02

**New**:
- Added the *TryGetConfig* for requesting singleton configs from the *ConfigProvider*.

## [0.2.0] - 2025-09-24

**New**:
Expand Down
10 changes: 8 additions & 2 deletions Runtime/ConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ public bool TryGetConfig<T>(int id, out T config)
}

/// <inheritdoc />
public T GetConfig<T>()
public bool TryGetConfig<T>(out T config)
{
var dictionary = GetConfigsDictionary<T>();

if (!dictionary.TryGetValue(_singleConfigId, out var config))
return dictionary.TryGetValue(_singleConfigId, out config);
}

/// <inheritdoc />
public T GetConfig<T>()
{
if (!TryGetConfig<T>(out var config))
{
throw new InvalidOperationException($"The Config container for {typeof(T)} is not a single config container. " +
$"Use either 'GetConfig<T>(int id)' or 'GetConfigsList<T>()' to get your needed config");
Expand Down
6 changes: 6 additions & 0 deletions Runtime/IConfigsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public interface IConfigsProvider
/// </summary>
bool TryGetConfig<T>(int id, out T config);

/// <summary>
/// Requests the single unique Config of <typeparamref name="T"/> type.
/// Returns true if there is a <paramref name="config"/> of <typeparamref name="T"/> type, false otherwise.
/// </summary>
bool TryGetConfig<T>(out T config);

/// <summary>
/// Requests the single unique Config of <typeparamref name="T"/> type
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.gamelovers.configsprovider",
"displayName": "Configs Provider",
"author": "Miguel Tomas",
"version": "0.2.0",
"version": "0.2.1",
"unity": "6000.0",
"license": "MIT",
"type": "library",
Expand Down
Loading