private void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { screenTouch = true; } if (touch.phase == TouchPhase.Ended) { screenTouch = false; } SpawnBubbleOnTouch(touch.position); } if (planeIdCount.Count > 0) { for (int i = 0; i < planeIdCount.Count - 1; i++) { if (planeIdCount[i].placedObjects.Count > 0) { if (planeIdCount[i].timeInterval + 2f < Time.time) { planeIdCount[i] = new PlaneIdCount(planeIdCount[i].id, planeIdCount[i].placedObjects); int rand = Random.Range(0, planeIdCount[i].placedObjects.Count); Instantiate(bubblePrefab, planeIdCount[i].placedObjects[rand].transform.position, Quaternion.identity); } } } } }
private void PlaneChanged(ARPlanesChangedEventArgs args) { if (args.updated.Count > 0) { for (int i = 0; i < args.updated.Count - 1; i++) { ARPlane arPlane = args.updated[i]; if (planeIdCount.Count > 0) { var planeIndex = planeIdCount.FindIndex(id => id.id == arPlane.trackableId.ToString()); if (planeIndex != -1) { PlaceObjects(planeIndex, arPlane.size.x, arPlane.size.y, arPlane.transform.position); } //Plane not in struct list, add to list //Based on size spawn nessisary gameObjects else { PlaneIdCount tempPlaneId = new PlaneIdCount(arPlane.trackableId.ToString()); planeIdCount.Add(tempPlaneId); PlaceObjects(planeIdCount.Count - 1, arPlane.size.x, arPlane.size.y, arPlane.transform.position); } } else { PlaneIdCount tempPlaneId = new PlaneIdCount(arPlane.trackableId.ToString()); planeIdCount.Add(tempPlaneId); PlaceObjects(planeIdCount.Count - 1, arPlane.size.x, arPlane.size.y, arPlane.transform.position); } } } }