Recenter or Reorient scene on Unity with Cardboard SDK

With Unity, the CardboardHead script is added to the main camera and that handles everything quite nicely, but I need to be able to “recenter” the view on demand and the only option I see so far is to rorate the entire scene and it seems like this is something the would address first-hand and I can’t find anything in the docs.

With Oculus Mobile SDK (GearVR), it would be OVRCamera.ResetCameraPositionOrientation(Vector3.one, Vector3.zero, Vector3.up, Vector3.zero); though they handle it nicely each time the viewer is put on so it’s rarely needed there.

P.S. Can’t add a “topic” because I’m new? Good way to keep new user segments from being affective (or adopting) this system. “Google Cardboard”

I asked this question the other day without seeing your question. I did something that worked for me and maybe it’ll help you and others. I’ll mention it here and on my own question for future searchers.

My biggest problem was that Cardbaord.SDK.HeadRotation is read-only and it’s a Quaternion that is stuck in 3D space and can’t be manipulated like you want. So instead of using the Cardboard.SDK.HeadRotation to directly control your camera game object’s position, I calculated the change in rotation between updates and applied that rotation to my camera game object.

I’m very new to this and I’m writing this example code off the top of my head, so there may be errors, but it’s close to what I’ve implemented that is working.

//used to set a game-object, such as a parent, as a point reference for resetting view
public Transform target;
private Quaternion prevRotation;

void Start () {
	//set your first rotation as starting head rotation
	prevRotation = Cardboard.SDK.HeadRotation;

}

void Update () {
	//on button push
	if (Input.GetButton ("Reset")) {
		//doesn't have to reset to target, can reset to anything you need
		//such as Quaternion.identity
		transform.rotation = target.rotation;

	} else {
	
		//here you set the the rotation to the difference between the current head
		//rotation and your previous head rotation
		var rot = Quaternion.Euler (Cardboard.SDK.HeadRotation.eulerAngles
						- prevRotation.eulerAngles);

		//add this difference to current rotation by using the Quaternion operator '*'
		transform.rotation *= rot;

	}

	//save the current head rotation as prevRotation to be used next update
	prevRotation = Cardboard.SDK.HeadRotation;

}

Please note I’m new to unity and programming in general, but this is currently working for the game I made, so I hope it helps!