Scene Shot Bookmarks in Unity
The purpose of this article is to visit an internal (and currently undocumented)
UnityEditor class that is useful for making Scene View custom editors.
Additionally, I'll introduce an open source custom editor called Scene Shot Bookmarks that speeds up authoring and level design by bookmarking numerous Scene View camera angles.
Scene View Limitations
Currently, there are only two built-in ways to update the Scene View:
- Manually pan, zoom, and rotate the Scene View with mouse and keyboard
- Interact with the Scene View gizmo to quickly change the Scene View camera angle and/or the perspective style
Scene View gizmo is rad, but limited
Both are really handy tools, but their use is limited. Additionally, both are slow when you want to quickly reconfigure the Scene View camera angle to a previous vantage point. I figured there was a better way and upon a little research I found out that there was.
Unity has an undocumented
SceneView class that provides a great way to dynamically change the Scene View with a custom editor. This is exactly what I wanted, access to the Scene View itself through code.
Scene Shot Bookmarks
I created the Scene Shot Bookmarks custom editor to answer one simple question:
Here is an example screenshot of the custom editor for reference:
Scene Shot Bookmarks
Once the Scene Shot Bookmarks editor is open, you can do one of two things:
- Save the current Scene View camera state (Bookmark button)
- Instantly reset the Scene View to a bookmarked camera angle (# button)
That's it. It is a really simple, but useful tool. I additionally used the
ScriptableObject class as opposed to EditorPrefs for persisting saved bookmarks. So, in addition to the two core aforementioned functions of Scene Shot Bookmarks, you can:
- Share bookmarks with your team (via source control)
- Persist bookmarks after closing and reopening Unity
- Associate nicknames to bookmarks for context
- Change the bookmark count via the Inspector Window
Here is a sample shot showcasing how simple it is to change the Scene Shot Bookmark UI to fit your game or application:
Scene Shot Bookmarks - Custom Count
You can get Scene Shot Bookmarks on Github.
If you end up forking and building off it, I'd love to see what you come up with. Ping me on Twitter @derekknox if so and/or if you have any questions or comments.