Game Development Reference
In-Depth Information
public Texture displayTexture;
public GameObject item;
public int quantity;
Note
Scripts that inherit from
monobehavior
can be fully manipulated by the Unity3D
Editor; they can be attached to GameObjects, have the property values saved,
among other things. This class does not inherit from
monobehavior
; as it is an
internal helper class for
InventoryMgr
. It never has to be attached to GameOb-
ject (a programmer or designer would not normally want to attach one of these
to a 3D object because it doesn't need a
Transform
component to do its work).
This class only acts as the glue between the interactive objects that have been
collected and the UI button that
InventoryMgr
displays for these objects' cus-
tom type. Hence, this class does not derive from any base class. This allows us
to declare a list of these objects directly inside
InventoryMgr
.
To make the class show up in the inspector (in
InventoryMgr
), we need to add
back some of the functionality that would have been included, had we inherited from
monobehavior
; namely, the serialization of its properties. Hence, we add the fol-
lowing code decoration before the class declaration:
[System.Serializable]