- Home /
How to use custom file types as Unity assets
I would to know if it is possible to have following custom features reachable from creating some scripts that will extend Unity editor:
custom file extension / file type, that will be handled by editor
accessibility to thumbnail of that asset, that is displayed in project window
dragging this asset to the scene as a full prefab (hierarchy of game objects), so I can say the asset should be a prefab type in its inside.
In my case an asset should represent generally a gameobject with some child gameobjects, where main gameobject should have mesh renderer and mesh filter to display model and child gameobjects should contain only box colliders and rigid bodies components.
How to achieve that?
I know that according to Unity editor, each prefab parts (components) must have assets that are imported to the project.
It is possible to have one file, that Unity will deal with like pack of prefab that can be dropped into scene, and corresponding assets - in one file?
How generally start work with this issue? What classes / attributes of Unity API will be useful here? Some help will be appreciated :)
Answer by Paulius-Liekis · Jun 27, 2014 at 05:49 PM
Strictly speaking Unity doesn't support custom asset/file types, but there are ways to fake it.
First of all look into AssetPostprocessor class and more specifically into OnPostprocessAllAssets (http://docs.unity3d.com/ScriptReference/AssetPostprocessor.OnPostprocessAllAssets.html). It gets called when any files change in project folder. I think that applies to custom files too. So what you can do is listed to OnPostprocessAllAssets and when that is called and there is your file-extension on the list then you generate your prefab from the file. So your file and prefab will be two separate assets in the project view, but that gets you close enough to having automated pipeline.
Some info regarding icons, although I'm not sure it answers your question: https://docs.unity3d.com/352/Documentation/Manual/GizmoandIconVisibility.html http://answers.unity3d.com/questions/7983/changing-the-inspector-titlebar-icon-and-text.html
Your answer
Follow this Question
Related Questions
How can I load an custom file from the Assets folder? 2 Answers
Using groups of prefabs between projects 1 Answer
Editing prefab fields from custom editor that are not automatically serialized 0 Answers
Prefab isn't centered on my cursor 0 Answers
When my scripts recompile or I enter play mode, my custom class gets reset 1 Answer