コード例 #1
0
    static int RecompressAssetBundleAsync(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.AssetBundle.Register");
#endif
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3)
            {
                string arg0 = ToLua.CheckString(L, 1);
                string arg1 = ToLua.CheckString(L, 2);
                UnityEngine.BuildCompression arg2 = StackTraits <UnityEngine.BuildCompression> .Check(L, 3);

                UnityEngine.AssetBundleRecompressOperation o = UnityEngine.AssetBundle.RecompressAssetBundleAsync(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4)
            {
                string arg0 = ToLua.CheckString(L, 1);
                string arg1 = ToLua.CheckString(L, 2);
                UnityEngine.BuildCompression arg2 = StackTraits <UnityEngine.BuildCompression> .Check(L, 3);

                uint arg3 = (uint)LuaDLL.luaL_checknumber(L, 4);
                UnityEngine.AssetBundleRecompressOperation o = UnityEngine.AssetBundle.RecompressAssetBundleAsync(arg0, arg1, arg2, arg3);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 5)
            {
                string arg0 = ToLua.CheckString(L, 1);
                string arg1 = ToLua.CheckString(L, 2);
                UnityEngine.BuildCompression arg2 = StackTraits <UnityEngine.BuildCompression> .Check(L, 3);

                uint arg3 = (uint)LuaDLL.luaL_checknumber(L, 4);
                UnityEngine.ThreadPriority arg4 = (UnityEngine.ThreadPriority)ToLua.CheckObject(L, 5, typeof(UnityEngine.ThreadPriority));
                UnityEngine.AssetBundleRecompressOperation o = UnityEngine.AssetBundle.RecompressAssetBundleAsync(arg0, arg1, arg2, arg3, arg4);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.AssetBundle.RecompressAssetBundleAsync"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #2
0
        private BuildCompression ConverBundleCompressiontToBuildCompression(
            BundledAssetGroupSchema.BundleCompressionMode compressionMode)
        {
            BuildCompression compresion = BuildCompression.LZMA;

            switch (compressionMode)
            {
            case BundledAssetGroupSchema.BundleCompressionMode.LZMA:
                break;

            case BundledAssetGroupSchema.BundleCompressionMode.LZ4:
                compresion = BuildCompression.LZ4;
                break;

            case BundledAssetGroupSchema.BundleCompressionMode.Uncompressed:
                compresion = BuildCompression.Uncompressed;
                break;
            }

            return(compresion);
        }
コード例 #3
0
        public ReturnCode Run()
        {
            Dictionary <string, ulong> fileOffsets = new Dictionary <string, ulong>();
            List <KeyValuePair <string, List <ResourceFile> > > bundleResources;
            {
                Dictionary <string, List <ResourceFile> > bundleToResources = new Dictionary <string, List <ResourceFile> >();
                foreach (var pair in m_Results.WriteResults)
                {
                    string bundle = m_WriteData.FileToBundle[pair.Key];
                    List <ResourceFile> resourceFiles;
                    bundleToResources.GetOrAdd(bundle, out resourceFiles);
                    resourceFiles.AddRange(pair.Value.resourceFiles);

                    foreach (ResourceFile serializedFile in pair.Value.resourceFiles)
                    {
                        if (!serializedFile.serializedFile)
                        {
                            continue;
                        }

                        ObjectSerializedInfo firstObject = pair.Value.serializedObjects.First(x => x.header.fileName == serializedFile.fileAlias);
                        fileOffsets[serializedFile.fileName] = firstObject.header.offset;
                    }
                }
                bundleResources = bundleToResources.ToList();
            }

            Dictionary <string, HashSet <string> > bundleDependencies = new Dictionary <string, HashSet <string> >();

            foreach (var files in m_WriteData.AssetToFiles.Values)
            {
                if (files.IsNullOrEmpty())
                {
                    continue;
                }

                string           bundle = m_WriteData.FileToBundle[files.First()];
                HashSet <string> dependencies;
                bundleDependencies.GetOrAdd(bundle, out dependencies);
                dependencies.UnionWith(files.Select(x => m_WriteData.FileToBundle[x]));
                dependencies.Remove(bundle);
            }

            IList <CacheEntry> entries      = bundleResources.Select(x => GetCacheEntry(x.Key, x.Value, m_Parameters.GetCompressionForIdentifier(x.Key))).ToList();
            IList <CachedInfo> cachedInfo   = null;
            IList <CachedInfo> uncachedInfo = null;

            if (m_Parameters.UseCache && m_Cache != null)
            {
                m_Cache.LoadCachedData(entries, out cachedInfo);

                uncachedInfo = new List <CachedInfo>();
            }

            for (int i = 0; i < bundleResources.Count; i++)
            {
                string           bundleName    = bundleResources[i].Key;
                ResourceFile[]   resourceFiles = bundleResources[i].Value.ToArray();
                BuildCompression compression   = m_Parameters.GetCompressionForIdentifier(bundleName);

                string        writePath;
                BundleDetails details;
                if (cachedInfo != null && cachedInfo[i] != null)
                {
                    if (!m_Tracker.UpdateInfoUnchecked(string.Format("{0} (Cached)", bundleName)))
                    {
                        return(ReturnCode.Canceled);
                    }

                    details          = (BundleDetails)cachedInfo[i].Data[0];
                    details.FileName = string.Format("{0}/{1}", m_Parameters.OutputFolder, bundleName);

                    HashSet <string> dependencies;
                    if (bundleDependencies.TryGetValue(bundleName, out dependencies))
                    {
                        details.Dependencies = dependencies.ToArray();
                    }
                    else
                    {
                        details.Dependencies = new string[0];
                    }
                    writePath = string.Format("{0}/{1}", m_Cache.GetCachedArtifactsDirectory(entries[i]), bundleName);
                }
                else
                {
                    if (!m_Tracker.UpdateInfoUnchecked(bundleName))
                    {
                        return(ReturnCode.Canceled);
                    }

                    details   = new BundleDetails();
                    writePath = string.Format("{0}/{1}", m_Parameters.TempOutputFolder, bundleName);
                    if (m_Parameters.UseCache && m_Cache != null)
                    {
                        writePath = string.Format("{0}/{1}", m_Cache.GetCachedArtifactsDirectory(entries[i]), bundleName);
                    }
                    Directory.CreateDirectory(Path.GetDirectoryName(writePath));

                    details.FileName = string.Format("{0}/{1}", m_Parameters.OutputFolder, bundleName);
                    details.Crc      = ContentBuildInterface.ArchiveAndCompress(resourceFiles, writePath, compression);
                    details.Hash     = CalculateHashVersion(fileOffsets, resourceFiles);

                    HashSet <string> dependencies;
                    if (bundleDependencies.TryGetValue(bundleName, out dependencies))
                    {
                        details.Dependencies = dependencies.ToArray();
                    }
                    else
                    {
                        details.Dependencies = new string[0];
                    }

                    if (uncachedInfo != null)
                    {
                        uncachedInfo.Add(GetCachedInfo(m_Cache, entries[i], resourceFiles, details));
                    }
                }

                SetOutputInformation(writePath, details.FileName, bundleName, details);
            }

            if (m_Parameters.UseCache && m_Cache != null)
            {
                m_Cache.SaveCachedData(uncachedInfo);
            }

            return(ReturnCode.Success);
        }
コード例 #4
0
#pragma warning restore 649

        CacheEntry GetCacheEntry(string bundleName, IEnumerable <ResourceFile> resources, BuildCompression compression)
        {
            var entry = new CacheEntry();

            entry.Type = CacheEntry.EntryType.Data;
            entry.Guid = HashingMethods.Calculate("ArchiveAndCompressBundles", bundleName).ToGUID();
            entry.Hash = HashingMethods.Calculate(Version, resources, compression).ToHash128();
            return(entry);
        }
コード例 #5
0
 private static extern AssetBundleRecompressOperation RecompressAssetBundleAsync_Internal_Injected(string inputPath, string outputPath, ref BuildCompression method, uint expectedCRC, ThreadPriority priority);
コード例 #6
0
 internal static AssetBundleRecompressOperation RecompressAssetBundleAsync_Internal(string inputPath, string outputPath, BuildCompression method, uint expectedCRC, ThreadPriority priority)
 {
     return(AssetBundle.RecompressAssetBundleAsync_Internal_Injected(inputPath, outputPath, ref method, expectedCRC, priority));
 }
コード例 #7
0
 public static AssetBundleRecompressOperation RecompressAssetBundleAsync(string inputPath, string outputPath, BuildCompression method, uint expectedCRC = 0u, ThreadPriority priority = ThreadPriority.Low)
 {
     return(AssetBundle.RecompressAssetBundleAsync_Internal(inputPath, outputPath, method, expectedCRC, priority));
 }
コード例 #8
0
 extern public static uint ArchiveAndCompress(ResourceFile[] resourceFiles, string outputBundlePath, UnityEngine.BuildCompression compression);
コード例 #9
0
 internal static extern AssetBundleRecompressOperation RecompressAssetBundleAsync_Internal(string inputPath, string outputPath, BuildCompression method, UInt32 expectedCRC, ThreadPriority priority);