docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ImageAssert

    Provides test assertion helpers for working with images.

    Inheritance
    object
    ImageAssert
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.TestTools.Graphics
    Assembly: UnityEngine.TestTools.Graphics.dll
    Syntax
    public class ImageAssert

    Fields

    kBackBufferHeight

    Declaration
    public const int kBackBufferHeight = 1080
    Field Value
    Type Description
    int

    kBackBufferWidth

    Declaration
    public const int kBackBufferWidth = 1920
    Field Value
    Type Description
    int

    onAllCamerasRendered

    Declaration
    public static Action<RenderTexture> onAllCamerasRendered
    Field Value
    Type Description
    Action<RenderTexture>

    Methods

    AllocatesMemory(Camera, ImageComparisonSettings, int)

    Render an image from the given camera and check if it allocated memory while doing so.

    Declaration
    public static void AllocatesMemory(Camera camera, ImageComparisonSettings settings = null, int gcAllocThreshold = 0)
    Parameters
    Type Name Description
    Camera camera

    The camera to render from.

    ImageComparisonSettings settings
    int gcAllocThreshold

    AreEqual(Texture2D, IEnumerable<Camera>, ImageComparisonSettings, string)

    Render an image from the given cameras and compare it to the reference image.

    Declaration
    public static void AreEqual(Texture2D expected, IEnumerable<Camera> cameras, ImageComparisonSettings settings = null, string expectedImagePathLog = null)
    Parameters
    Type Name Description
    Texture2D expected

    The expected image that should be rendered by the camera.

    IEnumerable<Camera> cameras

    The cameras to render from.

    ImageComparisonSettings settings

    Optional settings that control how the image comparison is performed. Can be null, in which case the rendered image is required to be exactly identical to the reference.

    string expectedImagePathLog

    AreEqual(Texture2D, Camera, ImageComparisonSettings, string)

    Render an image from the given camera and compare it to the reference image.

    Declaration
    public static void AreEqual(Texture2D expected, Camera camera, ImageComparisonSettings settings = null, string expectedImagePathLog = null)
    Parameters
    Type Name Description
    Texture2D expected

    The expected image that should be rendered by the camera.

    Camera camera

    The camera to render from.

    ImageComparisonSettings settings

    Optional settings that control how the image comparison is performed. Can be null, in which case the rendered image is required to be exactly identical to the reference.

    string expectedImagePathLog

    AreEqual(Texture2D, Texture2D, ImageComparisonSettings, string, bool)

    Compares an image to a 'reference' image to see if it looks correct.

    Declaration
    public static void AreEqual(Texture2D expected, Texture2D actual, ImageComparisonSettings settings = null, string expectedImagePathLog = null, bool saveFailedImage = true)
    Parameters
    Type Name Description
    Texture2D expected

    What the image is supposed to look like.

    Texture2D actual

    What the image actually looks like.

    ImageComparisonSettings settings

    Optional settings that control how the comparison is performed. Can be null, in which case the images are required to be exactly identical.

    string expectedImagePathLog
    bool saveFailedImage

    AreEqualLinearHDR(Texture2D, Texture2D, ImageComparisonSettings, string, bool)

    Compares an image to a 'reference' image to see if it looks correct. Assumes linear HDR images (RGBAFloat or RGBAHalf).

    Declaration
    public static void AreEqualLinearHDR(Texture2D expected, Texture2D actual, ImageComparisonSettings settings = null, string expectedImagePathLog = null, bool saveFailedImage = true)
    Parameters
    Type Name Description
    Texture2D expected

    What the image is supposed to look like.

    Texture2D actual

    What the image actually looks like.

    ImageComparisonSettings settings

    Optional settings that control how the comparison is performed. Can be null, in which case the images are required to be exactly identical.

    string expectedImagePathLog
    bool saveFailedImage

    CheckGCAllocWithCallstack(Camera, ImageComparisonSettings, string)

    Render an image from the given camera and check if it allocated memory while doing so. Also outputs the callstack of the GC.Alloc found

    Declaration
    public static IEnumerator CheckGCAllocWithCallstack(Camera camera, ImageComparisonSettings settings = null, string overrideSRPMarkerName = null)
    Parameters
    Type Name Description
    Camera camera

    The camera to render from.

    ImageComparisonSettings settings

    Settings to create the camera render target

    string overrideSRPMarkerName

    Override the main marker used to check the GC.Alloc

    Returns
    Type Description
    IEnumerator

    GetImageResolution(ImageComparisonSettings, out int, out int)

    Declaration
    public static void GetImageResolution(ImageComparisonSettings settings, out int width, out int height)
    Parameters
    Type Name Description
    ImageComparisonSettings settings
    int width
    int height

    ResizeInto(Texture2D, Texture2D)

    Resize a source texture to match the dimensions of the destination texture

    Declaration
    public static Texture2D ResizeInto(Texture2D source, Texture2D dest)
    Parameters
    Type Name Description
    Texture2D source
    Texture2D dest
    Returns
    Type Description
    Texture2D
    In This Article
    Back to top
    Copyright © 2024 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)