FairyGUI.UIPackage.GetById C# (CSharp) Method

GetById() public static method

Return a UIPackage with a certain id.
public static GetById ( string id ) : UIPackage
id string ID of the package.
return UIPackage
        public static UIPackage GetById(string id)
        {
            UIPackage pkg;
            if (_packageInstById.TryGetValue(id, out pkg))
                return pkg;
            else
                return null;
        }

Usage Example

Example #1
0
        /// <summary>
        /// 收集创建目标对象所需的所有类型信息
        /// </summary>
        /// <param name="item"></param>
        /// <param name="list"></param>
        static int CollectComponentChildren(PackageItem item, List <DisplayListItem> list)
        {
            ByteBuffer buffer = item.rawData;

            buffer.Seek(0, 2);

            int             dcnt = buffer.ReadShort();
            DisplayListItem di;
            PackageItem     pi;

            for (int i = 0; i < dcnt; i++)
            {
                int dataLen = buffer.ReadShort();
                int curPos  = buffer.position;

                buffer.Seek(curPos, 0);

                ObjectType type  = (ObjectType)buffer.ReadByte();
                string     src   = buffer.ReadS();
                string     pkgId = buffer.ReadS();

                buffer.position = curPos;

                if (src != null)
                {
                    UIPackage pkg;
                    if (pkgId != null)
                    {
                        pkg = UIPackage.GetById(pkgId);
                    }
                    else
                    {
                        pkg = item.owner;
                    }

                    pi = pkg != null?pkg.GetItem(src) : null;

                    di = new DisplayListItem(pi, type);

                    if (pi != null && pi.type == PackageItemType.Component)
                    {
                        di.childCount = CollectComponentChildren(pi, list);
                    }
                }
                else
                {
                    di = new DisplayListItem(null, type);
                    if (type == ObjectType.List) //list
                    {
                        di.listItemCount = CollectListChildren(buffer, list);
                    }
                }

                list.Add(di);
                buffer.position = curPos + dataLen;
            }

            return(dcnt);
        }
All Usage Examples Of FairyGUI.UIPackage::GetById