private void Awake() { m_interface = ARKInterface.GetInterface(); if (m_interface == null) { Destroy(this); } }
/// <summary> /// Returns the currently used interface. /// If no interface has been specified, creates the correct one depending on the device. /// </summary> public static ARKInterface GetInterface() { if (m_interface == null) { //TODO: SPECIFIC INTERFACES, FACTORY REFACTO? #if UNITY_IOS m_interface = new ARK_ARKit(); #endif // #if UNITY_EDITOR // m_Interface = new AREditorInterface(); // #elif UNITY_IOS // m_Interface = new ARKitInterface(); // #elif UNITY_ANDROID // m_Interface = new ARCoreInterface(); // #endif } return(m_interface); }
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); } } }
//TODO: DOC, is this method useless? public static void SetInterface(ARKInterface _interface) { m_interface = _interface; }
protected virtual void SetupARInterface() { m_interface = ARKInterface.GetInterface(); }