- Home /
Saving an object from script to project?
We're trying to create an editor for our project so our art team can plug stuff in easily without having to learn Unity. So we've got it mostly laid out and now we're trying to save objects created through our editor (so GameObjects created via c# code) and put those in the project hierarchy (not to be confused with the Scene Hierarchy). So what do we need to do to make this happen?
We figured out that we need AssetDatabase.CreateAsset(asset, pathname), but now if we try to use it using Resources.Load it returns null, unless we just saved it with our editor window. So if we make something, hit save, we can immediately hit load. But if we close Unity, reopen Unity, then hit load, we get a null error.
So basically it's keeping it in memory when it saves it and can find the reference somehow, but that reference is lost when close Unity (or at least that's what appears to be happening..)
$$anonymous$$ight be a bug (I've never tried, so not sure). Have you tried to report it ?
Were you able to find a solution to this issue? I'm having the same problems. I have 4 of one kind of scriptableobject resource that I'm trying to load. It loads the last resource I created, but not the others.