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

Custom asset formats - can someone from Unity Technologies support help?

Discussion in 'Editor & General Support' started by justinlloyd, Aug 7, 2011.

  1. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    I am attempting to create an asset importer that will read in a custom file format and have Unity recognise it, parse it, and place it in the asset database. I have chased my tail on this problem for the better part of two weeks trying to find the right combination of function calls and classes to make this work. I have investigated AssetPostprocessor, AssetImporter and read everything I could find on the forums, Unity answers, and every published book concerning Unity on how to do this particular task and nowhere is the process documented. The documentation of creating a custom asset importer and having Unity invoke it when an asset of that format is brought in to the Unity editor is obtuse and poorly detailed.

    I've asked on the forums (in two different ways), I've asked on Unity answers, and I have yet to see any response that addresses the problem.

    In all the years that Unity has existed I find it unbelievable that nobody (at least, nobody that reads the forums) has ever needed to import their own asset formats.

    Can someone from Unity Technology actually answer this question or direct me to a resource that solves it?
     
  2. bibbinator

    bibbinator

    Joined:
    Nov 20, 2009
    Posts:
    507
    Bump.

    I need to do this too. Anybody?
     
  3. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    There is no proper way to do this, i.e. Unity doesn't expose convenient way to perform this.

    I would say there are two parts:
    1) Import your custom file into Unity
    2) Trigger file import when file changes

    First part can be done by just writing some scripts, which open your file, parse it and create necessary prefabs/meshes/texture/hierarchies in Unity project.

    The second part is automating this process. I think the only way to do it is using AssetPostprocessor.OnImportAllAssets (or something like that). In that method you would have to check if any of your custom files have changed and then trigger reimport based on that.
     
  4. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    Thanks for the clarification. It is as I suspected. My solution at this time is to have separate asset processors that export to a recognised format that Unity is aware of or a custom binary format that I can interpret inside of Unity by reading the bytes directly from a "TextAsset."