FairyGUI.UIPackage.AddPackage C# (CSharp) Method

AddPackage() public static method

public static AddPackage ( string assetPath, UIPackage loadFunc ) : UIPackage
assetPath string
loadFunc UIPackage
return UIPackage
        public static UIPackage AddPackage(string assetPath, UIPackage.LoadResource loadFunc)
        {
            if (_packageInstById.ContainsKey(assetPath))
                return _packageInstById[assetPath];

            TextAsset asset = (TextAsset)loadFunc(assetPath, ".bytes", typeof(TextAsset));
            if (asset == null)
            {
                if (Application.isPlaying)
                    throw new Exception("FairyGUI: Cannot load ui package in '" + assetPath + "'");
                else
                    Debug.LogWarning("FairyGUI: Cannot load ui package in '" + assetPath + "'");
            }

            UIPackage pkg = new UIPackage();
            pkg._loadFunc = loadFunc;
            pkg.Create(asset.text, null, assetPath);
            if (_packageInstById.ContainsKey(pkg.id))
                Debug.LogWarning("FairyGUI: Package id conflicts, '" + pkg.name + "' and '" + _packageInstById[pkg.id].name + "'");
            _packageInstById[pkg.id] = pkg;
            _packageInstByName[pkg.name] = pkg;
            _packageInstById[assetPath] = pkg;
            _packageList.Add(pkg);
            pkg.assetPath = assetPath;

            return pkg;
        }

Same methods

UIPackage::AddPackage ( AssetBundle bundle ) : UIPackage
UIPackage::AddPackage ( AssetBundle desc, AssetBundle res ) : UIPackage
UIPackage::AddPackage ( AssetBundle desc, AssetBundle res, string mainAssetName ) : UIPackage
UIPackage::AddPackage ( string descFilePath ) : UIPackage
UIPackage::AddPackage ( string desc, AssetBundle res ) : UIPackage
UIPackage::AddPackage ( string desc, AssetBundle res, string mainAssetName ) : UIPackage

Usage Example

Example #1
0
        void Awake()
        {
            if (Application.isPlaying)
            {
                foreach (string packagePath in PreloadPackages)
                {
                    UIPackage.AddPackage(packagePath);
                }

                Load();
            }
        }
All Usage Examples Of FairyGUI.UIPackage::AddPackage