Is there a way to get the Scene view to quickly zoom to what a Camera object is looking at? I was thinking along the same lines as the ‘f’ Focus hotkey.
It’s great that the Play view does that but I think it would be easier to manipulate objects in the Scene view if the two views matched.
The game window only shows what the camera sees so you have to move the camera. To do this select the main camera and hit Ctrl Shift F. The camera will then align with the scene view.
btw, you have it backwards: the “f” key focuses the Scene window not the game window.
I’m not referring to the Game window. I’m referring to the Scene window (the window where you can move around objects). I want the Scene window to snap to what my Game window is viewing.
I think it would be easier to manipulate objects while looking at the view the player will be seeing at the same time.
Though I’ll try the Cltr-Shift F hotkey when I get home from work today. Thanks!
Thanks. The option is called “Align View to Selected”.
Is there a way to create a shortcut key for this? I read that you can do that in System Preferences > Mouse and Keyboard. But I can’t find that menu in v.4.3. I see Edit > Preferences > Keyes but the options are limited.
@DanJ
some of the keys are modifiable in Edit/Preferences in Keys tab of the preferences window.
for others you should write simple editor script menus which have your hotkey. then in the menu’s function just execute the menu you want
for example do this in js
@MenuItem(“HotKey/Build%g”)
static function DoIt()
{
EditorApplication.ExecuteMenuItem(“File/Build”);
}
now with ctrl+g (%g) you can execute the build command. the drawback is that you’ll see the hotkey menu in your menu bar but maybe there is another way to do this that i forgot. for more information about assigning shortkeys to menus see the [MenuItem] in Editor classes of the scripting reference.
hope this helps
Maybe someone already created this and is generous enough to share?
This is my first time to post on the forum. So if I’ve done anything inappropriate please pardon me…
I use “Align View to Selected” very often recently, but I need to repeatedly go to “GameObject > Align View to Selected” and that’s not very handy I was wondering if there is a way to set a shortcut so I found this thread. I know this thread is old but I think this might help someone.
using UnityEngine;
using UnityEditor;
public class Hotkey : EditorWindow {
[MenuItem ("Hotkey/Align View to Selected %g")]
// Use this for initialization
static void Start () {
GameObject activeGO = Selection.activeGameObject;
SceneView.lastActiveSceneView.rotation = activeGO.transform.rotation;
Vector3 position = activeGO.transform.position + (activeGO.transform.forward * 10);
SceneView.lastActiveSceneView.pivot = position;
SceneView.lastActiveSceneView.Repaint();
}
}
// Reference:
// http://answers.unity3d.com/questions/802411/api-for-sceneview-class.html
// http://answers.unity3d.com/questions/26606/align-with-view-programmatically.html
// https://forum.unity3d.com/threads/moving-scene-view-camera-from-editor-script.64920/
I’m unfamiliar with SceneView but I just mess with the code and create this. Put this script in your project folder in a folder called Editor. Press Ctrl+G to fake “Align View to Selected”. (Well Ctrl+G is just a random one in fact I’ll change it later)
But it will not 100% work the same as “Align View to Selected”. The position is slightly different. But it suits my need for now. Maybe someone can make it better
Then again thank you @Hatsuko … I now use this solution to align my camera with a object. Because with this there is no position offset anymore (caused when using the scroll wheel and the old method)… but i’m still wondering, why we can not simply access the virtual scene view camera and just set the position. Ideally I don’t want to align with the selected object rotation, but only move to the position… something like: AlignViewPositionToObject.
That’s really cool. The fov is just not the same. Even when i set the SceneView’s camera’s fov equal to my Camera.main’s fov it still stays at ~55-60fov for some reason. Does someone know how I can set the FOV of the scene camera?
Based on your script, I made a new script called Hotkeys which searched for and found an object named “Spawn Point”, and moved my Scene View to 1.8m above it, so my Scene View would be where my avatar’s eyes were when I spawned into the world I’m building.
But wait! There’s more!
I then put a regular C# script on a Game Object, calling them both “HotkeysData”, to hold empty Game Objects which I put into fields on that Hotkeysdata. Then I modified that original Editor script so that it finds that HotkeysData Game Object, and can access all those other objects through it.
THEN I added more shortcuts to the Editor “Hotkeys script”, and ended up with:
Alt+Shift+F for Align View to Selected
Ctrl+G to move my Scene View to the Avatar’s eyes position;
Ctrl+RightArrow to cycle my Scene View through “View Point” Game Objects I set up at various locations (& orientations) I go to often;
Alt+LeftArrow to cycle in the reverse order.
Note1: I had to mark as “static” all the class variables and internal methods in the Hotkeys Editor script.
Note2: There is NO WAY to clone a Transform. So, in order to add the avatar height to the transform without modifying the original spawn point, I had to make my own semi-deep copy method to get something to submit to the AlignViewToObject() command.
Your script has opened up some power for me in being able to navigate quickly to distinct, pre-set points around my world. This will come in super-handy as the world gets bigger.