示例#1
0
 public void Init(string modelparentpath)
 {
     soloItems.Clear();
     for (int i = 0; i < transform.childCount; i++)
     {
         if (transform.GetChild(i).GetComponent <soloItem>() != null)
         {
             soloItem item = transform.GetChild(i).GetComponent <soloItem>();
             if (item.target == null)
             {
                 var item2 = modelparentpath + "/" + item.gameObject.name;                                                       //models/chooseItem/qi_xie_desk/8th_puncture_needle_qxb
                 int index = item2.IndexOf('/');                                                                                 //index=6
                 item.target = GameObject.Find(item2.Substring(0, index)).transform.Find(item2.Substring(index + 1)).gameObject; //models/chooseItem/qi_xie_desk/8th_puncture_needle_qxb
             }
             if (item.target != null)
             {
                 soloItems.Add(item);
             }
             else
             {
                 item.gameObject.SetActive(false);
             }
         }
     }
 }
示例#2
0
    public void SetItemShowName(string nodeName, string showName)
    {
        soloItem so = soloItems.Find(name =>
        {
            if (name.target.name == nodeName)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        });

        if (so != null)
        {
            so.textName = showName;
        }
    }
示例#3
0
 /// <summary>
 /// 更新需要选择的物品
 /// </summary>
 /// <param name="Name">物品显示名字</param>
 /// <param name="isOK">是否需要</param>
 public void UpdateOkItem(string[] _names, bool[] _isOK)
 {
     for (int i = 0; i < _names.Length && i < _isOK.Length; i++)
     {
         soloItem so = soloItems.Find(name =>
         {
             if (name.textName == _names[i])
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         });
         if (so != null)
         {
             so.bIsOk = _isOK[i];
         }
     }
 }
示例#4
0
    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);
    }