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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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,199
    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 :)