protected override void JavaFinalize() { // If the anchor object is destroyed, call the detach() method to instruct // the AR Engine to stop tracking the anchor. if (mArAnchor != null) { mArAnchor.Detach(); } base.JavaFinalize(); }
private void _DrawARLogo(Touch touch) { List <ARHitResult> hitResults = ARFrame.HitTest(touch); ARHitResult hitResult = null; ARTrackable trackable = null; Boolean hasHitFlag = false; ARDebug.LogInfo("_DrawARLogo hitResults count {0}", hitResults.Count); foreach (ARHitResult singleHit in hitResults) { trackable = singleHit.GetTrackable(); ARDebug.LogInfo("_DrawARLogo GetTrackable {0}", singleHit.GetTrackable()); if ((trackable is ARPlane && ((ARPlane)trackable).IsPoseInPolygon(singleHit.HitPose)) || (trackable is ARPoint)) { hitResult = singleHit; hasHitFlag = true; if (trackable is ARPlane) { break; } } } if (hasHitFlag != true) { ARDebug.LogInfo("_DrawARLogo can't hit!"); return; } if (addedAnchors.Count > 16) { ARAnchor toRemove = addedAnchors[0]; toRemove.Detach(); addedAnchors.RemoveAt(0); } GameObject prefab; trackable = hitResult.GetTrackable(); if (trackable is ARPlane) { prefab = arDiscoveryLogoPlanePrefabs; } else { prefab = arDiscoveryLogoPointPrefabs; } /* * ARAnchor anchor = hitResult.CreateAnchor(); * var logoObject = Instantiate(prefab, anchor.GetPose().position, anchor.GetPose().rotation); * logoObject.GetComponent<ARDiscoveryLogoVisualizer>().Initialize(anchor); * addedAnchors.Add(anchor); */ }
private void _DrawARLogo(Touch touch) { List <ARHitResult> hitResults = ARFrame.HitTest(touch); foreach (ARHitResult singleHit in hitResults) { ARTrackable trackable = singleHit.GetTrackable(); if (trackable is ARPlane && ((ARPlane)trackable).IsPoseInPolygon(singleHit.HitPose)) { if (addedAnchors.Count > 16) { ARAnchor toRemove = addedAnchors[0]; toRemove.Detach(); addedAnchors.RemoveAt(0); } ARAnchor anchor = singleHit.CreateAnchor(); var logoObject = Instantiate(arDiscoveryLogoPrefabs, anchor.GetPose().position, anchor.GetPose().rotation); logoObject.GetComponent <ARDiscoveryLogoVisualizer>().Initialize(anchor); addedAnchors.Add(anchor); break; } } }
private void _DrawARLogo(Touch touch) { List <ARHitResult> hitResults = ARFrame.HitTest(touch); ARDebug.LogInfo("_DrawARLogo hitResults count {0}", hitResults.Count); foreach (ARHitResult singleHit in hitResults) { ARTrackable trackable = singleHit.GetTrackable(); ARDebug.LogInfo("_DrawARLogo GetTrackable {0}", singleHit.GetTrackable()); if ((trackable is ARPlane && ((ARPlane)trackable).IsPoseInPolygon(singleHit.HitPose)) || (trackable is ARPoint)) { GameObject prefab; if (trackable is ARPlane) { prefab = arDiscoveryLogoPlanePrefabs; } else { prefab = arDiscoveryLogoPointPrefabs; } if (addedAnchors.Count > 16) { ARAnchor toRemove = addedAnchors[0]; toRemove.Detach(); addedAnchors.RemoveAt(0); } ARAnchor anchor = singleHit.CreateAnchor(); var logoObject = Instantiate(prefab, anchor.GetPose().position, anchor.GetPose().rotation); logoObject.GetComponent <ARDiscoveryLogoVisualizer>().Initialize(anchor); addedAnchors.Add(anchor); break; } } }