void specialItemChoose() { currentButton.LoadSprite(currentButton.sprite.name.Replace("_h", "")); currentButton = null; m_uplane.SetActive(false); chooseResult = global::specialItemChoose.None; List <UPageBase> list = m_uplane.GetChildren(); UPageBase.FindPage("ChooseGoodsUI/ChooseItems/chooseItemFinishButton").gameObejct.SetActive(true); if (btnName == "right") { specialItem.bIsOk = true; specialItem.ChangeState(); chooseResult = global::specialItemChoose.right; } else { specialItem.bIsOk = false; //specialItem.errorIcon.SetActive(true); specialItem.ChangeState(); if (btnName == "overdate") { chooseResult = global::specialItemChoose.overDate; } //else if (tmp.getimage() == breakImage) //{ // chooseResult = global::specialItemChoose.broken; //} else if (btnName == "error") { chooseResult = global::specialItemChoose.wrongType; } } if (string.IsNullOrEmpty(btnName)) { OnSpecialNone.Invoke(); return; } m_uplane.gameObejct.SetActive(false); if (OnItemStateChange != null) { OnItemStateChange(); } }
void setSpecialObjPlane(soloItem item) { specialItem = item; if (m_uplane != null) { m_uplane.Destroy(); } string str = "right,error,overdate"; if (btnList.Count == 0) { foreach (var number in MyCommon.RandomRepeat(3)) { btnList.Add(str.Split(',')[number]); } } m_uplane = new UPlane(); //定义UI m_uplane.SetAnchored(AnchoredPosition.center); //定义位置远点 m_uplane.rect = new Rect(65, 0, 1620, 1080 / 6 * 5); //定义显示框的位置的大小 m_uplane.gameObejct.AddComponent <ToggleGroup>(); //副节点 m_uplane.color = new Color(0.9f, 0.9f, 0.9f); m_uplane.LoadImage(""); UText m_utext = new UText(); m_utext.SetAnchored(AnchoredPosition.center); m_utext.text = "请选择正确物品"; m_utext.rect = new Rect(100, -375, 500, 100); m_utext.baseText.fontSize = 55; m_utext.baseText.color = Color.white; m_utext.SetParent(m_uplane); for (int i = 0; i < btnList.Count; i++) { UPageButton btn = new UPageButton(); btn.SetParent(m_uplane); btn.name = btnList[i]; btn.SetAnchored(AnchoredPosition.center); btn.rect = new Rect(-540 + i * 500 + 50, 9, 500, 300); btn.LoadSprite("check_anesthetic_3"); btn.LoadPressSprite("check_anesthetic_3_h"); btn.onClick.AddListener(() => { OnImageButtonClick(btn); }); UText m_datetext_1 = new UText(); m_datetext_1.SetAnchored(AnchoredPosition.center); m_datetext_1.SetParent(m_uplane); m_datetext_1.rect = new Rect(-300 + i * 500 + 50, 240, 500, 300); m_datetext_1.baseText.fontSize = 23; m_datetext_1.baseText.color = new Color(0f, 0f, 0f); m_datetext_1.rectTransform.localEulerAngles = new Vector3(0f, 0f, 5.6f); m_datetext_1.baseText.raycastTarget = false; UText m_type_1 = new UText(); m_type_1.SetAnchored(AnchoredPosition.center); m_type_1.SetParent(m_uplane); m_type_1.rect = new Rect(-300 + i * 500 + 50, 200, 500, 300); m_type_1.baseText.color = new Color(0f, 0f, 0f); m_type_1.rectTransform.localEulerAngles = new Vector3(0f, 0f, 5.6f); m_type_1.baseText.fontSize = 23; m_type_1.baseText.raycastTarget = false; if (btnList[i] == "right") { m_datetext_1.text = "有效日期: " + (DateTime.Now.Year + 2).ToString() + "年" + (DateTime.Now.Month.ToString()) + "月1日"; m_type_1.text = "规格:16Fr "; } else { if (btnList[i] == "error") { m_datetext_1.text = "有效日期: " + (DateTime.Now.Year + 2).ToString() + "年" + (DateTime.Now.Month.ToString()) + "月1日"; m_type_1.text = "规格:8Fr\0\0\0\0\0\0\0\0"; } else { m_type_1.text = "规格:16Fr\r\r\r\r\r\r "; m_datetext_1.text = "有效日期: " + (DateTime.Now.Year - 1).ToString() + "年" + (DateTime.Now.Month.ToString()) + "月1日"; } } } UFinishButton OkButton = new UFinishButton("确定", new Rect(23, 363, 180, 70), AnchoredPosition.center); OkButton.SetParent(m_uplane); OkButton.baseButton.onClick.AddListener(specialItemChoose); m_uplane.transform.SetAsLastSibling(); List <UPageBase> list = m_uplane.GetChildren(); foreach (UPageBase upb in list) { UToogleItem tmp = null; try { tmp = (UToogleItem)upb; } catch { continue; } if (tmp != null) { upb.gameObejct.GetComponent <Toggle>().isOn = false; } } m_uplane.gameObejct.SetActive(true); UPageBase.FindPage("ChooseGoodsUI/ChooseItems/chooseItemFinishButton").gameObejct.SetActive(false); //GameObject.Find("Canvas").transform.Find("ChooseItems/UPageButton").gameObject.SetActive(false); }