- Home /
Intercept file import
Is it possible in Unity to override / add to the default automatic asset import behavior? I would like to add custom behavior to the way that Unity handles Modo lxo files. Ideally I would like to be able to completely take over the import procedure for certain lxo files that the user could specifies.
Answer by Bunny83 · May 05, 2012 at 01:30 PM
You might be able to use AssetPostprocessor.OnPostprocessAllAssets. If it's not a supported asset type it is usually recognised as "TextAsset" so you can access it as binary data. If you want a custom inspector for the asset itself you could try to implement your own editor for TextAsset (so you replace the old TextAssetInspector which is an internal class).
I never tried something like that. I'm also not sure if Unity will treat such assets as TextAssets but if it does it should work.
edit
I'm pretty sure that you can't create your own assettype. Unity can't handle that in their assetdatabase.
$$anonymous$$odo is one of the supported packages, and lxo is an accepted asset type to Unity. I am trying to override the default behavior for these particular types of asset in Unity. I believe what you have given me is enough to accomplish my goal, thanks!
Sorry, I'm not an artist and I've never come across a lox file ;) So it's basically just a model. Unity uses the collada exporter of modo since Unity only supports ".FBX, .dae, .3DS, .dxf and .obj"
$$anonymous$$odel assets are fully processed by an AssetPostprocessor so you can change anything afterwards.
$$anonymous$$eep in $$anonymous$$d that Unity doesn't use the asset itself. $$anonymous$$odel-assets are represented be it's importer. The importer will create sub assets (which are stored in the library folder in the assetdatabase). Those sub assets are usually the mesh data as seperate $$anonymous$$esh, the bone hierarchy as a GameObject tree and animations as anim assets.
You can add your own stuff as sub assets to any kind of asset via AssetDatabase.AddObjectToAsset. But like stated in the docs when you reimport the asset such sub assets will be lost.
Oh so is it not possible to tell Unity not to import anything from the lxo at all? $$anonymous$$y goal is to mark certain assets to not be imported by Unity but to defer all processing to my script, which will process the file.
No that's not possible. You could rename the file to .txt so it's just a text asset and Unity won't do any processing with it, but you can read the content in an editor script. See TextAsset
Answer by deus_duke · May 07, 2012 at 04:35 AM
Ah that's different then what I had in mind but it works. Thanks for all your help!
Your answer