Ejemplo n.º 1
0
    private void AddImg(string name)
    {
        GameObject go = Instantiate(m_imgCell, m_imgCellParent.transform);

        go.SetActive(true);
        ImageCell cell = go.GetComponent <ImageCell>();

        if (cell != null)
        {
            cell.SetImage(name, this);
            m_imageName += name + ";";
            if (!m_dicImgCells.ContainsKey(name))
            {
                m_dicImgCells.Add(name, cell);
            }
        }
    }
Ejemplo n.º 2
0
    public void Init(OutFood data)
    {
        m_foodData = data;
        m_isChange = true;
        m_btnComfirmAdd.SetActive(!m_isChange);
        m_btnComfirmChange.SetActive(m_isChange);
        //初始化界面
        m_inputAdress.text    = data.V_Adress;
        m_inputEvaluate.text  = data.V_Evaluate;
        m_inputLine.text      = data.V_Line;
        m_inputStar.text      = data.V_Star + "";
        m_inputStoreName.text = data.V_StoreName;
        m_imageName           = data.V_Iamge;
        int yearIndex = 0;

        for (int i = 0; i < m_Years.Count; i++)
        {
            string year = data.V_Date.Year.ToString();
            if (m_Years[i] == year)
            {
                yearIndex = i;
                break;
            }
        }
        m_dropdownYear.value  = yearIndex;
        m_dropdownMonth.value = data.V_Date.Month - 1;
        //菜单
        string[] goodFoods = data.V_GoodFoodName.Split(';');
        string[] badFoods  = data.V_BadFoodName.Split(';');

        for (int i = 0; i < goodFoods.Length; i++)
        {
            if (string.IsNullOrEmpty(goodFoods[i]))
            {
                continue;
            }
            string[]   foodStr = goodFoods[i].Split('-');
            GameObject go      = Instantiate(m_outFoodPerCell, m_outFoodPerCellParent.transform);
            go.SetActive(true);
            OutFoodPerCell cell = go.GetComponent <OutFoodPerCell>();
            if (cell != null)
            {
                cell.Init(m_tempId, foodStr[0], foodStr[1], true, this);
                m_dicFoodCells.Add(m_tempId, cell);
                m_tempId++;
            }
        }
        for (int i = 0; i < badFoods.Length; i++)
        {
            if (string.IsNullOrEmpty(badFoods[i]))
            {
                continue;
            }
            string[]   foodStr = badFoods[i].Split('-');
            GameObject go      = Instantiate(m_outFoodPerCell, m_outFoodPerCellParent.transform);
            go.SetActive(true);
            OutFoodPerCell cell = go.GetComponent <OutFoodPerCell>();
            if (cell != null)
            {
                cell.Init(m_tempId, foodStr[0], foodStr[1], false, this);
                m_dicFoodCells.Add(m_tempId, cell);
                m_tempId++;
            }
        }
        //图片
        string[] imagename = m_imageName.Split(';');
        for (int i = 0; i < imagename.Length; i++)
        {
            if (string.IsNullOrEmpty(imagename[i]))
            {
                continue;
            }
            GameObject go = Instantiate(m_imgCell, m_imgCellParent.transform);
            go.SetActive(true);
            ImageCell cell = go.GetComponent <ImageCell>();
            if (cell != null)
            {
                cell.SetImage(imagename[i], this);
                if (!m_dicImgCells.ContainsKey(imagename[i]))
                {
                    m_dicImgCells.Add(imagename[i], cell);
                }
            }
        }
    }