Hi,
I am developing a game where I use ScriptableObjects as data holders.
I will be using the ScriptableObjects to build levels and pass them to another project (where the data types are equal) and use the data to build the scene. Having the following structure:
MapListBase class:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]
public class MapListBase : ScriptableObject
{
[SerializeField]
public List<MapDetails> m_Details;
}
MapDetails Class:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
/// <summary>
/// Serializable class acting as model for Maps - used in Multiplayer and is the base class of SinglePlayer maps
/// </summary>
[Serializable]
public class MapDetails
{
[SerializeField]
protected string m_Name;
public string name
{
get{ return m_Name; }
}
//This is marked as a serialized field for debugging purposes only
[SerializeField]
protected bool m_IsLocked;
public bool isLocked
{
get { return m_IsLocked; }
}
[SerializeField] [Multiline]
protected string m_Description;
public string description
{
get { return m_Description; }
}
[SerializeField]
protected string m_SceneName, m_Id;
public string sceneName
{
get { return m_SceneName; }
}
public string id
{
get { return m_Id; }
}
[SerializeField]
protected Sprite m_Image;
public Sprite image
{
get{ return m_Image; }
}
[SerializeField]
protected int m_UnlockCost;
public int unlockCost
{
get{ return m_UnlockCost; }
}
}
And the Editor Script that creates the ScriptableObject:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class MakeMap {
[MenuItem("Assets/Create/Map Object")]
public static MapListBase Create()
{
MapListBase asset = ScriptableObject.CreateInstance<MapListBase> ();
AssetDatabase.CreateAsset (asset, "Assets/MapListBase.asset");
AssetDatabase.SaveAssets ();
EditorUtility.FocusProjectWindow ();
Selection.activeObject = asset;
return asset;
}
}
The problem is, the scriptable object generated in project A works fine however, as I copy-paste the same object to the project B it can not find the associated script even though I have the same classes referred below… I saw some forum threads mentioning about bugs for ignoring the script file’s meta data, would it be related to that subject?