Search Unity

Save object in ScriptableObject

Discussion in 'Editor & General Support' started by Baumkuchen, Mar 26, 2018.

  1. Baumkuchen

    Baumkuchen

    Joined:
    Feb 14, 2016
    Posts:
    8
    I want to save a list of "ClassA" with different typs in the Class "DatabaseA".
    Currently i cant save a System.object in my list. All other types work.

    public class ExampleClass
    {
    int i;
    System.object obj, <-- will not be saved in the ".asset" file
    float f;
    }

    public class DatabaseA: ScriptableObject
    {
    public List<ExampleClass> ListExampleClass;
    }
     
    Last edited: Mar 26, 2018
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
  3. Baumkuchen

    Baumkuchen

    Joined:
    Feb 14, 2016
    Posts:
    8
    Thx for your Answer. Yehr convert the type to a string is good idea.
    float, int, and so on... can be easly converted from string.
    But how i can convert a string to GameObject/Prefab, Texture2D, AudioClip?
    Unity also converts it from a string to a reference.

    Hint: I want to edit the stored data in a EditorWindow.

    Instead using the System.Object it would fit my needs using UnityEngine.Object if it is possible convert a UnityEngine.Object to base Types like uint, int, float and bool.
     
    Last edited: Mar 26, 2018
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281