I'd like to compare two classes that have the same values, how could I do that, without having to compare the values in the classes? (So thisClass = thasClass, and not thisClass.x = thasClass.x.) The code below is an example of the problem.
C#:
public class SomeClass
{
float x;
public SomeClass(float x)
{
this.x = x;
}
}
public class OtherClass : MonoBehaviour
{
void Start()
{
SomeClass thisClass = new SomeClass(1);
SomeClass thatClass = new SomeClass(1);
if (thisClass == thatClass) //this is never true, how would you make it true?
{
Debug.Log("classes are the same");
}
else
{
Debug.Log("classes aren't the same");
}
}
}
Last edited by a moderator: