Question by
kevinrocks_786 · Dec 03, 2015 at 12:54 PM ·
c#objectclassclasses
C# Find specific object by getting one of its variables
Hello guys. So I'm trying to do something similar to how you do it in JavaScript by getElementById.
I want to do something like this:
class Animal {
string id;
}
public Animal Zebra = new Animal();
Zebra.id = "abc";
//and then get it like this
var foo = getAnimalId("abc");
And then it returns Zebra. Anyway to do this? Thanks
Comment
I think doing this through lists might be the way to go:
https://unity3d.com/learn/tutorials/modules/intermediate/scripting/lists-and-dictionaries