Function to move object to scene view

I am working on an editor tool. I need to call Gameobject/Move To View from script. Please share the method. Also, how do I open the lighting window from script?

Hi Harsh,

This is not a polished solution, but should get you started so you can customize it to your needs.

void MoveToSceneView() {
	SceneView.FocusWindowIfItsOpen<UnityEditor.SceneView>();  // Might not need to focus
	if (SceneView.lastActiveSceneView == null) {              // and not sure if it's ever null.
		return;
	}

	Camera cam = SceneView.lastActiveSceneView.camera;
	GameObject gameO = Selection.activeGameObject;

	if (cam == null || gameO == null) { return; }

	float distanceFromCam = (gameO.transform.position - cam.transform.position).magnitude;
	Undo.RecordObject(gameO.transform, "MoveToSceneView Script");
	gameO.transform.position = cam.transform.position + cam.transform.forward * distanceFromCam;
}