docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Deduplicate reference images

    To reduce storage space, replace duplicate reference images with a single image. For example when different platform tests have the same reference image.

    Follow these steps:

    1. To open the Graphics Tests window, select Window > General > Graphics Tests.
    2. Select Optimize Images.

    Unity compares reference images for each test across all platform directories. If two or more images are identical, Unity keeps one version and deletes the others, then moves the single remaining version to the shared Assets/ReferenceImagesBase folder in the Project window.

    The deleted files don't affect tests, because tests check both platform-specific folders and Assets/ReferenceImagesBase for reference images.

    Deduplicate automatically

    To optimize automatically when there's a change in the reference image folders, follow these steps:

    1. In the Graphics Tests window, select Settings.
    2. Enable Auto Optimize.

    To configure optimization for a specific scene, add a Graphics Tests Settings component. For more information, refer to Graphics Test Settings component reference.

    Deduplicate from a C# script

    To call ReferenceImageOptimizer.OptimizeReferenceImages from a C# script, follow these steps:

    1. Call the OptimizeReferenceImages API:

      ReferenceImageOptimizer.OptimizeReferenceImages(filter: "", maxConcurrency: 4);
      
    2. Subscribe to the ReferenceImageOptimizer.OnStatsReceived to run code when the results of the optimization are ready. For example:

      ReferenceImageOptimizer.OnStatsReceived += (sender, args) =>
      {
          Debug.Log($"Test: {args.TestName}, Platforms: {args.Metrics.PlatformCount}, Divergence: {args.Metrics.AccumulatedDivergence}");
      };
      
    3. Subscribe to the ReferenceImageOptimizer.OnOptimizationComplete event to run code when the optimization has finished deleting and moving reference images. For example:

      ReferenceImageOptimizer.OnOptimizationComplete += (sender, result) =>
      {
          Debug.Log($"Status: {result.Status}, Deleted: {result.DeletedFiles.Count}, Moved: {result.MovedFiles.Count}");
      };
      

    Additional resources

    • Shader stripping
    • Customizing and optimizing tests
    • The Graphics Tests window
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)