// 创建bufficon结构 private void onCreateBuffIcon(BuffTemplate info) { int buffid = info.GetID(); GameObject obj = new GameObject("BuffIcon"); obj.transform.SetParent(transform, false); UI_BuffIcon icon = obj.AddComponent <UI_BuffIcon>(); //buff icon路径 //string filepath = "";// info.m_buffIconBig; string filepath = info.getBuffIconSmall();//m_buffIconSmall; if (string.IsNullOrEmpty(filepath)) { Debug.LogError("找不到资源:" + info.getDES()); return; } filepath = common.defaultPath + filepath; //string filepath = common.defaultPath + "Battle_Buff04"; //LogManager.LogError("Should use table filepath ..."); if (UIResourceMgr.LoadSprite(filepath) == null) { return; } Sprite sprite = Instantiate(UIResourceMgr.LoadSprite(filepath), Vector3.zero, Quaternion.identity) as Sprite; icon.onImageInit(sprite); BuffIcon buffIcon = new BuffIcon(icon, buffid); mBuffList.Add(buffIcon); // buff/debuff 排序 if (info.getConduce() != 0) { // buff 排在debuff前 obj.transform.SetSiblingIndex(iDebuffIdx); iDebuffIdx++; } else { // debuff 排在队尾 // 所以不处理 } }
public UI_BuffIcon icon; // 对应icon public BuffIcon(UI_BuffIcon _icon, int buffid) { iBuffID = buffid; iCount = 1; icon = _icon; }