Search Unity

Custom inspector for an asset type.

Discussion in 'Immediate Mode GUI (IMGUI)' started by Titan8190, Mar 23, 2015.

  1. Titan8190

    Titan8190

    Joined:
    Feb 16, 2013
    Posts:
    29
    Hi,

    I am looking for a way to make a custom inspector for a file type, I would like to achieve the same result as .fbx files for exemple, I would also like unity to generate a preview to use as custom icon in the asset hierarchy and even call my code when a file of this type is dragged into the scene.
    Is it possible to do that ? I can't find anything in the documentation about it.
     
  2. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    it is possible, I did it with XML once, pain in the ass though!

    But are you trying to do what I did and edit a asset type that does't exist within unity? or are you trying to write a editor for something like a scriptable object?
     
  3. Titan8190

    Titan8190

    Joined:
    Feb 16, 2013
    Posts:
    29
    To give you some context, I am making a hexagonal grid based terrain, I have an "HexaTerrain" class that procedurally generate the mesh from an array inside a binary file that I called ".hex".
    I managed to make a nice inspector for my HexaTerrain with brushes etc (I'm triing to be as close as possible to the unity built-in Terrain).

    But the file placed in my asset folder, has the default white icon with an empty inspector.
    I would like an icon to preview the map inside the browser, and when I select my "test.hex" file, have an inspector that display its Width and length, maybe load the mesh in a preview 3D window and have a bouton "Load into the current scene" or drag it to the scene view.
    The problem is that I only know how to make an inspector for a Monobehavhiour and don't know anything about unity's file browser's icon system. I think you did what I am trying to do.
     
  4. Titan8190

    Titan8190

    Joined:
    Feb 16, 2013
    Posts:
    29
    I have solved my problem by making my data as ScriptableObject with a binary importer/exporter. So I can have a my custom inspector and serialization also help me to not reload everything everytime I click play.
    But I'm still interested by your method smitchell.