port(m1): wave 6f — Unity primitive operators (362->304)
CS0019 operator gaps on value-type shims: - Vector2: ==/!=, Vector2*Vector2, Equals/GetHashCode. - Vector4: *float, +/-, ==/!=, Equals/GetHashCode. - Color: ==/!= (Color==Color32 via existing implicit conv), Equals/GetHashCode. - Rect: ==/!=; Matrix4x4: *, GetColumn/GetRow/indexer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,11 @@ namespace UnityEngine
|
||||
public static Vector2 operator *(Vector2 a, float s) => new Vector2(a.x * s, a.y * s);
|
||||
public static Vector2 operator *(float s, Vector2 a) => new Vector2(a.x * s, a.y * s);
|
||||
public static Vector2 operator /(Vector2 a, float s) => new Vector2(a.x / s, a.y / s);
|
||||
public static Vector2 operator *(Vector2 a, Vector2 b) => new Vector2(a.x * b.x, a.y * b.y);
|
||||
public static bool operator ==(Vector2 a, Vector2 b) => a.x == b.x && a.y == b.y;
|
||||
public static bool operator !=(Vector2 a, Vector2 b) => !(a == b);
|
||||
public override bool Equals(object o) => o is Vector2 v && this == v;
|
||||
public override int GetHashCode() => x.GetHashCode() ^ (y.GetHashCode() << 2);
|
||||
public static implicit operator Vector2(Vector3 v) => new Vector2(v.x, v.y);
|
||||
public static implicit operator Vector3(Vector2 v) => new Vector3(v.x, v.y, 0);
|
||||
}
|
||||
@@ -109,6 +114,10 @@ namespace UnityEngine
|
||||
public static implicit operator Color32(Color c) => new Color32(
|
||||
(byte)(Mathf.Clamp01(c.r) * 255f), (byte)(Mathf.Clamp01(c.g) * 255f),
|
||||
(byte)(Mathf.Clamp01(c.b) * 255f), (byte)(Mathf.Clamp01(c.a) * 255f));
|
||||
public static bool operator ==(Color a, Color b) => a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
|
||||
public static bool operator !=(Color a, Color b) => !(a == b);
|
||||
public override bool Equals(object o) => o is Color c && this == c;
|
||||
public override int GetHashCode() => r.GetHashCode() ^ (g.GetHashCode() << 2) ^ (b.GetHashCode() << 4) ^ (a.GetHashCode() << 6);
|
||||
}
|
||||
|
||||
public static class Mathf
|
||||
|
||||
Reference in New Issue
Block a user