Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[Solved] Serializable Item in List<Item>

Discussion in 'Getting Started' started by dojo9, Oct 5, 2020.

  1. dojo9

    dojo9

    Joined:
    Sep 18, 2020
    Posts:
    12
    I was following the Unity tutorial on Enums where the instructor used a [Serializable] Item Class and an ItemDB that used a List<Item>. Then the IDE showed ItemDB as shown below

    expected.png


    But when I tried the same in Unity 2019.4.11f, its not working. How can I fix this ?

    script.png
    result.png
     
  2. iMobCoding

    iMobCoding

    Joined:
    Feb 13, 2017
    Posts:
    147
    Your Item class shouldn't derive from MonoBehaviour. Declare it just like this:
    Code (CSharp):
    1. [Serializable]
    2. public class Item
    3. {
    4.     ...
    5. }
     
    dojo9, Vryken and JoeStrout like this.