A Unity ARFoundation Android Application
This is an Augmented Reality application that uses plane detection to provide a way for the user to place Virtual 3D objects on a plane. It also features some basic functionality with on-screen gestures to scale, rotate, and move virtual objects.
Project Demo:
Screenshots:
Code Sample:
private void UpdatePlacementPose()
{
var screenCenter = Camera.current.ViewportToScreenPoint(new Vector3(0.5f, 0.5f));
var hits = new List();
arOrigin.GetComponent().Raycast(screenCenter, hits, UnityEngine.XR.ARSubsystems.TrackableType.PlaneEstimated);
placementPoseIsValid = hits.Count > 0;
if (placementPoseIsValid)
{
placementPose = hits[0].pose;
var cameraForward = Camera.current.transform.forward;
var cameraBearing = new Vector3(cameraForward.x, 0, cameraForward.z).normalized;
placementPose.rotation = Quaternion.LookRotation(cameraBearing);
}
}