/* * This method is called on dropdown value change * The "current" field in the CustomtouchBehavior script is updated * current denotes the echoAR model that will be instantiated next */ public void updateCurrent() { GameObject arSessionOrigin = GameObject.Find("AR Session Origin"); CustomTouchBehavior touchScript = arSessionOrigin.GetComponent <CustomTouchBehavior>(); touchScript.current = dropdown.value; }
/* * Gets the most recently grabbed object from CustomTouchBehavior script */ private GameObject getMostRecentlyGrabbedObject() { GameObject arSessionOrigin = GameObject.Find("AR Session Origin"); CustomTouchBehavior touchScript = arSessionOrigin.GetComponent <CustomTouchBehavior>(); return(touchScript.grabbedObject); }
/* * Adds options to the dropdown menu * Options are read from CustomTouchBehavior script's consoleObjects list. * This is done only once, but must be called in Update() because it takes time for echoAR models to be loaded in. */ void PopulateDropDownOptions() { if (dropdown.options.Count == 0) { GameObject arSessionOrigin = GameObject.Find("AR Session Origin"); CustomTouchBehavior touchScript = arSessionOrigin.GetComponent <CustomTouchBehavior>(); List <string> options = new List <string>(); foreach (string option in touchScript.consoleObjects) { options.Add(option); } dropdown.AddOptions(options); } }
void Start() { // Add RemoteTransformations script to object and set its entry this.gameObject.AddComponent <RemoteTransformations>().entry = entry; //Get "current" from CustomTouchBehavior script GameObject arSessionOrigin = GameObject.Find("AR Session Origin"); string identifier = this.gameObject.name; CustomTouchBehavior touchScript = arSessionOrigin.GetComponent <CustomTouchBehavior>(); int count = touchScript.consoleObjects.Count; int index = touchScript.current; /* * Destroy this object if it is not the "current" object * If this is done for every model in the echoAR console, only the current object will remain */ if (count != 0 && index >= 0 && index < count && identifier != touchScript.consoleObjects[index]) { Destroy(this.gameObject); } }