/// Allow to select an item in the stage. /// @param item A GameObject containing the item to select. public void SelectItem(GameObject item) { GameObject found = this.FindItem(item); if (found) { Debug.Log("Item Found: " + found.ToString()); if (SelectedItem) { ModelBehaviour model = this.GetModelBehaviour(SelectedItem); if (model) { model.SetSelected(false); model.RotationJoystick = null; model.MovementJoystick = null; } } ModelBehaviour foundModel = this.GetModelBehaviour(found); if (foundModel) { this.SelectedItem = found; foundModel.SetSelected(true); foundModel.RotationJoystick = RotationJoystick; if (ARSession.state == ARSessionState.Unsupported && MovementJoystick) { foundModel.MovementJoystick = MovementJoystick; } this.ActivateSelectedInterface(true); } } }
/// Function for add an item in the stage. /// @param objectModel The prefab of the object to add. /// @param position Vector3 object containing the position where the item will be added. /// @param rotation Quaternion object containing the rotation values of the item. public void AddItem(GameObject objectModel, Vector3 position, Quaternion rotation) { EditNewObject(objectModel); GameObject spawnedObject = Instantiate(objectModel, position, rotation); spawnedObject.transform.rotation = Quaternion.Euler(-90.0f, 0.0f, 0.0f); if (ARSession.state == ARSessionState.Unsupported) { spawnedObject.transform.localScale = spawnedObject.transform.localScale * 100; } ModelBehaviour modelBehaviour = spawnedObject.AddComponent <ModelBehaviour>() as ModelBehaviour; modelBehaviour.cameraHandler = cameraHandler; this.Items.Add(spawnedObject); this.SelectItem(spawnedObject); }