概要
using System.Linq; using UnityEditor; using UnityEditorInternal; using UnityEngine; public class Example : ScriptableObject { public int m_id = 25; public string m_name = "ピカチュウ"; [MenuItem( "Tools/Save" )] private static void Save() { var example = CreateInstance<Example>(); InternalEditorUtility.SaveToSerializedFileAndForget ( obj: new Object[] { example }, path: "Assets/Example.yaml", allowTextSerialization: true ); AssetDatabase.Refresh(); } [MenuItem( "Tools/Load" )] private static void Load() { var path = "Assets/Example.yaml"; var list = InternalEditorUtility.LoadSerializedFileAndForget( path ); var example = list .OfType<Example>() .FirstOrDefault() ; Debug.Log( example.m_id ); Debug.Log( example.m_name ); } }
InternalEditorUtility.SaveToSerializedFileAndForget で保存、
InternalEditorUtility.LoadSerializedFileAndForget で読み込みが可能