So I'm working on creating an Editor GUI for an item database, and the way I have my inventory item system set up is that there are 3 types of items: equipment items, active items, and passive items. Passive items are the base item, and both equipment items and active items extend from the base item. So I need my Editor GUI to be able to distinguish between these types of items. So the plan right now for me is to use Code (csharp): is to check the type of the item. Is this bad practice and should I therefore instead cache the item type and use that? Or does anyone know an even better way to make an inventory item system? Thanks in advance guys!
first, I could explain that you can get the types and reference them against eachother... Code (csharp): string typeName = "Passive"; if(obj.GetType() == Type.GetType(Passive)) typeName = "Active"; if(obj.GetType() == Type.GetType(Equipment)) typeName = "Equipment"; but a much simpler solution is to add typeName as a public string variable in the class. Then all you have to do is get the string rather than put references to types in scripts.