Can I run a character animation in an editor window?

I’m about to embark on a small project to make my life easier, and I was hoping for a sanity check from someone regarding whether some/all of the following is technically feasible within a Unity Editor window.

In my game I have a little video screen that pops up occasionally, showing a person who tells you things. I call the guy and his functionality my “Comm Studio”. He basically talks, and performs animations (like gesturing, typing, etc), and I have a 3rd party LipSync program that synchronizes his mouth to the dialog he’s speaking. I also have some settings to control when the video has intentional static/distortion, and to control whether the guy is looking into the camera or looking where the current animation tells him to look.

Functionality wise, it works well. I’m using an Animation Clip to the Distortion and CameraLookWeight using keyframes. And I’m using AnimationEvents to have him transition from one animation to another at specific points in the clip. For example:

So this works, but it doesn’t provide me with any kind of “preview”. My plan is to create an editor window to be able to play each “clip”, which should show the following somewhere within the editor window:

  • The character model should play any animations it’s been told to play.
  • The animation events should fire.
  • The keyframed values should be sent to the underlying object, just like if I was in Play mode.
  • The audio will play.

So, really, my essential question is whether it’s possible for an editor window to be linked to its own custom scene (not the scene that is currently opened), and for animations to play within the editor window?

Thanks,

-Dan

There is an undocumented class called PreviewRenderUtility that might be able to do what you want, though I am unsure about animations or other runtime constructs.

If PreviewRenderUtility doesn’t work out, you can create objects in the scene that are hidden and unsaved using HideFlags.HideAndDontSave. Animator has APIs that allow you to run animations manually during the editor.

Awesome, thanks. Those were both things I knew nothing about. I’ll take a look.

Hi preview render utility is okay, but it gets tricky when you do more advanced things such as rotating/panning/zooming the camera.

luckily I ripped out the animation viewer code which should make things easier for you if you want to go down this root

https://cdn.discordapp.com/attachments/236733544569765892/446342855490011136/window.cs
this was a few months ago, so this may not be insync with the latest unity code