Can scene camera follow the object?

There is a GameOjbect(walker) in My scene,and it move fast when in play mode,
And I have to adjust other GameOjects’ position around the walker,
Can I use a script or something else to control the scene’s camera (note:not the camera in play mode).

[EDIT: as of Unity 4.3, press Shift-F to lock the scene view to the selected object]

To control the SceneView’s camera, you have to use some undocumented (and therefore: officially not supported) methods.

SceneView.lastActiveSceneView.camera.pivot allows you to directly alter the pivot point of the sceneView camera. Using some other standard camera functions this should allow you to do what you want.

Scripts using this need to be in an Editor folder.

If you really want to do this I suggest you decompile UnityEditor.dll and have a look in the SceneView and the Camera classes.

I just wrote a script that allows multiple SceneViews to follow a gameobject in edit and play mode. I uploaded it to the Unity3d Wiki: http://wiki.unity3d.com/index.php/SceneViewCameraFollower Check it out.

I’m not certain when this feature was introduced, but as of Unity 4.3 you can press Shift-F (or double-tap F) to lock the scene camera to the selected object. When the object moves, the scene camera will follow it.

See hotkey documentation.

In 2020 Version It’s Shift + F.

//Allows multiple SceneView cameras in the editor to be setup to follow gameobjects.
//October 2012 - Joshua Berberick

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
 
[ExecuteInEditMode]
public class SceneViewCameraFollower : MonoBehaviour
{
#if UNITY_EDITOR
 
	public bool on = true;
	public bool onlyInPlayMode = false;
	public SceneViewFollower[] sceneViewFollowers;
	private ArrayList sceneViews;
 
	void LateUpdate()
	{
		if(sceneViewFollowers != null && sceneViews != null)
		{
			foreach(SceneViewFollower svf in sceneViewFollowers)
			{
				if(svf.targetTransform == null) svf.targetTransform = transform;
				svf.size = Mathf.Clamp(svf.size, .01f, float.PositiveInfinity);
				svf.sceneViewIndex = Mathf.Clamp(svf.sceneViewIndex, 0, sceneViews.Count-1);
			}
		}
 
		if(Application.isPlaying)
			Follow();
	}
 
	public void OnDrawGizmos()
	{
		if(!Application.isPlaying)
			Follow();
	}
 
	void Follow()
	{
		sceneViews = UnityEditor.SceneView.sceneViews;
		if(sceneViewFollowers == null || !on || sceneViews.Count == 0) return;
 
		foreach(SceneViewFollower svf in sceneViewFollowers)
		{	
			if(!svf.enable) continue;
			UnityEditor.SceneView sceneView = (UnityEditor.SceneView) sceneViews[svf.sceneViewIndex];
			if(sceneView != null)
			{
				if((Application.isPlaying && onlyInPlayMode) || !onlyInPlayMode)
				{
					sceneView.orthographic = svf.orthographic;
					sceneView.LookAtDirect(svf.targetTransform.position + svf.positionOffset, (svf.enableFixedRotation) ? Quaternion.Euler(svf.fixedRotation) : svf.targetTransform.rotation, svf.size);	
				}
			}
		}	
	}
 
	[System.Serializable]
	public class SceneViewFollower
	{
		public bool enable;
		public Vector3 positionOffset;
		public bool enableFixedRotation;
		public Vector3 fixedRotation;
		public Transform targetTransform;
		public float size;
		public bool orthographic;
		public int sceneViewIndex;
 
		SceneViewFollower()
		{
			enable = false;
			positionOffset = Vector3.zero;
			enableFixedRotation = false;
			fixedRotation = Vector3.zero;
			size = 5;
			orthographic = true;
			sceneViewIndex = 0;
		}
	}
 
#endif
}

Hi,
don’t know if someone is still looking for it, I wrote a small extension to Blender Camera Controls Window (by Will Traxler) which is an extension of Blender Camera Controls (by Marc Kusters).

You can find it here: GitHub - sikandarchishty/Blender-Camera-Controls-for-Unity

It works in Editor as soon as Unity is opened.

Please note, this works if you are in scene window and not inspector etc. (ofcourse that’s how its supposed to work :stuck_out_tongue: )

and it works in all newer versions.

There’s a script named ‘SmoothFollow’ in the standard assets. Add it to the camera and drag the object you want it to follow into the ‘Target’ slot of the script