private void PlaceObject() { // do we want to limit the spawning to a single instance? if (isSingleSpawn) { // check to see if we have spawned our single mesh if (singleMesh == null) { singleMesh = Instantiate(dynamicObjectToPlace, placementPose.position, placementPose.rotation); // make sure we still count this mesh, so we can select and delete it allObjects.Add(singleMesh); } } else { // check to see if we want to delete the previous with each spawn if (deletePrevious) { // make sure we have set an obj first if (allObjects.Count == 1) { Destroy(allObjects[0].transform.gameObject); allObjects.Clear(); } } // store each obj we create into a list AR_Object aro = Instantiate(dynamicObjectToPlace, placementPose.position, placementPose.rotation); // set the data for this object from what we got from the url fetch aro.arName = (allObjects.Count <= jData.objects.Count) ? jData.objects[allObjects.Count].name : "Default"; aro.id = (allObjects.Count <= jData.objects.Count) ? jData.objects[allObjects.Count].id : 0; aro.age = (allObjects.Count <= jData.objects.Count) ? jData.objects[allObjects.Count].age : 0; allObjects.Add(aro); } }
private void HandleSelectionDetection() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); touchPosition = touch.position; if (touch.phase == TouchPhase.Began) { Ray ray = AR_Camera.ScreenPointToRay(touch.position); RaycastHit hitObject; if (Physics.Raycast(ray, out hitObject)) { AR_Object selectedObj = hitObject.transform.GetComponent <AR_Object>(); if (selectedObj != null) { ChangeSelection(selectedObj); HandleSelectionEvent(selectedObj); } else { PlaceObject(); } } } if (touch.phase == TouchPhase.Ended) { onTouchHold = false; } } }
public void AssignMesh(int inputValue) { // assign desired to mesh to both the ghost and what will be spawned dynamicObjectToPlace = SpawnList[inputValue]; //grab the actual mesh of what will be spawned Mesh newMesh = dynamicObjectToPlace.GetComponent <MeshFilter>().mesh; // and update the ghost placementIndicator.transform.GetChild(0).GetComponent <MeshFilter>().mesh = newMesh; Debug.Log("Ghost = " + placementIndicator.transform.GetChild(0).name); }
private void ChangeSelection(AR_Object selected) { foreach (AR_Object obj in allObjects) { // change the color of the selected object MeshRenderer meshRenderer = obj.GetComponent <MeshRenderer>(); // if we have found our selected obj if (selected == obj) { onTouchHold = true; selectedObject = obj; } // handle color changing meshRenderer.material.color = (selected != obj) ? inActiveColor : activeColor; } }
public void HandleSelectionEvent(AR_Object selectedObj) { Debug.Log("HandleSelectionEvent called"); }