public void RefillInfoFromExistingPatron(CheckOutItem patron_item_unit_thingy) { CancelButton.SetActive(true); SaveButton.SetActive(true); ItemSidePanel.SetActive(true); namePanel.SetActive(true); current_scanned_patron_barcode = PatronInputField.text; nameInputField.text = patron_item_unit_thingy.patron_name; ItemInputField.Select(); int item_counter = patron_item_unit_thingy.items.Length; for (int i = 0; i < item_counter; i++) { //add it into the view GameObject item_obj = Instantiate(item_prefab) as GameObject; item_obj.GetComponent <ItemBox>().SetBarcodeText(patron_item_unit_thingy.items[i]); //add item string into list current_scanned_items_list.Add(patron_item_unit_thingy.items[i]); item_obj.transform.SetParent(item_holder.content, false); } item_cart_label__with_counter.text = label_string + current_scanned_items_list.Count.ToString(); }
public void CancelButtonAction() { PatronInputField.text = string.Empty; ItemInputField.text = string.Empty; nameInputField.text = string.Empty; nameInputField.text = string.Empty; current_scanned_patron_barcode = string.Empty; current_scanned_items_list.Clear(); item_cart_label__with_counter.text = label_string + current_scanned_items_list.Count.ToString(); ItemBox[] item_boxes = FindObjectsOfType <ItemBox>(); if (item_boxes != null) { for (int i = 0; i < item_boxes.Length; i++) { Destroy(item_boxes[i].gameObject); } } //WARNING, Disable these things AFTER deleting the item //boxes above. If they are inactive the FindObjectsOfType //doesn't find them. CancelButton.SetActive(false); SaveButton.SetActive(false); ItemSidePanel.SetActive(false); namePanel.SetActive(false); PatronInputField.Select(); ClearMessage(); }
public GameObject item_prefab;//SET IN EDITOR void Awake() { CancelButton.SetActive(false); SaveButton.SetActive(false); ItemSidePanel.SetActive(false); namePanel.SetActive(false); message_text.text = string.Empty; PatronInputField.Select(); }
public void PatronScanned() { if (PatronInputField.text != current_scanned_patron_barcode && current_scanned_items_list.Count > 0) { ItemInputField.text = string.Empty; current_scanned_items_list.Clear(); item_cart_label__with_counter.text = label_string + current_scanned_items_list.Count.ToString(); ItemBox[] item_boxes = FindObjectsOfType <ItemBox>(); if (item_boxes != null) { for (int i = 0; i < item_boxes.Length; i++) { Destroy(item_boxes[i].gameObject); } } } if (PatronInputField.text.Length == patron_barcode_length) { //first check if we already have this number in the list CheckOutItem doesItExist = FindIfExisting(PatronInputField.text); if (doesItExist != null) { Debug.Log("need to recall this card numbers checked out items"); DisplayMessage("Recalled patron from list"); RefillInfoFromExistingPatron(doesItExist); } else { CancelButton.SetActive(true); SaveButton.SetActive(true); ItemSidePanel.SetActive(true); namePanel.SetActive(true); current_scanned_patron_barcode = PatronInputField.text; ClearMessage(); if (!PatronInputField.text.StartsWith("21")) { Debug.Log("trying to display warning in red"); DisplayMessage("<color=red>this may not be a valid number</color>"); } ItemInputField.Select(); } } else { if (!(PatronInputField.text.Length == 0)) { DisplayMessage("Invalid patron barcode. Must be 14 digits."); } } }