Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Loading bunch of Scriptable Objects without Resources

Discussion in 'Editor & General Support' started by SHUN_GOKU_SATSU, Jun 1, 2018.

  1. SHUN_GOKU_SATSU

    SHUN_GOKU_SATSU

    Joined:
    Mar 30, 2018
    Posts:
    1
    So i making a startegy game with some rpg stuff mixed in it. I barely started to work with Unity and have not much programming experience.
    So i was wondering can i load in List bunch of Scriptable Objects (in my case it's Items) without using Resources.LoadAll (which i guess for my lack of experience is not even working lol) or any other Resources.whatever (i guess i should not teach my self to use resource folder).

    So i have Folder in my Assets "Scriptable Objects/Items" where i store bunch of items. My end goal is to have them automaticly be in List without any need to attach it somwhere manually or use Resources
    Is this even possible?

    (also excuse me for my terrible english)
     
  2. countlesschain

    countlesschain

    Joined:
    Jun 2, 2018
    Posts:
    6
    I don't know enough to help you find what you are looking for, however if you decide to use Resources.LoadAll i can offer some advice:

    In your asset folder you should have a folder named "Resources".
    Inside this resources folder you would have another folder with a group of items that you want to load into a script.
    For simplicity, you should make sure that this folder only contains the items you want to load, as loadall will load indiscriminately.

    So the your path to the prefabs or scriptable objects would be Assets/Resources/FolderOfStuff

    and you would use something like:

    Code (CSharp):
    1. Object[] spawnables = (Object[]) Resources.LoadAll("FolderOfStuff", typeof(Object));
    To put all those objects in a list.

    Hope that helps