com.amanotes.themeengine
v1.2.2
Published
Theme management system with event-driven updates for sprites, text, and audio
Readme
ThemeEngine
Package: com.amanotes.themeengine
Version: 1.2.1
Event-driven theme management system for Unity. Change sprites, audio, text, colors, videos, and resource IDs at runtime with automatic UI updates.
Quick Start
1. Create a Theme Config
Right-click in Project → Create > ThemeEngine > Theme Config
Add your theme assets by key:
- Textures:
"background","button","icon" - Audio Clips:
"bgm","click_sound" - Text:
"title","score_label" - Videos:
"intro_video","background_video" - Colors:
"primary","accent" - Resource IDs:
"song_id","level_id"
2. Add Handler Components
ThemeSprite — auto-updates SpriteRenderer or Image:
- Add Component →
ThemeSprite - Assign ThemeConfig and key
ThemeHandler — generic handler for any asset type (sprite, text, audio, video, color):
- Add Component →
ThemeHandler - Assign ThemeConfig
- Add entries with keys and targets
ThemeBGVideo — video background with rhythm engine integration:
- Add Component →
ThemeBGVideo - Assign ThemeConfig, key, and VideoPlayer
3. Change Theme at Runtime
using Amanotes.Core;
[SerializeField] private ThemeConfig theme;
theme.SetText("title", "New Title");
theme.SetColor("primary", Color.red);
theme.SetResourceId("song_id", "song_123");
var color = theme.GetColorValue("primary", Color.white);
var text = theme.GetText("title")?.text;4. Listen to Changes
void OnEnable() => theme.OnAssetChanged += OnThemeChanged;
void OnDisable() => theme.OnAssetChanged -= OnThemeChanged;
void OnThemeChanged(string key, ThemeConfig.ThemeAsset asset)
{
if (key == "primary" && asset is ThemeConfig.ColorAsset color)
ApplyColor(color.value);
}WebGL Integration (SnapBeat)
Add ThemeCommandHandler to receive theme updates from web:
SetTexture(json)— downloads and applies texture by URLSetAudio(json)— downloads and applies audio clip by URLSetText(json)— sets text valueSetColor(json)— sets color from hex stringSetVideo(json)— sets video URLSetResourceId(json)— sets resource ID string
Components
| Component | Purpose |
|-----------|---------|
| ThemeConfig | ScriptableObject storing all theme data |
| ThemeHandler | Generic handler routing any asset to targets |
| ThemeSprite | Auto-updates SpriteRenderer/Image (tint + camera fit) |
| ThemeBGVideo | Video background with rhythm sync |
| ThemeCommandHandler | SnapBeat web bridge for remote theming |
| VideoFitCamera | Auto-fits video sprite to camera/rect |
Dependencies
- Unity 2022.3+
com.unity.nuget.newtonsoft-json3.0.0- (Optional)
com.amanotes.snapbeat— enables web bridge - (Optional)
com.amanotes.magictilescore— enables rhythm sync
Version History
See CHANGELOG.md
