training-academy/UNITY_MIGRATION_PLAN.md

6.4 KiB

Unity Migration Plan - Gooner Training Academy

🎯 Migration Priority: HIGH

Performance bottlenecks identified in multi-video system justify Unity migration


📊 Current Web Architecture Analysis

Media System Complexity (Primary Migration Driver):

  • QuadVideoPlayer: 4 simultaneous video streams with individual controls
  • OverlayVideoPlayer: Popup video system with full controls
  • FocusVideoPlayer: Minimal focus session player
  • BaseVideoPlayer: 400+ line shared video foundation
  • VideoPlayerManager: Centralized video orchestration
  • Real-time video management: Live switching, volume mixing, progress tracking

Web Performance Limitations:

  • HTML5 Video Limitations: Browser video element limitations with 4+ simultaneous streams
  • CSS Animation Overhead: Synthwave effects causing repainting issues
  • DOM Complexity: Heavy video DOM manipulation and control overlays
  • Memory Management: No fine-grained video memory control in web
  • GPU Utilization: Limited GPU optimization in browser context

🎮 Unity Architecture Design

Phase 1: Core Video Engine (Month 1)

// Unity Video Architecture
VideoManager {
    - QuadVideoDisplay (4 RenderTextures)
    - OverlayVideoSystem (UI Canvas overlay)
    - FocusVideoPlayer (minimal UI)
    - VideoLibraryManager (asset streaming)
    - PerformanceProfiler (frame rate monitoring)
}

// Video Performance Optimization
- Native video decoding (AVPro or Unity VideoPlayer)
- GPU texture streaming for multiple videos
- Memory pooling for video assets
- Async video loading with progress tracking
- Hardware-accelerated video compositing

Phase 2: Game Logic Port (Month 2)

// Core Game Systems
TaskChallengeGame {
    - GameStateManager (JSON persistence)
    - GameModeManager (scenario handling)
    - ProgressionSystem (statistics & achievements)
    - EventSystem (task completion, timers)
}

// Data Architecture
- ScriptableObject-based game data
- JSON import/export for web compatibility  
- Event-driven architecture for loose coupling
- Modular game mode system

Phase 3: Advanced Features (Month 3)

// Unity-Specific Enhancements
- 3D UI elements (rotating panels, depth-based layouts)
- Particle effects for rewards/achievements
- Advanced audio mixing (Unity AudioMixer)
- VR/AR readiness (future expansion)
- Console platform support
- Advanced input handling (gamepads, touch)

🚀 Migration Strategy: Modular Approach

Week 1-2: Video System Proof of Concept

  1. Unity Project Setup: 2022.3 LTS with Video packages
  2. Basic Video Player: Single video with controls in Unity UI
  3. Quad Layout Test: 4 videos rendering to RenderTextures
  4. Performance Baseline: Frame rate testing vs web version

Week 3-4: Core Video Features

  1. Video Library Integration: File system scanning in Unity
  2. Control Systems: Play/pause, volume, progress for each video
  3. Video Switching: Smooth transitions between videos
  4. Memory Management: Proper video asset loading/unloading

Week 5-6: Game Logic Foundation

  1. Data Layer: Game state, progression, statistics
  2. Event System: Task completion, mode switching
  3. UI Framework: Menus, modals, notifications
  4. Settings System: User preferences and configuration

Week 7-8: Feature Parity

  1. Game Modes: Port all game scenarios and rules
  2. Audio Integration: Background music and TTS
  3. Image Systems: Task images and consequences
  4. Save/Load: Complete persistence system

🔧 Technical Architecture

Unity Package Requirements:

- Video Player (built-in)
- AVPro Video (optional, for advanced codec support)
- TextMeshPro (UI text rendering)
- JSON.NET (for data serialization)
- Modern UI Pack (optional, for polished UI)

Performance Targets:

  • 60+ FPS with 4 simultaneous videos
  • <2GB RAM usage for video streaming
  • <100ms video switching latency
  • <5 second cold startup time

Cross-Platform Strategy:

Primary: Windows (PC)
Secondary: macOS, Linux (desktop expansion)
Future: Android/iOS (mobile adaptation)
Long-term: VR platforms (Quest, PCVR)

📋 Migration Phases

Phase 1: Video Engine (Priority 1)

Goal: Solve performance bottlenecks with native video processing

  • Multi-video rendering system
  • GPU-optimized video playback
  • Advanced video controls and overlays
  • Success Metric: 4 videos @ 60fps consistently

Phase 2: Game Logic (Priority 2)

Goal: Feature parity with web version

  • Complete game mechanics port
  • Data persistence and statistics
  • All game modes and scenarios
  • Success Metric: 100% feature parity

Phase 3: Unity Enhancements (Priority 3)

Goal: Leverage Unity-specific features

  • 3D UI elements and effects
  • Advanced audio systems
  • Platform-specific optimizations
  • Success Metric: Enhanced user experience beyond web

🎯 Decision Matrix

Migrate Now If:

  • Video performance continues to degrade
  • Need for mobile/console platforms
  • Want advanced 3D UI effects
  • Development team ready to learn Unity/C#

Stay Web If:

  • Performance issues can be web-optimized
  • Rapid iteration is more important
  • Team lacks Unity expertise
  • Web-first distribution is critical

💡 Immediate Actions

This Week:

  1. Performance Test Current Fixes: Validate if CSS optimizations resolve issues
  2. Unity Learning: Install Unity 2022.3 LTS and test basic video playback
  3. Architecture Planning: Design Unity class structure based on current system
  4. Team Preparation: Begin Unity/C# learning if needed

Next Week:

  1. Unity Prototype: Build minimal 4-video system in Unity
  2. Performance Comparison: Direct fps comparison web vs Unity
  3. Migration Timeline: Finalize timeline based on prototype results
  4. Resource Planning: Assess development time and learning curve

🏁 Recommendation: START UNITY MIGRATION

The media system complexity and performance requirements justify Unity migration now rather than later. The modular web architecture will translate well to Unity, and the advanced video processing capabilities will solve current bottlenecks.

Timeline: 2-3 months for full migration with enhanced features