Fix Unity warnings

This commit is contained in:
Pascal Serrarens 2026-01-05 11:26:13 +01:00
parent 3611de5142
commit d102fc7b80
4 changed files with 52 additions and 48 deletions

View File

@ -324,27 +324,13 @@ namespace LinearAlgebra {
public static Vector2Float Scale(Vector2Float v1, Vector2Float v2) {
return new Vector2Float(v1.horizontal * v2.horizontal, v1.vertical * v2.vertical);
}
/*
/// <summary>
/// Tests if the vector has equal values as the given vector
/// </summary>
/// <param name="v1">The vector to compare to</param>
/// <returns><em>true</em> if the vector values are equal</returns>
public bool Equals(Vector2Float v1) => horizontal == v1.horizontal && vertical == v1.vertical;
/// <summary>
/// Tests if the vector is equal to the given object
/// </summary>
/// <param name="obj">The object to compare to</param>
/// <returns><em>false</em> when the object is not a Vector2 or does not have equal values</returns>
public override bool Equals(object obj) {
if (!(obj is Vector2Float v))
return false;
return (horizontal == v.horizontal && vertical == v.vertical);
}
*/
//public readonly bool Equals(Vector2Float v1) => horizontal == v1.horizontal && vertical == v1.vertical;
/// <summary>
/// Tests if the two vectors have equal values
@ -372,15 +358,25 @@ namespace LinearAlgebra {
return (v1.horizontal != v2.horizontal || v1.vertical != v2.vertical);
}
/*
/// <summary>
/// Tests if the vector is equal to the given object
/// </summary>
/// <param name="obj">The object to compare to</param>
/// <returns><em>false</em> when the object is not a Vector2 or does not have equal values</returns>
public override readonly bool Equals(object obj) {
if (obj is not Vector2Float v)
return false;
return (horizontal == v.horizontal && vertical == v.vertical);
}
/// <summary>
/// Get an hash code for the vector
/// </summary>
/// <returns>The hash code</returns>
public override int GetHashCode() {
return (horizontal, vertical).GetHashCode();
public override readonly int GetHashCode() {
return HashCode.Combine(horizontal, vertical);
}
*/
/// <summary>
/// Get the distance between two vectors

View File

@ -60,17 +60,6 @@ namespace LinearAlgebra {
/// <returns><em>true</em> if the vector values are equal</returns>
public readonly bool Equals(Vector2Int v) => this.horizontal == v.horizontal && vertical == v.vertical;
/// <summary>
/// Tests if the vector is equal to the given object
/// </summary>
/// <param name="obj">The object to compare to</param>
/// <returns><em>false</em> when the object is not a Vector2 or does not have equal values</returns>
public override readonly bool Equals(object obj) {
if (obj is not Vector2Int v)
return false;
return (this.horizontal == v.horizontal && this.vertical == v.vertical);
}
*/
/// <summary>
@ -98,6 +87,26 @@ namespace LinearAlgebra {
return (v1.horizontal != v2.horizontal || v1.vertical != v2.vertical);
}
/// <summary>
/// Tests if the vector is equal to the given object
/// </summary>
/// <param name="obj">The object to compare to</param>
/// <returns><em>false</em> when the object is not a Vector2 or does not have equal values</returns>
public override readonly bool Equals(object obj) {
if (obj is not Vector2Int v)
return false;
return (this.horizontal == v.horizontal && this.vertical == v.vertical);
}
/// <summary>
/// Get an hash code for the vector
/// </summary>
/// <returns>The hash code</returns>
public override readonly int GetHashCode() {
return HashCode.Combine(horizontal, vertical);
}
public readonly float sqrMagnitude => this.horizontal * this.horizontal + this.vertical * this.vertical;
public static float SqrMagnitudeOf(Vector2Int v) {

View File

@ -250,30 +250,22 @@ namespace LinearAlgebra {
public static Vector3Float operator *(Vector3Float v1, float d) {
Vector3Float v = new Vector3Float(v1.horizontal * d, v1.vertical * d, v1.depth * d);
Vector3Float v = new(v1.horizontal * d, v1.vertical * d, v1.depth * d);
return v;
}
public static Vector3Float operator *(float d, Vector3Float v1) {
Vector3Float v = new Vector3Float(d * v1.horizontal, d * v1.vertical, d * v1.depth);
Vector3Float v = new(d * v1.horizontal, d * v1.vertical, d * v1.depth);
return v;
}
public static Vector3Float operator /(Vector3Float v1, float d) {
Vector3Float v = new Vector3Float(v1.horizontal / d, v1.vertical / d, v1.depth / d);
Vector3Float v = new(v1.horizontal / d, v1.vertical / d, v1.depth / d);
return v;
}
/*
public bool Equals(Vector3Float v) => (horizontal == v.horizontal && vertical == v.vertical && depth == v.depth);
public override bool Equals(object obj) {
if (!(obj is Vector3Float v))
return false;
return (horizontal == v.horizontal && vertical == v.vertical && depth == v.depth);
}
*/
//public bool Equals(Vector3Float v) => (horizontal == v.horizontal && vertical == v.vertical && depth == v.depth);
public static bool operator ==(Vector3Float v1, Vector3Float v2) {
return (v1.horizontal == v2.horizontal && v1.vertical == v2.vertical && v1.depth == v2.depth);
@ -283,9 +275,16 @@ namespace LinearAlgebra {
return (v1.horizontal != v2.horizontal || v1.vertical != v2.vertical || v1.depth != v2.depth);
}
// public override int GetHashCode() {
// return (horizontal, vertical, depth).GetHashCode();
// }
public override readonly bool Equals(object obj) {
if (obj is not Vector3Float v)
return false;
return (horizontal == v.horizontal && vertical == v.vertical && depth == v.depth);
}
public override readonly int GetHashCode() {
return HashCode.Combine(horizontal, vertical, depth);
}
/// @brief The distance between two vectors
/// @param v1 The first vector

View File

@ -501,7 +501,7 @@ public static class OpenAssetHandler {
// Called when an asset is double-clicked or opened.
[OnOpenAsset]
public static bool OpenMyScriptableObject(int instanceID, int line) {
NanoBrainObj obj = EditorUtility.InstanceIDToObject(instanceID) as NanoBrainObj;
NanoBrainObj obj = EditorUtility.EntityIdToObject(instanceID) as NanoBrainObj;
if (obj != null) {
NanoBrainEditor.Open(obj);
return true; // handled