From 7aaef85dc3c5552f60dd0b7b7a1d0de296f3eccd Mon Sep 17 00:00:00 2001 From: Ivan Murzak Date: Thu, 25 Jul 2024 20:34:21 -0700 Subject: [PATCH] Added public API in ColorBinder --- .../Scripts/Binders/BaseColorBinder.Public.cs | 23 +++++++++++++++++++ .../Binders/BaseColorBinder.Public.cs.meta | 11 +++++++++ 2 files changed, 34 insertions(+) create mode 100644 Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs create mode 100644 Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs.meta diff --git a/Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs b/Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs new file mode 100644 index 0000000..921417e --- /dev/null +++ b/Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +namespace Unity.Theme.Binders +{ + public abstract partial class BaseColorBinder : MonoBehaviour + { + public bool SetColorByName(string name) => SetColor(Theme.Instance?.GetColorByName(name)); + public bool SetColorByGuid(string colorGuid) => SetColor(Theme.Instance?.GetColorByGuid(colorGuid)); + public bool SetColor(ColorDataRef colorData) => SetColorByGuid(colorData.Guid); + public bool SetColor(ColorData colorData) + { + if (colorData == null) + { + if (Theme.Instance?.debugLevel <= DebugLevel.Error) + Debug.LogError($"Color is null. Can't set it as a color for the binder", gameObject); + return false; + } + data.colorGuid = colorData.Guid; + SetColor(GetColor(colorData)); + return true; + } + } +} \ No newline at end of file diff --git a/Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs.meta b/Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs.meta new file mode 100644 index 0000000..202110d --- /dev/null +++ b/Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c7cda860638b7146ba33d441f5a7c95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: