Search Unity

AssetDatabase.LoadAllAssetsAtPath issue

Discussion in 'Asset Database' started by martinmr, Feb 12, 2016.

  1. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    Hi everyone,

    just wanted to work with AssetDatabase.LoadAllAssetsAtPath, but figured out that it ins't working as i thought it would.

    I have some prefabs in Assets/Prefabs/FX/

    wanted to "load all assets at path" -> path Assets/Prefabs/FX/ but it doenst found anything.

    But when i make the path like Assets/Prefabs/FX/Cloud.prefab, he returns the prefab plus sub gameobjects in this prefab. in an Object Array.

    so basicly i still can't load alle prefabs /without sub gameobjects/

    can someone verify or tell me what i'm doing wrong ?
     
    Last edited: Feb 12, 2016
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,336
    The method works like it's documented.

    To get what you need (find all assets in a folder), you'll have to do it manually - use something like Directory.GetFiles to find all of the file names, and then pass the files you want (ie. ending in .prefab) to AssetDatabase.LoadAssetAtPath.
     
    GameRocker likes this.
  3. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    yep thanks, Directory.GetFiles was what i did first and than just found this LoadAll... stuff :)