Пример #1
0
        //属性
        void GetAttr(int id, GameObject conatin, GameObject image)
        {
            deleteAttr(conatin, image);
            //print("收到的id是:" + id);
            SXML        xml  = XMLMgr.instance.GetSXML("achievement.title", "title_id==" + id);
            List <SXML> xmls = xml.GetNodeList("nature");

            for (int i = 0; i < xmls.Count; i++)
            {
                GameObject objclone = GameObject.Instantiate(image) as GameObject;
                objclone.SetActive(true);
                objclone.transform.SetParent(conatin.transform, false);
                objclone.transform.FindChild("Text").GetComponent <Text>().text = Globle.getRankAttrNameById(xmls[i].getInt("att_type")) + ":" + xmls[i].getInt("att_value");
            }
            refreshs(conatin, image);
        }
Пример #2
0
        void CreateList()
        {
            content = transform.FindChild("con/ranklist/content");
            GameObject temp = transform.FindChild("con/ranklist/0").gameObject;
            GameObject att  = transform.FindChild("con/ranklist/0/0").gameObject;

            foreach (var v in a3_RankModel.getInstance().dicrankinfo.Values)
            {
                GameObject go = GameObject.Instantiate(temp) as GameObject;
                go.transform.SetParent(content.transform);
                go.transform.localScale    = Vector3.one;
                go.transform.localPosition = Vector3.zero;
                go.SetActive(true);
                go.name = v.title_id.ToString();
                string file = "icon_achievement_title_ui_" + v.title_id;
                go.transform.FindChild("title/Image").GetComponent <Image>().sprite = GAMEAPI.ABUI_LoadSprite(file);
                go.transform.FindChild("title/Image").GetComponent <Image>().SetNativeSize();
                Transform iconRoot = go.transform.FindChild("title/icon");
                go.transform.FindChild("title/icon").GetComponent <Image>().sprite = GAMEAPI.ABUI_LoadSprite("icon_achievement_title_ui_t" + v.title_id);
                go.transform.FindChild("title/icon").GetComponent <Image>().SetNativeSize();
                var ud = go.AddComponent <UIDark>();
                if (v.title_id > a3_RankModel.now_id)
                {
                    ud.ADDO();
                }
                Transform attcontent = go.transform.FindChild("att");
                foreach (var a in v.nature.Keys)
                {
                    GameObject nk = GameObject.Instantiate(att) as GameObject;
                    nk.transform.SetParent(attcontent.transform);
                    nk.transform.localScale    = Vector3.one;
                    nk.transform.localPosition = Vector3.zero;
                    nk.SetActive(true);
                    nk.transform.FindChild("1").GetComponent <Text>().text = /*LRAlign((*/ Globle.getRankAttrNameById((int)a) /*))*/ + ":";
                    if (a == 33)
                    {
                        nk.transform.FindChild("1/2").GetComponent <Text>().text = (((float)v.nature[a]) / 10).ToString() + @"%";
                    }
                    else
                    {
                        nk.transform.FindChild("1/2").GetComponent <Text>().text = v.nature[a].ToString();
                    }
                }
            }

            var glg = content.GetComponent <GridLayoutGroup>();

            content.GetComponent <RectTransform>().sizeDelta = new Vector2((glg.cellSize.x + glg.spacing.x + 0.1f) * a3_RankModel.getInstance().dicrankinfo.Count, 0);
        }