Search Unity

How to put the animation preview window in a custom editor script

Discussion in 'Immediate Mode GUI (IMGUI)' started by arisonu123, Mar 16, 2017.

  1. arisonu123

    arisonu123

    Joined:
    Feb 19, 2015
    Posts:
    26
    Hi! I am making a custom editor script with several different editor windows. I want to be able to preview what my stuff does in an animation preview window(My scripts are making changes to events that occur in an animation). I have been looking but have been unable to find out how I can make an animation preview show up as an editor window for my custom editor scripts. I just want that little window that you can drag a model into and see a preview of the animation to appear whenever I go to the create menu and click to create one of my custom objects with my custom editor script. I also want to be able to tell it do something else whenever the user clicks the play button on the preview window. Is this possible?
     
  2. marijnz

    marijnz

    Joined:
    Sep 20, 2012
    Posts:
    67
    A lot of this stuff is internal thus can't be easily accessed. However PreviewRenderUtility is openly accessible and can be used to preview models. Animating them isn't trivial, and some looking into this a while ago, showed me it would require quite some reflection to internal stuff and maybe some copying of code to make it work. Shouldn't take too long, but could maybe eat up some time and will of course result in very brittle code..

    See for yourself where PreviewRenderUtility is used in https://github.com/MattRix/UnityDecompiled/. The most relevant for you is probably AvatarPreview. Well, let me know how it goes and good luck! :)