diff --git a/CHANGELOG.md b/CHANGELOG.md index f3afb3c..cd4e1e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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**: diff --git a/Runtime/ConfigProvider.cs b/Runtime/ConfigProvider.cs index 37662cd..8d8f2b4 100644 --- a/Runtime/ConfigProvider.cs +++ b/Runtime/ConfigProvider.cs @@ -29,11 +29,17 @@ public bool TryGetConfig(int id, out T config) } /// - public T GetConfig() + public bool TryGetConfig(out T config) { var dictionary = GetConfigsDictionary(); - if (!dictionary.TryGetValue(_singleConfigId, out var config)) + return dictionary.TryGetValue(_singleConfigId, out config); + } + + /// + public T GetConfig() + { + if (!TryGetConfig(out var config)) { throw new InvalidOperationException($"The Config container for {typeof(T)} is not a single config container. " + $"Use either 'GetConfig(int id)' or 'GetConfigsList()' to get your needed config"); diff --git a/Runtime/IConfigsProvider.cs b/Runtime/IConfigsProvider.cs index 60de6cf..c045a5a 100644 --- a/Runtime/IConfigsProvider.cs +++ b/Runtime/IConfigsProvider.cs @@ -22,6 +22,12 @@ public interface IConfigsProvider /// bool TryGetConfig(int id, out T config); + /// + /// Requests the single unique Config of type. + /// Returns true if there is a of type, false otherwise. + /// + bool TryGetConfig(out T config); + /// /// Requests the single unique Config of type /// diff --git a/package.json b/package.json index 76edff2..46dad6c 100644 --- a/package.json +++ b/package.json @@ -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",