Note that there are some explanatory texts on larger screens.

plurals
  1. POGeneric Inventory Unity
    text
    copied!<p>Edit: I've been thinking of how to give a tl;dr here. How about this: Inspector is looking for a BaseObject. How can I get the inspector to allow me to assign a DerivedObject, derived from BaseObject.</p> <p>I'm trying to make a generic inventory system. I've tried out Brackey's inventory system, but wanted to expand upon it to include things beyond just an "Item". I'd like to have a "Key" or "Weapon" classes that inherit Item as a base, whereas Brackey's Inventory has a number of Boolean fields that determine if it is able to be equipped or if it's a weapon. I can do this, my problem is how do create these items at editor time, when my script is expecting base Type: Item.</p> <p>Starting from scratch I have an Item (Fields: string ItemName) and I have Key : Item ( New Fields: string AuthorityLevel)</p> <p>I've got a Pickup script that I apply as a component to GameObjects. In that script I can give it a property of Item, and when the GameObject is interacted with I can call the Pickup.GetItem() method. This then takes the Item property and adds it to my Inventory object.</p> <p>How would I get that Item property to hold a reference to a Key object, which inherits from Item? The inspector for the PickUp script will only show the Item Property's "ItemName", rather than the Key Item's AuthorityLevel field.</p> <p>I'm a little lost. I've found it easy to implement this at runtime, since the scripts that create items, know what specific item to create and can assign it to the newly created GameObject's PickUp script. But at Editor time, it's difficult to tell the inspector that I want the Pickup script to hold a reference to Key or any other object that inherits from Item.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload