Note: This guide contains step-by-step instructions for setting up the enhanced UI features.
-
Create the Theme Manager:
- In Unity Hierarchy, right-click โ Create Empty
- Name it "UIThemeManager"
- Add Component โ Scripts โ UI โ UIThemeManager
-
Assign UI Elements:
- In Inspector, find the UIThemeManager component
- Drag your UI elements into the appropriate lists:
- Background Elements: Main background panels
- Primary Elements: Main buttons, important panels
- Secondary Elements: Secondary buttons, info panels
- Accent Elements: Highlight elements, special buttons
- Text Elements: Main text (titles, scores)
- Secondary Text Elements: Descriptions, hints
-
Choose a Theme:
- In UIThemeManager Inspector, select colors or use presets
- Play mode to see live updates
- Call
UIThemeManager.instance.SetThemePreset()from code to switch themes
-
Add to UI Element:
- Select button, panel, or any UI element
- Add Component โ Scripts โ UI โ UIAnimator
-
Configure Animation:
- Animation Type: Choose effect (Scale, Fade, ScaleAndFade, Position, All)
- Animation Duration: 0.3 seconds recommended
- Animate On Enable: Check for automatic animation
- Loop Animation: Check for continuous effects
-
Fine-tune:
- Adjust Start/End Scale for size effects
- Adjust Start/End Alpha for fade effects
- Use Animation Curve for custom timing
-
Add to Button:
- Select existing Button GameObject
- Add Component โ Scripts โ UI โ EnhancedButton
-
Configure Effects:
- โ Enable Hover Effect
- โ Enable Click Effect
- โ Enable Ripple Effect (optional, requires ripple prefab)
- Set Hover Scale: 1.05
- Set Click Scale: 0.95
-
Add Audio (optional):
- Assign Hover Sound clip
- Assign Click Sound clip
- Set Volume: 1.0
-
Advanced:
- Create ripple prefab (Image with transparent white)
- Assign Ripple Prefab for ripple effects
- Assign Click Particle Prefab for particles on click
-
Create Score Display:
- In scene with GameState, find score UI
- Add Component โ Scripts โ UI โ EnhancedScoreDisplay
-
Assign References:
- Score Text: Main score text component
- Multiplier Text: Multiplier display text
- Combo Text: Combo counter text
- Combo Fill Bar: Optional progress bar image
-
Configure Settings:
- Score Animation Speed: 2.0
- Pop Scale: 1.2
- Pop Duration: 0.2
- Set combo thresholds and messages
-
Integrate with Game:
// In your game code: EnhancedScoreDisplay scoreDisplay = FindObjectOfType<EnhancedScoreDisplay>(); scoreDisplay.AddScore(100); scoreDisplay.SetMultiplier(2); scoreDisplay.IncrementCombo();
-
Create Manager:
- Create Empty GameObject named "ParticleEffectManager"
- Add Component โ Scripts โ ParticleEffectManager
-
Assign Prefabs:
- Create or assign particle effect prefabs:
- Coin Collect Effect
- Powerup Effect
- Obstacle Hit Effect
- Level Up Effect
- Combo Effect
- Create or assign particle effect prefabs:
-
Configure Pool:
- Pool Size: 20 (default, adjust based on needs)
-
Use in Code:
ParticleEffectManager.instance.PlayCoinCollectEffect(transform.position); ParticleEffectManager.instance.PlayPowerupEffect(transform.position);
- Modern (Default) - Blue/Purple/Orange
- Sunset - Warm orange/pink/yellow
- Ocean - Cool blue/teal
- Forest - Green/yellow nature
- Neon - Cyberpunk high-contrast
// From any script:
UIThemeManager.instance.SetThemePreset(UIThemeManager.ThemePreset.Neon);// On your menu button GameObject:
// 1. Add EnhancedButton component
// 2. Add UIAnimator component
// 3. Configure UIAnimator:
// - Type: ScaleAndFade
// - Animate On Enable: true
// - Duration: 0.3
// 4. Configure EnhancedButton:
// - Enable all effects
// - Assign audio clipspublic class GameController : MonoBehaviour
{
private EnhancedScoreDisplay scoreDisplay;
void Start()
{
scoreDisplay = FindObjectOfType<EnhancedScoreDisplay>();
}
void OnCoinCollected(Vector3 position)
{
scoreDisplay.AddScore(10);
scoreDisplay.IncrementCombo();
ParticleEffectManager.instance.PlayCoinCollectEffect(position);
}
}public void OnThemeButtonClicked(int themeIndex)
{
UIThemeManager.ThemePreset preset = (UIThemeManager.ThemePreset)themeIndex;
UIThemeManager.instance.SetThemePreset(preset);
// Save preference
PlayerPrefs.SetInt("SelectedTheme", themeIndex);
}-
Particle Effects:
- Use object pooling (already implemented)
- Adjust pool size based on your needs
- Disable effects not in use
-
UI Animations:
- Limit simultaneous animations to 10-15
- Use simple animation curves
- Disable loop animations when off-screen
-
Theme Manager:
- Register elements once at start
- Avoid frequent theme switching during gameplay
- Use cached references
- Solution: Increase
transitionSpeedor adjustanimationDuration
- Solution: Ensure Button component exists and is enabled
- Solution: Call
ApplyTheme()after changing colors manually
- Solution: Check prefab assignments and ensure ParticleSystem component exists
For mobile devices:
- Reduce particle count in prefabs
- Lower pool sizes (10-15 instead of 20)
- Simplify animation curves
- Use fewer simultaneous animations
- Disable pulse animations if needed
- โ Setup UIThemeManager in your main menu scene
- โ Add EnhancedButton to all buttons
- โ Setup EnhancedScoreDisplay in game scene
- โ Create particle effect prefabs
- โ Test theme switching
- โ Integrate with existing game logic
- Check the IMPROVEMENTS.md file for detailed documentation
- Review the XML comments in each script
- Test in Play mode to see effects in action
- Check Unity Console for any error messages
Estimated Setup Time: 20-30 minutes total Difficulty: Beginner-friendly Unity Version: 2019.3+