首先需要创建一个类

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "testAsset",menuName = "createAsset",order = 100)]//菜单按钮  第二个参数是菜单的名字 第三个是菜单上的顺序
public class assetSerialize : ScriptableObject {//这个类需要继承ScriptableObject

    public int ID;
    public string name;
    public List<int> list;
 
   }

这个类写完之后呢 会出现
Unity Asset 序列化

点击之后就可以创建Asset
Unity Asset 序列化
如何读取呢

void readAsset()
{
assetSerialize assets = UnityEditor.AssetDatabase.LoadAssetAtPath(“Assets/testAsset.asset”);//读取所创建的路径
Debug.Log(assets.ID);
Debug.Log(assets.name);
foreach (var item in assets.list)
{
Debug.Log(item);
}
}
Unity Asset 序列化

相关文章: