Skip to content

Commit 9fdcb39

Browse files
authored
Add AlphaBlend tint mode to TintEffect (#1131)
* Add AlphaBlend * Update CHANGELOG.md
1 parent 8735060 commit 9fdcb39

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

org.mixedrealitytoolkit.uxcore/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
44

55
## Unreleased
66

7+
### Added
8+
9+
* Added `AlphaBlend` tint mode to `TintEffect`. [PR #1131](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1131)
10+
711
### Fixed
812

913
* Fixed "leaked managed shell" issue in `UGUIInputAdapter`. [PR #1096](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1096)

org.mixedrealitytoolkit.uxcore/StateVisualizer/Effects/TintEffect.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ public override void PrepareFrame(Playable playable, FrameData info)
132132
{
133133
ApplyColor(startColors[i], tintables[i]);
134134
}
135-
136135
}
137136

138137
/// <inheritdoc />
@@ -162,6 +161,12 @@ public override void ProcessFrame(Playable playable, FrameData info, object play
162161
{
163162
targetColor = currentColor * TintColor;
164163
}
164+
else if (BlendMode == BlendType.AlphaBlend)
165+
{
166+
// Simulate layering a transparent color over the current color
167+
targetColor = Color.Lerp(currentColor, TintColor, TintColor.a);
168+
targetColor.a = currentColor.a; // Preserve the graphic's original overall opacity
169+
}
165170
else
166171
{
167172
targetColor = TintColor;
@@ -191,7 +196,12 @@ internal enum BlendType
191196
/// <summary>
192197
/// Multiply the tint color onto the existing color stack.
193198
/// </summary>
194-
Multiply
199+
Multiply,
200+
201+
/// <summary>
202+
/// Alpha-blends the tint color onto the existing color stack using the tint color's alpha value.
203+
/// </summary>
204+
AlphaBlend
195205
}
196206

197207
[SerializeField]

0 commit comments

Comments
 (0)