Class TextureComparisonAlgorithm
Abstract base class for algorithms that compare two textures using a specified threshold.
Inherited Members
Namespace: UnityEngine.TestTools.Graphics
Assembly: UnityEngine.TestTools.Graphics.dll
Syntax
public abstract class TextureComparisonAlgorithm
Constructors
TextureComparisonAlgorithm()
Initializes a new instance of the TextureComparisonAlgorithm class.
Declaration
protected TextureComparisonAlgorithm()
TextureComparisonAlgorithm(ITextureComparisonSettings)
Initializes a new instance of the TextureComparisonAlgorithm class with the specified threshold.
Declaration
protected TextureComparisonAlgorithm(ITextureComparisonSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| ITextureComparisonSettings | settings | The threshold that determines how differences between images are evaluated. |
Properties
Description
Gets or sets the description of the algorithm, used when displaying assertion results.
Declaration
public string Description { get; protected init; }
Property Value
| Type | Description |
|---|---|
| string |
Settings
Gets the threshold used by the algorithm to measure the difference between images.
Declaration
protected ITextureComparisonSettings Settings { get; }
Property Value
| Type | Description |
|---|---|
| ITextureComparisonSettings |
Methods
Compare(Texture2D, Texture2D)
Compares two textures synchronously.
Declaration
public abstract ITextureComparisonResult Compare(Texture2D expected, Texture2D actual)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D | expected | The first texture to compare. |
| Texture2D | actual | The second texture to compare. |
Returns
| Type | Description |
|---|---|
| ITextureComparisonResult | A result object representing the outcome of the comparison. |
Compare(Texture2D[], Texture2D[])
Compares two series of textures synchronously
Declaration
public abstract ITextureComparisonResult Compare(Texture2D[] expected, Texture2D[] actual)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D[] | expected | The first texture to compare. |
| Texture2D[] | actual | The second texture to compare. |
Returns
| Type | Description |
|---|---|
| ITextureComparisonResult | A result object representing the outcome of the comparison. |
CompareAsync(Texture2D, Texture2D)
Compares two textures asynchronously.
Declaration
public abstract Task<ITextureComparisonResult> CompareAsync(Texture2D expected, Texture2D actual)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D | expected | The first texture to compare. |
| Texture2D | actual | The second texture to compare. |
Returns
| Type | Description |
|---|---|
| Task<ITextureComparisonResult> | A task that represents the asynchronous comparison operation. The task result contains a ITextureComparisonResult representing the outcome of the comparison. |
DescribeActual(ITextureComparisonResult)
Describes the measured values of a comparison result produced by this algorithm, as named values for structured result reporting. The algorithm owns the keys. Returns null when the algorithm does not provide structured values (or the result is not one of its own); reporting then falls back to the result's ToString().
Declaration
public virtual IReadOnlyDictionary<string, object> DescribeActual(ITextureComparisonResult result)
Parameters
| Type | Name | Description |
|---|---|---|
| ITextureComparisonResult | result | The result of a comparison run by this algorithm. |
Returns
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, object> | The measured values as named values, or null. |
DescribeExpected()
Describes the thresholds this algorithm compares against, as named values for structured result reporting. The algorithm owns the keys. Returns null when the algorithm does not provide structured values; reporting then falls back to Description.
Declaration
public virtual IReadOnlyDictionary<string, object> DescribeExpected()
Returns
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, object> | The configured thresholds as named values, or null. |
Evaluate(ITextureComparisonResult)
Evaluates the result of a texture comparison.
Declaration
public abstract (object, bool) Evaluate(ITextureComparisonResult result)
Parameters
| Type | Name | Description |
|---|---|---|
| ITextureComparisonResult | result | The result of the comparison to evaluate. |
Returns
| Type | Description |
|---|---|
| (object, bool) | A tuple containing an evaluation object (typically for reporting) and a boolean indicating whether the comparison passed. |