Search Unity

Bad camera position when viewing transitions (with workaround)

Discussion in 'Animation' started by NoiseFloorDev, Jul 29, 2017.

  1. NoiseFloorDev

    NoiseFloorDev

    Joined:
    May 13, 2017
    Posts:
    104
    When I'm editing animation transitions, the camera is always stuck at the origin, even if the animation is taking place far off. I was originally going to ask if anyone knew what was going on, but I ended up picking apart the inspector and writing a workaround, so I thought I'd share it in case it's useful to anyone.

    There turned out to be a number of bugs:

    - It ignores meshes entirely if they aren't at least 3 hierarchy levels deep (?!). Mine are 2, and they'd be 1 if an asset had only a single mesh.
    - Determining which position to add for meshes is weird (compares the transform and the bounding box). I don't know how it's intended to work, but this just ignores meshes entirely for me.
    - It averages the position of everything in the animation to decide where to put the camera. However, if you have any dummy/helper objects in your asset, they'll count towards the average. I have lots of helper objects, and they're all at 0x0x0, so this pulls the preview towards the origin. (I'm guessing the "minimum depth" thing above is to prevent this from pulling in people's top-level groups...)
    - A related issue: the camera is reset every time you change the transition. Even when the above bugs aren't an issue, this one's a real headache when you're trying to fine-tune transitions.

    A script to work around these issues is attached. You can use it by dropping it into an Editor directory. It'll choose a more sensible pivot (at least for my assets), and fix the camera resetting every time you change the transition, which makes transitions a lot easier to edit. Note that this is a hack that rummages deep into the internals of the editor, so any update may break it ("voids your warranty", etc). Don't install this unless one of these issues is a problem for you.

    These all seem like simple things to fix internally (if I can even half-fix them from the outside with reflection), so hopefully this stuff will get fixed.

    Case 936144.
     

    Attached Files: