/// <summary>
 /// Asset打包构造函数
 /// </summary>
 /// <param name="asset">当前Asset</param>
 /// <param name="dependentasset">依赖使用当前Asset的Asset</param>
 public PackageAsset(Object asset, Object dependentasset = null)
 {
     mAssetObject = asset;
     if (mAssetObject == null)
     {
         mPackageAssetType          = AssetPackageType.E_INVALIDE;
         mAssetAssetBundleBuildRule = AssetABBuildRule.E_INVALIDE;
         mAssetPath             = string.Empty;
         mDependentPackageAsset = null;
         mInvalideBuildRuleList = null;
     }
     else
     {
         mAssetPath                 = AssetDatabase.GetAssetPath(mAssetObject);
         mPackageAssetType          = ABHelper.Singleton.getAssetPackageType(mAssetPath);
         mAssetAssetBundleBuildRule = ABHelper.Singleton.getAssetABBuildRule(mAssetPath);
         if (dependentasset != null)
         {
             mDependentPackageAsset = new PackageAsset(dependentasset);
         }
         else
         {
             mDependentPackageAsset = null;
         }
         mInvalideBuildRuleList = new List <AssetABBuildRule>();
         mInvalideBuildRuleList.Add(AssetABBuildRule.E_INVALIDE);
     }
 }
Beispiel #2
0
        PackAssets(
            string assetFolder, string outputFolder, AssetPackageInfo info,
            bool compression = false)     // [...]/assets
        {
            AssetResult ret = new AssetResult(outputFolder);

            ret.Compression = compression;
            Uri assetPath = new Uri(assetFolder);

            foreach (KeyValuePair <string, AssetFileInfo> assetFileInfo in info.FileInfos)
            {
                Console.WriteLine("Checking Folder: " + assetFolder + " with pattern: " + assetFileInfo.Key);
                string[]         files = Directory.GetFiles(assetFolder, assetFileInfo.Key, SearchOption.AllDirectories);
                AssetPackageType type  = assetFileInfo.Value.PackageType;

                for (int i = 0; i < files.Length; i++)
                {
                    Uri file     = new Uri(files[i]);
                    Uri packPath = assetPath.MakeRelativeUri(file);

                    ret.AddFile(files[i], packPath.ToString(), type);
                }
            }

            return(ret);
        }
 private PackageAsset()
 {
     mAssetObject               = null;
     mPackageAssetType          = AssetPackageType.E_INVALIDE;
     mAssetAssetBundleBuildRule = AssetABBuildRule.E_INVALIDE;
     mAssetPath             = string.Empty;
     mDependentPackageAsset = null;
     mInvalideBuildRuleList = null;
 }
Beispiel #4
0
        private void StoreInPackages(Stream s, string file, string packPath, AssetPackageType type)
        {
            int firstPack = FindAssetPackWithSpace();


            Console.WriteLine("Adding file: " + file + " To pack: " + (firstPack + 1));

            AssetPointer ap = new AssetPointer
            {
                PackageId   = firstPack,
                Offset      = (int)Packs[firstPack].BytesWritten,
                PackageSize = AssetPacker.PackSize,
                Length      = (int)s.Length,
                Path        = packPath,
                PackageType = type
            };

            IndexList.Add(ap);


            int packid    = firstPack;
            int bytesLeft = ap.Length;

            do
            {
                int write = bytesLeft;
                if (write > Packs[packid].SpaceLeft)
                {
                    write = Packs[packid].SpaceLeft;
                }

                byte[] b = new byte[write];
                s.Read(b, 0, write);
                Packs[packid].Write(b, 0, b.Length);
                bytesLeft -= write;
                if (bytesLeft != 0)
                {
                    packid = FindAssetPackWithSpace();
                }
            } while (bytesLeft != 0);

            s.Close();
        }
Beispiel #5
0
        public void AddFile(string file, string packPath, AssetPackageType type)
        {
            FileStream fs = new FileStream(file, FileMode.Open);

            StoreInPackages(fs, file, packPath, type);
        }