12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- namespace UnityEngine.TestTools.Utils
- {
- public static class Utils
- {
- public static bool AreFloatsEqual(float expected, float actual, float epsilon)
- {
-
- if (expected == Mathf.Infinity || actual == Mathf.Infinity || expected == Mathf.NegativeInfinity || actual == Mathf.NegativeInfinity)
- return expected == actual;
-
-
-
-
-
- return Math.Abs(actual - expected) <= epsilon * Mathf.Max(Mathf.Max(Mathf.Abs(actual), Mathf.Abs(expected)), 1.0f);
- }
- public static bool AreFloatsEqualAbsoluteError(float expected, float actual, float allowedAbsoluteError)
- {
- return Math.Abs(actual - expected) <= allowedAbsoluteError;
- }
-
-
-
-
-
- public static GameObject CreatePrimitive(PrimitiveType type)
- {
- var prim = GameObject.CreatePrimitive(type);
- var renderer = prim.GetComponent<Renderer>();
- if (renderer)
- renderer.sharedMaterial = new Material(Shader.Find("VertexLit"));
- return prim;
- }
- }
- }
|