Class EuclideanDistance
Uses the Pythagorean theorem to measure the per-pixel color difference between two textures using a compute shader.
Inherited Members
Namespace: UnityEngine.TestTools.Graphics
Assembly: UnityEngine.TestTools.Graphics.dll
Syntax
public class EuclideanDistance : TextureComparisonAlgorithm
Constructors
EuclideanDistance(ITextureComparisonSettings)
Initializes a new instance of the Euclidean distance algorithm with the given settings. The Euclidean distance is calculated as the square root of the sum of the squared differences in each color channel (R, G, B, and optionally A) between corresponding pixels in the two images. The average distance across all pixels is compared against the specified maximum distance threshold to determine if the images are considered a match.
Declaration
public EuclideanDistance(ITextureComparisonSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| ITextureComparisonSettings | settings | Settings containing the maximum acceptable distance threshold. |
Methods
Compare(Texture2D, Texture2D)
Compare two texture together using the Euclidean distance algorithm
Declaration
public override ITextureComparisonResult Compare(Texture2D expected, Texture2D actual)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D | expected | Expected texture |
| Texture2D | actual | Actual texture |
Returns
| Type | Description |
|---|---|
| ITextureComparisonResult | The result of the comparison |
Overrides
Compare(Texture2D[], Texture2D[])
Compare two arrays of texture
Declaration
public override ITextureComparisonResult Compare(Texture2D[] expected, Texture2D[] actual)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D[] | expected | Expected textures |
| Texture2D[] | actual | Actual textures |
Returns
| Type | Description |
|---|---|
| ITextureComparisonResult | The result of the comparison |
Overrides
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Not Supported for this algorithm |
CompareAsync(Texture2D, Texture2D)
Compare two textures together asynchronously.
Declaration
public override Task<ITextureComparisonResult> CompareAsync(Texture2D expected, Texture2D actual)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D | expected | Expected texture |
| Texture2D | actual | Actual texture |
Returns
| Type | Description |
|---|---|
| Task<ITextureComparisonResult> | The result of the comparison |
Overrides
Evaluate(ITextureComparisonResult)
Evaluates the result of a texture comparison.
Declaration
public override (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. |