Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Can I run a character animation in an editor window?

Discussion in 'Extensions & OnGUI' started by dgoyette, Jul 31, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    638
    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:

    upload_2018-7-30_17-45-56.png

    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
     
  2. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    279
    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.
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    638
    Awesome, thanks. Those were both things I knew nothing about. I'll take a look.
     
  4. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    126
    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