Skip to content

Commit

Permalink
Added public API in ColorBinder
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanMurzak committed Jul 26, 2024
1 parent 9344975 commit 7aaef85
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
11 changes: 11 additions & 0 deletions Assets/_PackageRoot/Scripts/Binders/BaseColorBinder.Public.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7aaef85

Please sign in to comment.