F8 Timer

January 5, 2026 · View on GitHub

license Unity Version Platform

Introduction (Simply press F8 to start game development without distractions)

Unity F8 Timer Component
Timing system providing both time-based and frame-based counters with full lifecycle management.

  • Timer Types:
    • Timer: Real-time seconds counter
    • FrameTimer: Frame-based counter

Plugin Installation (Requires Core Framework First)

Note! Built into → F8Framework Core: https://github.com/TippingGame/F8Framework.git
Method 1: Download files directly and import to Unity
Method 2: Unity → Menu Bar → Window → Package Manager → "+" → Add Package from git URL → Enter: https://github.com/TippingGame/F8Framework.git

Code Examples

void Start()
{
    // Normal Timer: pass 'this' as context, executes every 1 second, 
    // starts after 0 seconds delay, repeats 3 times (-1 means infinite loop)
    int timeid = FF8.Timer.AddTimer(this, 1f, 0f, 3,
        () => { LogF8.Log("tick"); },
        () => { LogF8.Log("completed"); },
        ignoreTimeScale: false);

    // Extension methods
    FF8.Timer.AddTimer(1f, () => { });
    FF8.Timer.AddTimer(1f, false, () => { });
    FF8.Timer.AddTimer(1f, 1, () => { }, () => { });

    // Frame Timer: pass 'this' as context, executes every 1 frame,
    // starts after 0 frames delay, loops infinitely (-1 means infinite loop)
    timeid = FF8.Timer.AddTimerFrame(this, 1f, 0f, -1,
        () => { LogF8.Log("tick"); },
        () => { LogF8.Log("completed"); },
        ignoreTimeScale: false);
    
    // Extension methods
    FF8.Timer.AddTimerFrame(1f, () => { });
    FF8.Timer.AddTimerFrame(1f, false, () => { });
    FF8.Timer.AddTimerFrame(1f, 1, () => { }, () => { });
    // More expansion methods
    this.AttachTimerF8(1f, () => { }, () => { }, false);
    this.DelayTimerF8(1f, () => { });
    this.IntervalTimerF8(1f, () => { });
    this.RepeatTimerF8(1f, 5, () => { });
    this.UntilTimerF8(1f,  () => true, () => { });

    // Stop the timer with the specified timeid
    FF8.Timer.RemoveTimer(timeid);

    // Listen for application focus events to automatically pause/resume all timers
    FF8.Timer.AddListenerApplicationFocus();

    // Manually pause or resume all timers (or specific timer by id)
    FF8.Timer.Pause();
    FF8.Timer.Resume();
    // Restart all timers (or specific timer by id)
    FF8.Timer.Restart();

    // For online games: sync with server time (unit: milliseconds)
    FF8.Timer.SetServerTime(1702573904000);
    FF8.Timer.GetServerTime();

    // Get total elapsed time in the game
    FF8.Timer.GetTime();
}

Automatic Window Focus Handling with OnApplicationFocus, Pause all timers