Search Unity

Unsupported type Generic Mono

Discussion in 'Scripting' started by Daivuk, Apr 6, 2012.

  1. Daivuk

    Daivuk

    Joined:
    Apr 4, 2012
    Posts:
    14
    Hi, I am trying to have a serialized class and I get this error as soon as I modify a value:
    "Unsupported type Generic Mono"
    PropertyModification.cpp at line: 130

    There are literally no google result for "Unsupported type Generic Mono".
    So I thought I would post here. There is my script:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4.  
    5. public class GoodsDropper : MonoBehaviour
    6. {
    7.     [System.Serializable]
    8.     public class DropItemDef
    9.     {
    10.         public GameObject Item = null;
    11.         public int ItemValue = 0;
    12.     }
    13.  
    14.     public Transform DropLocation;
    15.     public List<DropItemDef> Items;
    16.    
    17.     public void DropRandomGoods()
    18.     {
    19.     }
    20. }
    21.  
    I tried putting the serialize class outside of that class, or in its own file. I always get the same error. Here I am using

    public List<DropItemDef> Items;

    But I also tried with simple array:

    public DropItemDef[] Items;

    Always same error. But If I don't use an array, just single object like this:
    public DropItemDef Item;

    It works fine.


    Does anybody have any idea what I am doing wrong here? Thanks!
     
  2. karljj1

    karljj1

    Joined:
    Feb 17, 2011
    Posts:
    440
    I dont think you can serialize GameObjects, so you wont be able to serialize DropItemDef.

    I had this problem in the past, i think it was the Transform object that caused the problem.
     
  3. Daivuk

    Daivuk

    Joined:
    Apr 4, 2012
    Posts:
    14
    If I remove gameobject and only keep the int, I have the same error
     
  4. karljj1

    karljj1

    Joined:
    Feb 17, 2011
    Posts:
    440
    Where in the code do you modify the valus that cause the error?

    Are you creating the list? By default it will be null.

    public List<DropItemDef> Items = new List<DropItemDef>();
     
  5. Daivuk

    Daivuk

    Joined:
    Apr 4, 2012
    Posts:
    14
    I modify the values in the inspector. I can change its size to 1, and then fill the data. It's the first time I try with a custom data type, and I get that error.
     
  6. Julianobsg

    Julianobsg

    Joined:
    Jul 14, 2012
    Posts:
    4
    I actually having the same problem, and noticed that the problem is actually the list and the serializable class, they don't fit together, do know why and do know the solution.


    EDITED

    Ok, still not achieved a solution, but what I've made that "solved" the problem, was creating a class with the actual list, in this case would be a class

    [System.Serializable]
    public class DropItems {
    public List<DropItemDef> list;
    }

    And then I've used it as a normal item, like:

    Public DropItems Items;

    and the items would be called Items.list, which is kind of painful, but skipped the error.
     
    Last edited: Jul 14, 2012
  7. DannyB

    DannyB

    Joined:
    Jun 20, 2012
    Posts:
    214
    I am also getting the same error.
    Weirdly, everything seems to be working and the error appears only when I try to edit one of the values through the inspector.

    I will try Unity Answers

    EDIT:
    If anyone with the same problem reaches this thread, the answer may be in this Unity Answer
     
    Last edited: Oct 4, 2012
  8. citizen.rafiq

    citizen.rafiq

    Joined:
    Nov 25, 2012
    Posts:
    1
    re-attach ur script component
     
  9. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    Strange, I've done that plenty of times and never had an error, though I usually have the custom class sitting above and outside the main class definition like so:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4.  
    5. [System.Serializable]
    6. public class DropItemDef
    7. {
    8.     public GameObject Item = null;
    9.     public int ItemValue = 0;
    10. }
    11.  
    12.  
    13. public class GoodsDropper : MonoBehaviour
    14. {
    15.  
    16.     public Transform DropLocation;
    17.  
    18.     public List<DropItemDef> Items;
    19.  
    20.     public void DropRandomGoods()
    21.     {
    22.     }
    23.  
    24. }
    Also, if you're changing/re-factoring types/data that's already serialized in the game scene it's often best to reset the script component to defaults (click the little gear icon in the inspector).
     
    Last edited: Nov 25, 2012
  10. DannyB

    DannyB

    Joined:
    Jun 20, 2012
    Posts:
    214
    Guys, thanks but you are resurrecting an old thread that is already solved in the Unity Answer post linked above.