Пример #1
0
        private async void MenuOpen_Click(object?sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title   = "Open assets or bundle file";
            ofd.Filters = new List <FileDialogFilter>()
            {
                new FileDialogFilter()
                {
                    Name = "All files", Extensions = new List <string>()
                    {
                        "*"
                    }
                }
            };
            string[] files = await ofd.ShowAsync(this);

            if (files.Length > 0)
            {
                string selectedFile = files[0];

                DetectedFileType fileType = AssetBundleDetector.DetectFileType(selectedFile);

                CloseAllFiles();

                if (fileType == DetectedFileType.AssetsFile)
                {
                    string assetName = Path.GetFileNameWithoutExtension(selectedFile);

                    AssetsFileInstance fileInst = am.LoadAssetsFile(selectedFile, true);
                    am.LoadClassDatabaseFromPackage(fileInst.file.typeTree.unityVersion);

                    InfoWindow info = new InfoWindow(am, fileInst, assetName, false);
                    info.Show();
                }
                else if (fileType == DetectedFileType.BundleFile)
                {
                    bundleInst = am.LoadBundleFile(selectedFile, false);
                    //don't pester user to decompress if it's only the header that is compressed
                    if (AssetBundleUtil.IsBundleDataCompressed(bundleInst.file))
                    {
                        AskLoadCompressedBundle(bundleInst);
                    }
                    else
                    {
                        if ((bundleInst.file.bundleHeader6.flags & 0x3F) != 0) //header is compressed (most likely)
                        {
                            DecompressToMemory(bundleInst);
                        }
                        LoadBundle(bundleInst);
                    }
                }
            }
        }
Пример #2
0
        private async void MenuOpen_Click(object?sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title   = "Open assets or bundle file";
            ofd.Filters = new List <FileDialogFilter>()
            {
                new FileDialogFilter()
                {
                    Name = "All files", Extensions = new List <string>()
                    {
                        "*"
                    }
                }
            };
            string[] files = await ofd.ShowAsync(this);

            if (files != null && files.Length > 0)
            {
                string selectedFile = files[0];

                DetectedFileType fileType = AssetBundleDetector.DetectFileType(selectedFile);

                CloseAllFiles();

                //can you even have split bundles?
                if (fileType != DetectedFileType.Unknown)
                {
                    if (selectedFile.EndsWith(".split0"))
                    {
                        string?splitFilePath = await AskLoadSplitFile(selectedFile);

                        if (splitFilePath == null)
                        {
                            return;
                        }
                        else
                        {
                            selectedFile = splitFilePath;
                        }
                    }
                }

                if (fileType == DetectedFileType.AssetsFile)
                {
                    AssetsFileInstance fileInst = am.LoadAssetsFile(selectedFile, true);

                    if (!await LoadOrAskTypeData(fileInst))
                    {
                        return;
                    }

                    InfoWindow info = new InfoWindow(am, new List <AssetsFileInstance> {
                        fileInst
                    }, false);
                    info.Show();
                }
                else if (fileType == DetectedFileType.BundleFile)
                {
                    bundleInst = am.LoadBundleFile(selectedFile, false);
                    //don't pester user to decompress if it's only the header that is compressed
                    if (AssetBundleUtil.IsBundleDataCompressed(bundleInst.file))
                    {
                        AskLoadCompressedBundle(bundleInst);
                    }
                    else
                    {
                        if ((bundleInst.file.bundleHeader6.flags & 0x3F) != 0) //header is compressed (most likely)
                        {
                            bundleInst.file.UnpackInfoOnly();
                        }
                        LoadBundle(bundleInst);
                    }
                }
            }
        }