Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Subfolders in Resources

Discussion in 'Editor & General Support' started by khanstruct, Dec 21, 2012.

Thread Status:
Not open for further replies.
  1. khanstruct

    khanstruct

    Joined:
    Feb 11, 2011
    Posts:
    2,869
    Can someone tell me if there's an issue in Unity 4 that causes problems with sub directories in your Resources folder when using Resources.Load?

    I tried loading a texture from a sub folder within the Resources folder and it kept returning null. I double and triple checked my spelling and capitalization; even trimmed down the folder and texture name to A and B to be sure.

    I moved the same texture to the root Resources folder, and it loaded just fine.

    I haven't submitted a bug report yet, because I want to be sure its not just something dumb on my end. Has anyone else had any issue with this?
     
  2. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    When you do the Load just prefix with the folder name:

    Resource.Load("subfolder/yourasset");

    For instance.. my resources folder looks like this

    Resources
    --- Aliens
    --- Environment
    --- Ships

    So the code I use is:

    GameObject go = (GameObject)Instantiate(Resources.Load("Ships/Quintet"));
     
  3. khanstruct

    khanstruct

    Joined:
    Feb 11, 2011
    Posts:
    2,869
    That's exactly what I was doing. It doesn't work.
     
  4. RazorCut

    RazorCut

    Joined:
    May 7, 2009
    Posts:
    393
    Show actual code then.
     
Thread Status:
Not open for further replies.