public void OnFingerTap(Lean.LeanFinger finger) { /* Find out which object was tapped */ Ray screenRay = Camera.main.ScreenPointToRay(finger.ScreenPosition); GameObject tappedObject = null; RaycastHit hit; if (Physics.Raycast(screenRay, out hit)) { tappedObject = hit.collider.gameObject; } if (tappedObject != null && tappedObject.name.Equals(gameObject.name) && tappedObject.name.Contains("furniture")) { /* Set this furniture as the selected one */ bool isActive = false; if (global_stuff.selectedFurniture == null || (global_stuff.selectedFurniture != null && !global_stuff.selectedFurniture.Equals(gameObject.name))) { isActive = true; global_stuff.selectedFurniture = gameObject.name; } else { global_stuff.selectedFurniture = null; } Debug.Log("selectedFurniture: " + global_stuff.selectedFurniture); /* Toggle the objects */ toggleUIElements(isActive); if (isActive) { /* Change the title and description text */ furnPrice furnProperties = GetComponent <furnPrice> (); GameObject itemTitle = GameObject.Find("ItemTitle"); GameObject itemDescription = GameObject.Find("ItemDescription"); itemTitle.GetComponent <Text> ().text = furnProperties.title; itemDescription.GetComponent <Text> ().text = furnProperties.description; } } }
// Update is called once per frame public void Update() { string selectedFurniture = global_stuff.selectedFurniture; if (text != null) { text.text = ""; int sumPrice = 0; if (selectedFurniture != null) { GameObject obj = GameObject.Find(selectedFurniture); Vector3 vec = obj.GetComponent <Renderer> ().bounds.size; furnPrice price = obj.GetComponent <furnPrice> (); sumPrice += price.price; if (obj.activeSelf == true) { text.text = text.text + "Price: $" + price.toString() + "\n"; text.text = text.text + "Dimensions: " + (int)vec.x + "\' x " + (int)vec.y + "\' x " + (int)vec.z + "\'\n"; } } } }