The [CreateAssetMenu] property can click the corresponding name in Create to create an asset file. As shown below
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu]
public class ChatConfig : ScriptableObject
{
[SerializeField]
public List<string> ChatContent;
}
All data can be loaded by using the object of the type of Resources Load as ChatConfig, for example
var content = Resources.Load<ChatConfig>("ChatConfig");
code creation
using UnityEditor;
using UnityEngine;
public class CreateAssetEditor
{
[MenuItem("Assets/Create ScriptObject")]
static void CreateScriptObject()
{
ChatConfig config = ScriptableObject.CreateInstance<ChatConfig>();
config.ChatContent = new System.Collections.Generic.List<string>
{
"A",
"B"
};
AssetDatabase.CreateAsset(config, "Assets/Resources/NewChatConfig.asset");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}