void Update() { // need to know if we touched the screen and where if (Input.touchCount > 0) { Vector3 touchPosition = Input.GetTouch(0).position; // (x,y) if (raycastManager.Raycast(touchPosition, hits, TrackableType.PlaneWithinPolygon)) { var hitPose = hits[0].pose; spawnedObject = Instantiate(prefab, hitPose.position, hitPose.rotation); // need to assign button onClick functions PlacedPrefab placedPrefab = spawnedObject.GetComponent <PlacedPrefab>(); placedPrefab.AddToModelAButton(modelAButton); placedPrefab.AddToModelBButton(modelBButton); // put our spawnedObject into our prefab manager list PrefabManager.instance.AddPrefabs(spawnedObject); } } }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); Vector2 touchPosition = touch.position; if (touch.phase == TouchPhase.Began) { Ray ray = arCamera.ScreenPointToRay(touch.position); RaycastHit hitObject; if (Physics.Raycast(ray, out hitObject)) { PlacedPrefab placementPrefab = hitObject.transform.GetComponent <PlacedPrefab>(); if (placementPrefab) { SelectedObject(placementPrefab); } } } } }
void SelectedObject(PlacedPrefab selectedPrefab) { selectedPrefab.Selected = true; }