コード例 #1
0
        public Dictionary <BundleReplacer, MemoryStream> WriteFilesToMemory(List <AssetsReplacer> replacers)
        {
            var bunDict    = new Dictionary <BundleReplacer, MemoryStream>();
            var lastFileId = replacers.Max(r => r.GetFileID());

            for (var fileId = 0; fileId <= lastFileId; fileId++)
            {
                var id = fileId;
                var sortedAssetsList = replacers.Where(r => r.GetFileID() == id).ToList();
                using var ms     = new MemoryStream();
                using var writer = new AssetsFileWriter(ms);
                var fileInst = Workspace.LoadedFiles[fileId];

                fileInst.file.Write(writer, 0, sortedAssetsList, 0);
                bunDict.Add(AssetModifier.CreateBundleReplacer(fileInst.name, true, ms.ToArray()), ms);
            }
            return(bunDict);
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: Igor55x/UAAE
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (BundleInst == null)
            {
                return;
            }
            var ofd = new OpenFileDialog
            {
                Title  = @"Open assets file",
                Filter = @"All types (*.*)|*.*|Assets file (*.assets)|*.assets"
            };

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var i = 0;

            foreach (var file in ofd.FileNames)
            {
                var fileName     = Path.GetFileName(file);
                var fileBytes    = File.ReadAllBytes(fileName);
                var isSerialized = !(file.EndsWith(".resS") || file.EndsWith(".resource"));
                var replacer     = AssetModifier.CreateBundleReplacer(fileName, isSerialized, fileBytes);
                if (!cboxBundleContents.Items.Contains(fileName))
                {
                    cboxBundleContents.Items.Add(fileName + " *");
                }
                else
                {
                    var item = cboxBundleContents.Items[i] + " *";
                    cboxBundleContents.Items.Remove(item);
                    cboxBundleContents.Items.Insert(i, item);
                }
                ModifiedFiles[fileName] = replacer;
                i++;
            }
            Modified = true;
        }