public void Place(int index) { Transform cam = Camera.main?.transform; m_ARSpace = FindObjectOfType <ARSpace>(); if (cam != null && m_objects[index] != null && m_ARSpace != null) { RaycastHit hit; Vector3 direction = cam.forward; Vector3 origin = cam.position; if (Physics.Raycast(origin, direction, out hit, Mathf.Infinity)) { if (hit.collider != null) { ARPlane arPlane = hit.collider.GetComponentInParent <ARPlane>(); if (arPlane) { Vector3 pos = hit.point; GameObject go = Instantiate(m_objects[index], m_ARSpace.transform); go.transform.localRotation = Quaternion.identity; go.transform.position = pos; } } } } }
private void Start() { if (m_InNode == null) { GameObject go = new GameObject("graph in node"); m_InNode = go.AddComponent <Node>(); m_InNode.neighbours = new List <Node>(); m_InNode.nodeName = go.name; m_InNode.includeInSave = false; } if (m_OutNode == null) { GameObject go = new GameObject("graph out node"); m_OutNode = go.AddComponent <Node>(); m_OutNode.neighbours = new List <Node>(); m_OutNode.nodeName = go.name; m_OutNode.includeInSave = false; } if (!NavigationManager.Instance.inEditMode) { m_MeshRenderer.enabled = false; } m_ArSpace = FindObjectOfType <ARSpace>(); LoadContents(); }
/// <summary> /// Start this instance. /// </summary> public override void Start() { m_Sdk = ArwaySDK.Instance; if (string.IsNullOrEmpty(m_Sdk.developerToken)) { NotificationManager.Instance.GenerateError("Invalid Developer Token!"); } ARSpace.SetActive(showContentBeforeLocalization); destinationDropdown.SetActive(showContentBeforeLocalization); // Set max Localization Time to 30 secs if (localizationTimeout > 30f) { localizationTimeout = 30f; } base.Start(); if (!SanityCheckAccessConfiguration()) { return; } feedbackBox.text = stateParams[currentAppState].StepMessage; }
protected override void OnCloudAnchorLocated(AnchorLocatedEventArgs args) { base.OnCloudAnchorLocated(args); if (args.Status == LocateAnchorStatus.Located) { currentCloudAnchor = args.Anchor; UnityDispatcher.InvokeOnAppThread(() => { Pose anchorPose = Pose.identity; #if UNITY_ANDROID || UNITY_IOS anchorPose = currentCloudAnchor.GetPose(); #endif if (AzureAssetImporter.mapIdToOffset.ContainsKey(args.Identifier)) { Vector3 Mapoffsetposition = AzureAssetImporter.mapIdToOffset[args.Identifier].position; Quaternion Mapoffsetrotation = AzureAssetImporter.mapIdToOffset[args.Identifier].rotation; Matrix4x4 cloudMapOffset = Matrix4x4.TRS(Mapoffsetposition, Mapoffsetrotation, Vector3.one); Matrix4x4 anchorPoseOg = Matrix4x4.TRS(anchorPose.position, anchorPose.rotation, Vector3.one); Matrix4x4 resultpose = anchorPoseOg * cloudMapOffset.inverse; loaderPanel.SetActive(false); // localizeButton.SetActive(false); ARSpace.SetActive(true); destinationDropdown.SetActive(true); NotificationManager.Instance.GenerateSuccess("Offset found , setting global pose" + args.Identifier); ARSpace.transform.rotation = resultpose.rotation; ARSpace.transform.position = new Vector3(resultpose[0, 3], resultpose[1, 3], resultpose[2, 3]); } else { ARSpace.SetActive(true); destinationDropdown.SetActive(true); NotificationManager.Instance.GenerateSuccess("No Offset , setting default pose" + args.Identifier); SpawnOrMoveCurrentAnchoredObject(anchorPose.position, anchorPose.rotation); } }); Debug.Log("Yay, anchor located!"); SetBypassCache(true); } }
void OnEnable() { m_ArSpace = UnityEngine.Object.FindObjectOfType <ARSpace>(); if (m_ArSpace == null) { Debug.LogError("No ARSpace found"); } var scale = transform.localScale; var pos = transform.localPosition; transform.SetParent(m_ArSpace.transform); transform.localScale = scale; transform.localPosition = pos; }
public void LoadMap(SDKJob job) { JobLoadMapBinaryAsync j = new JobLoadMapBinaryAsync(); j.id = job.id; j.OnResult += (SDKMapResult result) => { Debug.Log(string.Format("Load map {0} ({1} bytes)", job.id, result.mapData.Length)); Color pointCloudColor = ARMap.pointCloudColors[UnityEngine.Random.Range(0, ARMap.pointCloudColors.Length)]; ARMap.RenderMode renderMode = m_ARMap?.renderMode ?? ARMap.RenderMode.EditorAndRuntime; ARSpace.LoadAndInstantiateARMap(null, result, renderMode, pointCloudColor); }; m_Jobs.Add(j); }
private void InitializeNavigationManager() { if (m_arSpace == null) { m_arSpace = FindObjectOfType <ARSpace>(); if (m_arSpace == null) { Debug.LogWarning("NavigationManager: No AR Space found in scene, ensure one exists."); return; } } m_NavigationGraphManager = GetComponent <NavigationGraphManager>(); if (m_NavigationGraphManager == null) { Debug.LogWarning("NavigationManager: Missing Navigation Graph Manager component."); return; } m_playerTransform = Camera.main.transform; if (m_playerTransform == null) { Debug.LogWarning("NavigationManager: Could not find the main camera. Do you have the MainCamera tag applied?"); return; } if (m_navigationPathPrefab == null) { Debug.LogWarning("NavigationManager: Missing navigation path object reference."); return; } if (m_navigationPathPrefab != null) { if (m_navigationPathObject == null) { m_navigationPathObject = Instantiate(m_navigationPathPrefab); m_navigationPathObject.SetActive(false); m_navigationPath = m_navigationPathObject.GetComponent <NavigationPath>(); } if (m_navigationPath == null) { Debug.LogWarning("NavigationManager: NavigationPath component in Navigation path is missing."); return; } } if (m_TargetsList == null) { Debug.LogWarning("NavigationManager: Navigation Targets List reference is missing."); return; } if (m_ShowListIcon == null) { Debug.LogWarning("NavigationManager: \"Show List\" icon is missing."); return; } if (m_SelectTargetIcon == null) { Debug.LogWarning("NavigationManager: \"Select Target\" icon is missing."); return; } if (m_TargetsListIcon == null) { Debug.LogWarning("NavigationManager: \"Targets List\" icon reference is missing."); return; } if (m_TargetsListText == null) { Debug.LogWarning("NavigationManager: \"Targets List\" text reference is missing."); return; } if (m_StopNavigationButton == null) { Debug.LogWarning("NavigationManager: Stop Navigation Button reference is missing."); return; } m_managerInitialized = true; }
void Start() { button = GetComponent <Button>(); mainCamera = Camera.main; arspace = FindObjectOfType <ARSpace>(); }