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

Resources.Load subfolders

Discussion in 'Editor & General Support' started by Cleroth, Jul 22, 2013.

  1. Cleroth

    Cleroth

    Joined:
    Jul 11, 2012
    Posts:
    25
    It seems that using subfolders inside Resources no longer works with Resources.Load

    Examples:

    Works:
    Code (csharp):
    1. var ind = Instantiate(Resources.Load("Indicator", typeof(GameObject))) as GameObject;
    Folder structure:
    Resources
    — Indicator.prefab

    According to this and a few other sources, this should work, yet it doesn't:
    Code (csharp):
    1. var ind = Instantiate(Resources.Load("UI/Indicator", typeof(GameObject))) as GameObject;
    Folder structure:
    Resources
    — UI
    — — Indicator.prefab

    According to the documentation :
    If it's relative, then it should be working.

    The only other way I've found to be able to organize the assets is to put a "Resources" folder inside every asset category. This really doesn't seem ideal to me, and will most likely result in a mess:

    Code (csharp):
    1. var ind = Instantiate(Resources.Load("Indicator", typeof(GameObject))) as GameObject;
    Folder structure:
    Resources
    — UI
    — — Resources
    — — — Indicator.prefab

    Does Unity really not support subfolders inside Resources anymore? Or am I doing something wrong? I've been trying to wrap my head around something I must be doing wrong, but it's getting quite frustrating and I've found no reason for it not to work.
     
  2. WilB

    WilB

    Joined:
    Oct 25, 2012
    Posts:
    17
    I've just run into the same problem - almost. If I put a TextAsset file at "Resources/Data/foo.txt" it loads fine, but if I locate it as "Resources/Media/Page01/Stage01/foo.txt" it fails to load. Huh??