the Animal class has two children classes: Dog, and Cat. i am now writing a component for pet food, and i want to expose a variable in the unity inspector that specifies whether this pet food is for Dog or for Cat. i’m trying to write something like:
public Type foodtype;
in the pet food component, and then check if the dog can eat it by:
if (foodtype == typeof(Dog))
// eat food.
but i can’t figure out the proper syntax for this. would someone kindly lend a hand?