ScriptableObjectを使用したデータ管理

ScriptableObjecetを継承したデータクラスを実装

CharacterDataSet.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharacterDataSet : ScriptableObject
{
    public List<Param> DataList = new List<Param>();
}

[System.Serializable]
public class Param
{
    public string Name;
    public Sprite Image;
    public GameObject Model;
}

保存用フォルダ作成

Resources/ScriptableObjecet

ScriptableObjectをアセットとして保存するためのクラスを実装

CharacterDataGenerator.cs

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class CharacterDataGenerator
{
    [MenuItem("Assets/Create/CharacterData")]
    static void CreateCheracterData()
    {
        CharacterDataSet data = ScriptableObject.CreateInstance<CharacterDataSet>();
        string path = AssetDatabase.GenerateUniqueAssetPath("Assets/Resources/ScriptableObject/CharacterDataSet.asset");
        AssetDatabase.CreateAsset(data, path);
        AssetDatabase.Refresh();
    }
}

UnityEditorスクリプトなのでEditorフォルダ以下に移動させる必要があります。

読み込み方法

CharacterManager.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CheracterManager : MonoBehaviour
{
    private CharacterDataSet _characterDataSet;

    private void Start()
    {
        _characterDataSet = Resources.Load<CharacterDataSet>("ScriptableObject/CharacterDataSet");
        Debug.Log(_characterDataSet.DataList.Count);
    }
}