public void SpawnWorldRootBAnchor() { worldRootBAnchor = FindObjectOfType <WorldRootBAnchor>(); // Spawn if not found if (worldRootBAnchor == null) { WorldRootBAnchor worldRootBAnchorPrefab = Resources.Load <WorldRootBAnchor>(BConsts.PATH_AR_WorldRootBAnchor); if (IS_NOT_NULL(worldRootBAnchorPrefab)) { worldRootBAnchor = Instantiate(worldRootBAnchorPrefab, Vector3.zero, Quaternion.identity); } } // Initialize if (IS_NOT_NULL(worldRootBAnchor)) { worldRootBAnchor.BAnchorMovedToTracker += On_WorldRootBAnchor_BAnchorMovedToTracker; BAnchorCursorPlacer worldRootBAnchorCursorPlacer = worldRootBAnchor.GetComponent <BAnchorCursorPlacer>(); if (IS_NOT_NULL(worldRootBAnchorCursorPlacer)) { worldRootBAnchorCursorPlacer.EndedPlacing += On_WorldRootBAnchorCursorPlacer_EndedPlacing; } BEventsCollection.AR_WorldBAnchorSet.Invoke(new BEHandle <BAnchorInformation>(worldRootBAnchor.GetBAnchorInformation())); } }
public void SetWorldRootBAnchor(WorldRootBAnchor worldRootBAnchor) { if (WorldRootBAnchor != null && WorldRootBAnchor != worldRootBAnchor) { LogConsoleWarning("Overwriting World Root BAnchor!"); } WorldRootBAnchor = worldRootBAnchor; }
private void OnTrackedImageUpdated(ARTrackedImage trackedImage) { string trackedImageName = trackedImage.referenceImage.name; if (IS_KEY_CONTAINED(trackedImagesMap, trackedImageName)) { // Check if World Root Anchor should stay fix WorldRootBAnchor worldRootBAnchor = (WorldRootBAnchor)trackedImagesMap[trackedImageName]; if (FixWorldRoot == true && worldRootBAnchor != null) { return; } trackedImagesMap[trackedImageName].transform.position = trackedImage.transform.position; trackedImagesMap[trackedImageName].transform.rotation = trackedImage.transform.rotation; } }
private void OnTrackedImageRemoved(ARTrackedImage trackedImage) { string trackedImageName = trackedImage.referenceImage.name; if (IS_KEY_CONTAINED(trackedImagesMap, trackedImageName)) { // Check if World Root Anchor should stay fix WorldRootBAnchor worldRootBAnchor = (WorldRootBAnchor)trackedImagesMap[trackedImageName]; if (FixWorldRoot == true && worldRootBAnchor != null) { return; } trackedImagesMap[trackedImageName].gameObject.SetActive(false); OnTrackedImageUpdated(trackedImage); } }
protected override void LateStart() { base.LateStart(); // Set World Root BAnchor if (MotherOfManagers.Instance.ARTrackingMode != ARTrackingMode.NONE && WorldRootBAnchor == null) { WorldRootBAnchor = FindObjectOfType <WorldRootBAnchor>(); if (WorldRootBAnchor == null) { WorldRootBAnchor worldRootBAnchorPrefab = Resources.Load <WorldRootBAnchor>(BConsts.PATH_AR_WorldRootBAnchor); if (IS_NOT_NULL(worldRootBAnchorPrefab)) { WorldRootBAnchor = Instantiate(worldRootBAnchorPrefab, Vector3.zero, Quaternion.identity); } } } }