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

Get all prefab assets

Discussion in 'Scripting' started by xonnex, Jul 29, 2015.

  1. xonnex

    xonnex

    Joined:
    Jun 26, 2015
    Posts:
    8
    Hello!

    I've just found that the function AssetDatabase.GetDependencies doesn't seem to work for my purpose. I was hoping to be able to pass one pathName to the function and get a list of the assets it depends on. The returned string[] only contains the prefab name when I do this though. When I pass two or more prefab names, I get a list of assets which appears to be assets they all share, which doesn't help me.

    I've tried to find a different approach to the problem but I am stuck now. How can I find out what assets a prefab needs?
     
  2. xonnex

    xonnex

    Joined:
    Jun 26, 2015
    Posts:
    8
    Obviously Unity knows what assets to load when I call Resources.Load on a prefab, but it doesn't seem to be exposed to the users. Do I really have to parse the prefab file to get this information?
     
  3. xonnex

    xonnex

    Joined:
    Jun 26, 2015
    Posts:
    8
    I will sort of answer the question myself. The issue isn't with the function, the issue is in the prefab itself. I will continue to investigate the issue, but I can verify that the function DOES work for a single pathName. One can argue it's wierd that the function doesn't contain overloads for single files though.