#Loading prefabs from Scriptable Object to create levels

1 messages · Page 1 of 1 (latest)

lone geode
#

I am trying to create levels for my casual 2d mobile game. I can create levels in individual scenes. But I was wondering if there is way to store all the prefabs required for a level in a scriptable object and load it at runtime. The challenge I am facing here is that I am not able to assign transform to scriptable object by drag and drop, I want this info to instantiate objects at a particular position and rotation. Is it possible to do, and is it a good idea to do?

cursive hawk
#

template scenes are what your looking for.

you just save your scene and then every scene you make will have the objects.

#

if you really want to do it in runtime, just use a root prefab that has all the objects in its children.

#

scriptable objects are not to be used in this way.

crisp slate
#

Scriptable Object is not necessary for this, you can have a class that could store all prefabs using the Resources.Load method, and then at start of a scene you instantiate the desired prefabs

wraith arrow
#

Please don't do that

#

Either use AssetBundles or Addressables

#

Resources.Load is a huge memory hit for no reason lmfao, especially without proper asset management and cleanup

crisp slate
faint flicker
#

Unity themselves recommend to not use the Resources system anymore: https://learn.unity.com/tutorial/assets-resources-and-assetbundles#5c7f8528edbc2a002053b5a7

Unity Learn

This is a series of articles that provides an in-depth discussion of Assets and resource management in the Unity engine. It seeks to provide expert developers with deep, source-level knowledge of Unity's Asset and serialization systems. PLEASE NOTE: this tutorial has now been deprecated. We now recommend using Addressables for your projects and ...