Can it be done: Export a ScriptableObject asset to be used in another project

Howdy all, I am creating an .asset file from a ScriptableObject I have storing some basic information:

using UnityEngine;

public class CompiledBuild : ScriptableObject
{
    public string[] WordStrings;
    public Color[][] WordColors;
    public int ChunkSizeMs;
    public int FrameLengthChunks;
    public int DownSampleFactor;
    public string NetworkConfig;
}

The asset I am creating seems to be all good. I am creating these assets from an “Editor” project of mine and I intend to import these “CompiledBuild” assets into a separate “Game” project (the editor code is in no way needed to ship with the game so it is a separate project), however I am having trouble reading the .asset file within the main game project. I have this CompiledObject class in both projects (I have even tried placing them in exactly the same location in the project heirarchy) and they are identical, however it doesn’t seem like Unity can read the exported asset if I paste it into the main game Project. If I have an object reference to a CompiledBuild object in the scene the Inspector shows there are no CompiledBuild assets, and if I click to drag the asset into the reference the text while dragging says “Nothing Selected” (the string hardcoded into Unity for missing script references).

My question is this: Is sharing an .asset file between projects possible? Or are they tied to the project they were created in. I have also tried right-clicking my asset and choosing “Export Package”, but the export window seems to want to include my entire project of script files as “dependencies” even though it is a pure ScriptableObject class.

Is it possible? Or do I need to share my data differently? Any help much appreciated. I have searched around for this a fair amount online but cannot find anybody who is trying to share assets like this.

You’re on the right track. You will need to export is as a custom package. In the export window you can select/deselect anything you want to be in the package. Be careful, you will want to include the asset file, the source file (the corresponding .cs file with the type in it).
And you can simply import it in the other project. Feel free to deselect the project and select only the proper files in the export, you just need to know your exact dependencies.

2 Likes

Is Unity finally able to de/serialize multi-dimensional arrays?

Ah, it works! Interesting. I exported it with the CompiledBuild.cs file as well and it seemed to maintain the link after I imported it. I don’t quite know how that works, but it seems to. Oh, maybe it links specifically to the GUID of the ScriptableObject? Perhaps I won’t have to export it like that any more now that the GUID has updated. I will continue to investigate. This has definitely unblocked me now, thanks for your help!