Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1685a4f
Add RendererColorBinder to bind theme colors to a Renderer's material…
IvanMurzak Nov 24, 2025
9aa603c
Add MeshRendererColorBinder to bind theme colors to a MeshRenderer's …
IvanMurzak Nov 24, 2025
d704012
Add LineRendererColorBinder to bind theme colors to a LineRenderer's …
IvanMurzak Nov 24, 2025
5d93adc
Update TextMeshProColorBinder to use TMP_Text and adjust MCP connecti…
IvanMurzak Nov 24, 2025
a2455d9
Refactor tests to use TMP_Text instead of TextMeshProUGUI for color b…
IvanMurzak Nov 24, 2025
5f0ed22
Add GenericRendererColorBinder and related binders for theme color ma…
IvanMurzak Nov 24, 2025
ad91631
Add SkinnedMeshRendererColorBinder to bind theme colors to SkinnedMes…
IvanMurzak Nov 24, 2025
d2d9d62
Update README to include new color binders: Shadow, Outline, Renderer…
IvanMurzak Nov 24, 2025
dea395d
Update Unity-Theme/Assets/root/Scripts/Binders/LineRendererColorBinde…
IvanMurzak Nov 24, 2025
b656b91
Update Unity-Theme/Assets/root/Scripts/Binders/Base/GenericRendererCo…
IvanMurzak Nov 24, 2025
e88393f
Merge branch 'feature/material-color-binder' of https://github.com/Iv…
IvanMurzak Nov 24, 2025
fbd9191
Refactor GenericRendererColorBinder to use sharedMaterial instead of …
IvanMurzak Nov 24, 2025
06bb263
Add LightColorBinder class for binding color to Light components
IvanMurzak Nov 24, 2025
499acf6
Add required color binder classes for various Unity components
IvanMurzak Nov 24, 2025
c59006e
Refactor code structure for improved readability and maintainability
IvanMurzak Nov 24, 2025
0441e9e
Create settings.local.json
IvanMurzak Nov 24, 2025
91c5f83
Merge branch 'main' into feature/material-color-binder
IvanMurzak Nov 24, 2025
49d23ac
Fix color setting logic in GenericRendererColorBinder to validate col…
IvanMurzak Nov 24, 2025
57a2d70
Apply suggestions from code review
IvanMurzak Nov 24, 2025
773911e
Add XML documentation for color binder classes
IvanMurzak Nov 24, 2025
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
10 changes: 10 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"permissions": {
"allow": [
"Bash(if not exist \"c:\\Projects\\Unity\\Unity-Theme\\docs\" mkdir \"c:\\Projects\\Unity\\Unity-Theme\\docs\")",
"Bash(mkdir:*)"
],
"deny": [],
"ask": []
}
}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ There is a list of built-in color binders:
- ✔️ Light
- ✔️ Image
- ✔️ Button
- ✔️ Shadow
- ✔️ Toggle
- ✔️ Material
- ✔️ Outline
- ✔️ Renderer
- ✔️ Selectable
- ✔️ TextMeshPro
- ✔️ LineRenderer
- ✔️ MeshRenderer
- ✔️ SpriteRenderer
- ✔️ SkinnedMeshRenderer
- ✔️ SpriteShapeRenderer

![Unity-Theme-Binder](https://github.com/IvanMurzak/Unity-Theme/assets/9135028/6198af48-9f0e-4cda-b5e9-40508bbd5c45)

Expand Down
11 changes: 11 additions & 0 deletions Unity-Theme/.claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"permissions": {
"allow": [
"Bash(gh pr list:*)",
"Bash(gh pr view:*)",
"Bash(gh pr diff:*)"
],
"deny": [],
"ask": []
}
}
5 changes: 4 additions & 1 deletion Unity-Theme/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,7 @@ crashlytics-build.properties

# Appodeal
/Assets/Appodeal/**
/Assets/Appodeal.meta
/Assets/Appodeal.meta

# MCP Servers
.vscode/mcp.json
4 changes: 2 additions & 2 deletions Unity-Theme/Assets/Resources/Unity-MCP-ConnectionConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"EnabledResources": [
"*"
],
"Host": "http://localhost:8080",
"Host": "http://localhost:10088",
"TimeoutMs": 10000,
"KeepConnected": false
"KeepConnected": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using UnityEngine;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds theme colors to a Renderer's material color
/// Supports binding the main material color property or a custom shader property
/// </summary>
public abstract class GenericRendererColorBinder<T> : GenericMultiColorBinder<T> where T : Renderer
{
// Color entry index for material's main color
protected const int MATERIAL_COLOR_INDEX = 0;

[SerializeField]
[Tooltip("Enable to use a custom material property name instead of the default color property")]
protected bool useCustomProperty = false;

[SerializeField]
[Tooltip("Custom shader property name to bind the color to (e.g., '_BaseColor', '_EmissionColor')")]
protected string customMaterialColorProperty = "_Color";

/// <summary>
/// Defines the color entry labels for Renderer's material
/// </summary>
protected override string[] ColorEntries => new string[]
{
"Material Color"
};

protected override void SetColors(T targetComponent, Color[] colors)
{
if (colors == null || colors.Length <= MATERIAL_COLOR_INDEX)
{
LogError("Invalid colors array provided to SetColors.");
return;
}
if (targetComponent.material != null)
{
if (useCustomProperty && !string.IsNullOrEmpty(customMaterialColorProperty))
{
targetComponent.material.SetColor(customMaterialColorProperty, colors[MATERIAL_COLOR_INDEX]);
}
else
{
targetComponent.material.color = colors[MATERIAL_COLOR_INDEX];
}
}
}

protected override Color[] GetColors(T target)
{
if (target.sharedMaterial != null)
{
Color color;
color = (useCustomProperty && !string.IsNullOrEmpty(customMaterialColorProperty))
? (target.sharedMaterial.HasProperty(customMaterialColorProperty)
? target.sharedMaterial.GetColor(customMaterialColorProperty)
: Color.white)
: target.sharedMaterial.color;

return new Color[] { color };
}

return new Color[] { Color.white };
}
}
}

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

3 changes: 1 addition & 2 deletions Unity-Theme/Assets/root/Scripts/Binders/ButtonColorBinder.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using UnityEngine;
using UnityEngine.UI;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds theme colors to a Unity Button's ColorBlock
/// Supports binding all 5 button states: Normal, Highlighted, Pressed, Selected, and Disabled
/// </summary>
[RequireComponent(typeof(Button))]
[AddComponentMenu("Theme/Button Color Binder")]
public class ButtonColorBinder : SelectableColorBinder
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using UnityEngine;
using UnityEngine.UI;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds theme colors to a Unity Button's ColorBlock
/// Supports binding all 5 button states: Normal, Highlighted, Pressed, Selected, and Disabled
/// Requires a Button component to be present
/// </summary>
[RequireComponent(typeof(Button))]
[AddComponentMenu("Theme/Button Color Binder (Required)")]
public class ButtonColorBinderRequired : ButtonColorBinder
{
}
}

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

3 changes: 3 additions & 0 deletions Unity-Theme/Assets/root/Scripts/Binders/ImageColorBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds a theme color to the Image component's color property.
/// </summary>
[AddComponentMenu("Theme/Image Color Binder")]
public class ImageColorBinder : GenericColorBinder<Image>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using UnityEngine;
using UnityEngine.UI;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds a theme color to the Image component's color property.
/// Requires an Image component to be attached to the GameObject.
/// </summary>
[RequireComponent(typeof(Image))]
[AddComponentMenu("Theme/Image Color Binder (Required)")]
public class ImageColorBinderRequired : ImageColorBinder
{
}
}

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

17 changes: 17 additions & 0 deletions Unity-Theme/Assets/root/Scripts/Binders/LightColorBinder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using UnityEngine;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds theme colors to a Light's color.
/// </summary>
[AddComponentMenu("Theme/Light Color Binder")]
public class LightColorBinder : GenericColorBinder<Light>
{
protected override void SetColor(Light target, Color color)
=> target.color = color;

protected override Color? GetColor(Light target)
=> target.color;
}
}
11 changes: 11 additions & 0 deletions Unity-Theme/Assets/root/Scripts/Binders/LightColorBinder.cs.meta

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using UnityEngine;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds a theme color to the Light component's color property.
/// This "Required" variant enforces the presence of a Light component.
/// </summary>
[RequireComponent(typeof(Light))]
[AddComponentMenu("Theme/Light Color Binder (Required)")]
public class LightColorBinderRequired : LightColorBinder
{
}
}

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

40 changes: 40 additions & 0 deletions Unity-Theme/Assets/root/Scripts/Binders/LineRendererColorBinder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using UnityEngine;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds theme colors to a LineRenderer's color.
/// Supports binding separate start and end colors.
/// </summary>
[AddComponentMenu("Theme/LineRenderer Color Binder")]
public class LineRendererColorBinder : GenericMultiColorBinder<LineRenderer>
{
// Color entry indices for LineRenderer
private const int START_INDEX = 0;
private const int END_INDEX = 1;

/// <summary>
/// Defines the color entry labels for LineRenderer's color properties
/// </summary>
protected override string[] ColorEntries => new string[]
{
"Start",
"End"
};

protected override void SetColors(LineRenderer targetComponent, Color[] colors)
{
targetComponent.startColor = colors[START_INDEX];
targetComponent.endColor = colors[END_INDEX];
}

protected override Color[] GetColors(LineRenderer targetComponent)
{
return new Color[]
{
targetComponent.startColor,
targetComponent.endColor
};
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using UnityEngine;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds theme colors to a LineRenderer's color.
/// Supports binding separate start and end colors.
/// Requires a LineRenderer component to be present
/// </summary>
[RequireComponent(typeof(LineRenderer))]
[AddComponentMenu("Theme/LineRenderer Color Binder (Required)")]
public class LineRendererColorBinderRequired : LineRendererColorBinder
{
}
}

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

13 changes: 13 additions & 0 deletions Unity-Theme/Assets/root/Scripts/Binders/MeshRendererColorBinder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using UnityEngine;

namespace Unity.Theme.Binders
{
/// <summary>
/// Binds theme colors to a MeshRenderer's material color
/// Supports binding the main material color property or a custom shader property
/// </summary>
[AddComponentMenu("Theme/MeshRenderer Color Binder")]
public class MeshRendererColorBinder : GenericRendererColorBinder<MeshRenderer>
{
}
}

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

Loading
Loading