public void initStart() { analytic.time_startFindPlane = Time.time; planePrefab.SetActive(true); UnityARHitTestExample hitScript = hitParent.GetComponentInChildren <UnityARHitTestExample>(); unityARAnchorManager = new UnityARAnchorManager(this, hitParent, hitScript, Camera_managerScrpt); UnityARUtility.InitializePlanePrefab(planePrefab); }
public UnityARAnchorManager(UnityARGeneratePlane plane, GameObject hitParent, UnityARHitTestExample sharp, UnityARCameraManager camera_manager) { planeAnchorMap = new LinkedListDictionary <string, ARPlaneAnchorGameObject> (); UnityARSessionNativeInterface.ARAnchorAddedEvent += AddAnchor; UnityARSessionNativeInterface.ARAnchorUpdatedEvent += UpdateAnchor; UnityARSessionNativeInterface.ARAnchorRemovedEvent += RemoveAnchor; generatedPlane = plane; hitScript = sharp; Camera_managerScrpt = camera_manager; }
void Awake() { m_HitTransform = transform; ListMenu = GameObject.Find("MenuList"); HelpPlane = GameObject.Find("HelpWord_Plane"); Instance = this; }
// Update is called once per frame void Update() { if (Input.touchCount > 0 && m_HitTransform != null) { hitScript = gameObject.GetComponent <UnityARHitTestExample>(); var touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved) { var screenPosition = Camera.main.ScreenToViewportPoint(touch.position); ARPoint point = new ARPoint { x = screenPosition.x, y = screenPosition.y, }; // prioritize reults types ARHitTestResultType[] resultTypes = { ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent, // if you want to use infinite planes use this: //ARHitTestResultType.ARHitTestResultTypeExistingPlane, ARHitTestResultType.ARHitTestResultTypeHorizontalPlane, ARHitTestResultType.ARHitTestResultTypeFeaturePoint }; foreach (ARHitTestResultType resultType in resultTypes) { if (HitTestWithResultType(point, resultType)) { return; } } } } }