[Feature Request]

It would be super usefull if we would be able to reference a prefab or a scriptable object with option that it wouldn’t automatically load into memory. Right now the only possible way to do it is to save a path of the prefab/scriptable object, place it under Resources folder and than load it with Resources.Load. This is super error prone and time consuming. What I propose is an attribute or some similar solution which would enable you to manually load the object into the memory. Here is an example:

You can do this with a child class that contains all of the data you need but no implementation. You cannot have a static member of the type of the child class that you can reference directly. You would need to manage multiple instances of the class yourself though

I’m not exactly sure what you mean. In any case I would have to store string and even then I’d have to track prefab for possible path changes. It would be much easier if this would be implemented in Unity.

You could use a generic [SO] type that hides the loading part and either allows loading at startup, async loading at startup, lazy loading, async lazy loading and so on.
(edit: @Grizmu has found an actual built-in solution to that, see the post below)

You’re right when you come up with the other concerns, which are:

In this case, I’d recommend to take a look at Unity’s Addressable system. They also support async loading and probably loading on demand as well.

@IcyHammer
You are in luck. It has been added in the 2019.3 editor and is already available in the alpha. Here are the docs.

3 Likes

@Grizmu Nice, that’s a first time something like this happened to me haha :slight_smile:

@Grizmu unfortunately it works like described only in editor, in standalone player it automatically loads all referenced assets as usual.

Oh, you are right.

That’s a bummer. Looks like we’ll have to stick to addressables, resources and asset bundles for runtime for the time being.