I have a custom editor script with an ObjectField where I can assign my custom implementation of ScriptableObject. After I assign a scriptable object I get its name and store it so it persists when I reboot Unity. Knowing the object’s name can I reassign the value to the ObjectField after rebooting Unity?
This makes no sense. The name of things are not necessarily unique in the first place. Also if you have a public / serialized field that references your scriptable object asset, that reference would be serialized as well if you created your “editor script” correctly. However since we don’t know what your editor script does, how and where you show your object field and where you want to store that reference we can not really help you here.
To directly answer your question: No there’s no built-in method to find an arbitrary asset by name. Apart from that when you build your game only used assets are included in the build. If the scriptable object is not (actually) referenced from an included scene (or a dependency of the scene) or placed inside the resources folder it won’t be part of the build.
To me that sounds a lot like you are not really familiar with Unity’s serialization system and how the editor works. Since you have a specific problem you should post all relevant information on that problem. You just came up with a strange workaround-approach which just doesn’t work and asked how this can be done. Tell us what you actually want to do, what you currently do (include the relevant code, and where it’s called from) and what exactly isn’t working.
If the path in your project folder is persistent you can use that and the name of the object, otherwise I would store the path instead of the name since the name can always be received from the path in case you need it and that’s just faster, better and easier in all ways and honestly, using a text object or most other methods really would probably suit you better. But if you still prefer to have it only save the name, here is a simple example of a script that loads a ScriptableObject by it’s name (be it alot more resource intensive than storing the path itself):
ScriptableObject so = (ScriptableObject) AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("NAME OF SCRIPTABLE OBJECT")));
Obviously replace the “NAME OF SCRIPTABLE OBJECT” with the actual name of the object and “ScriptableObject” with the name of your ScriptableObject class. Hope this helps you and good luck!