F8 Download

March 27, 2026 · View on GitHub

license Unity Version Platform

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

Unity F8 Download Component

  • Supports file downloads from both localhost and HTTP sources
  • Local file writing
  • Download progress monitoring
  • Resumable transfers
  • Dynamic management (add/remove/pause/resume downloads)

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

private string[] fileInfos = new[]
{
    "https://raw.githubusercontent.com/TippingGame/F8Framework/refs/heads/main/Tests/Logo.png"
};

private Downloader downloader;

void Start()
{
    // Create downloader instance
    downloader = FF8.Download.CreateDownloader("Download", new Downloader());

    // Set timeout (default: no timeout)
    downloader.DownloadTimeout = 30; // seconds
    
    // Configure event handlers
    downloader.OnDownloadSuccess += OnDownloadSuccess;
    downloader.OnDownloadFailure += OnDownloadFailure;
    downloader.OnDownloadStart += OnDownloadStart;
    downloader.OnDownloadOverallProgress += OnDownloadOverall;
    downloader.OnAllDownloadTaskCompleted += OnDownloadFinish;
    
    int count = 0;
    // Add download tasks
    foreach (var fileInfo in fileInfos)
    {
        count++;
        // Get existing file size for resume support (optional)
        FileInfo file = new FileInfo(Application.persistentDataPath + "F8Download/download" + count + ".png");
        long fileSizeInBytes = file.Length;
        downloader.AddDownload(
            fileInfo, 
            Application.persistentDataPath + "F8Download/download" + count + ".png",
            fileSizeInBytes,
            true
        );
    }
    
    // Start download process
    downloader.LaunchDownload();
    
    // Get remote file size (Note: Some downloads may not report total size upfront)
    FF8.Download.GetUrlFilesSizeAsync("", size => LogF8.Log(size));
    
    // Cancel all downloads
    downloader.CancelDownload();
}

// Download started callback
void OnDownloadStart(DownloadStartEventArgs eventArgs)
{
    LogF8.Log(eventArgs.DownloadInfo.DownloadUrl);
}

// Progress update callback
void OnDownloadOverall(DonwloadUpdateEventArgs eventArgs)
{
    // Some download tasks only have download URLs and cannot obtain the binary length, 
    // making it impossible to use more precise progress tracking.
    float currentTaskIndex = (float)eventArgs.CurrentDownloadTaskIndex;
    float taskCount = (float)eventArgs.DownloadTaskCount;

    // Calculate progress percentage
    float progress = currentTaskIndex / taskCount * 100f;
    
    // Downloaded size (bytes)
    long downloadedBytes = eventArgs.TotalDownloadedLength;
    
    // Download speed calculation (bytes/second)
    double speedBytesPerSecond = eventArgs.DownloadInfo.DownloadedLength / eventArgs.DownloadInfo.DownloadTimeSpan.TotalSeconds;
    
    // Unit conversion: bytes → MB
    double downloadedMB = downloadedBytes / (1024.0 * 1024.0);
    double speedMBPerSecond = speedBytesPerSecond / (1024.0 * 1024.0);
    
    // Log output: Progress and speed
    LogF8.Log($"Progress: {downloadedMB:F2}MB, Speed: {speedMBPerSecond:F2}MB/s");
}

// Download success callback
void OnDownloadSuccess(DownloadSuccessEventArgs eventArgs)
{
    LogF8.Log($"DownloadSuccess {eventArgs.DownloadInfo.DownloadUrl}");
}

// Download failure callback
void OnDownloadFailure(DownloadFailureEventArgs eventArgs)
{
    LogF8.LogError($"DownloadFailure {eventArgs.DownloadInfo.DownloadUrl}\n{eventArgs.ErrorMessage}");
}

// All downloads completed
void OnDownloadFinish(DownloadTasksCompletedEventArgs eventArgs)
{
    LogF8.Log($"DownloadFinish - Total duration: {eventArgs.TimeSpan}");
}