private void Awake() { m_interface = ARKInterface.GetInterface(); if (m_interface == null) { Destroy(this); } }
void Update() { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { var camera = GetCamera(); var ray = camera.ScreenPointToRay(Input.GetTouch(0).position); var layerMask = 1 << LayerMask.NameToLayer("ARObject"); RaycastHit hit; if (Physics.Raycast(ray, out hit, float.MaxValue, layerMask)) { GameObject go = Instantiate(m_objectToPlace, root); go.transform.position = hit.point; var pose = new Pose(); ARKInterface.GetInterface().TryGetPose(ref pose); var relativePos = pose.position - hit.point; go.transform.rotation = Quaternion.LookRotation(relativePos); } } }
protected virtual void SetupARInterface() { m_interface = ARKInterface.GetInterface(); }