Hello, I am replacing part of my scripts with ScriptableObject & assets created by them. I created a ScriptableObject called Item, then I made a bunch of assets like “Sword”. “Axe”, “Bow”, etc.
Now I am passing an item to a class and I want to check if the item is an “Axe”. With enum I could just do item.itemType == ItemType.Axe. How do I do this using ScriptableObject assets? Really, how to I get the asset into my class. Am I able to call it like an enum, Item.Axe?
It seems like I need to use Load Resources to search through files for the asset of Axe, then compare it, but that seems too intensive a task to do frequently.
Similarly, let’s say I made a List<Item> and I want to populate that with a “Sword”, “Axe”, and “Bow” in my script. How do I treat the assets? I guess I can’t figure out if assets are interfaces or classes under the hood. Do I need to declare new Item<Axe>() to have an Axe in my script? What is the syntax. I cannot find it anywhere I look online.
submitted by /u/Duckduckgosling
[link] [comments]
Unity 3D – News, Help, Resources, and Conversation