Пример #1
0
        //MonobehaviourSearch
        //TransformSearch
        //Dependencies
        #endregion

        public AssetsViewer(AssetsManager am, AssetsFileInstance instance, bool fromBundle = false)
        {
            InitializeComponent();

            Workspace              = new AssetsWorkspace(am, instance, fromBundle);
            Workspace.ItemUpdated += UpdateAssetInfo;
            Am         = Workspace.Am;
            Pm         = Workspace.Pm;
            MainFile   = Workspace.MainInstance;
            FromBundle = Workspace.FromBundle;

            Importer = Workspace.Importer;
            Exporter = Workspace.Exporter;

            AssetsFileName = Workspace.AssetsFileName;
            AssetsRootDir  = Workspace.AssetsRootDir;
            UnityVersion   = Workspace.UnityVersion;

            ModifiedFiles = new Dictionary <BundleReplacer, MemoryStream>();
            //UndoList = new Stack<List<int>>();
            //RedoList = new Stack<List<int>>();

            SetFormText();
            LoadAssetsToList();
        }
Пример #2
0
 public AssetData(AssetsWorkspace workspace, AssetTypeValueField baseField)
 {
     InitializeComponent();
     Workspace = workspace;
     BaseField = baseField;
     PopulateTree();
     LoadDump();
 }
Пример #3
0
        public static AssetTypeInstance GetByteArrayTexture(AssetsWorkspace workspace, AssetContainer tex)
        {
            var textureTemp = workspace.GetTemplateField(tex.Item);
            var image_data  = textureTemp.children.FirstOrDefault(f => f.name == "image data");

            if (image_data == null)
            {
                return(null);
            }
            image_data.valueType = EnumValueTypes.ByteArray;
            var texTypeInst = new AssetTypeInstance(new[] { textureTemp }, tex.FileReader, tex.Item.Position);

            return(texTypeInst);
        }
Пример #4
0
        public EditDialog(IWin32Window owner, AssetsWorkspace workspace, List <AssetContainer> selectedAssets)
        {
            InitializeComponent();

            this.owner          = owner;
            this.workspace      = workspace;
            this.selectedAssets = selectedAssets;
            var plugInfs = workspace.Pm.GetSupportedPlugins(selectedAssets);

            foreach (var plugInfo in plugInfs)
            {
                lboxPluginsList.Items.Add(plugInfo);
            }
        }
Пример #5
0
        public BatchImport(AssetsWorkspace workspace, List <AssetContainer> selectedAssets, string directory, params string[] extensions)
        {
            InitializeComponent();

            this.directory = directory;
            batchItems     = new List <BatchImportItem>();

            var filesInDir = new List <string>();

            foreach (var ext in extensions)
            {
                filesInDir.AddRange(Directory.GetFiles(directory, "*" + ext));
            }

            foreach (var cont in selectedAssets)
            {
                var item = cont.Item;
                Extensions.GetUAAENameFast(workspace, item, out _, out var name);
                var batchItem = new BatchImportItem
                {
                    Description = name,
                    File        = Path.GetFileName(cont.FileInstance.path),
                    PathID      = cont.Item.PathID,
                    Type        = item.Type,
                    Cont        = cont
                };

                var matchingFiles = new List <string>();
                foreach (var ext in extensions)
                {
                    var endWith = batchItem.GetMatchName(ext);
                    matchingFiles.AddRange(filesInDir.Where(f => f.EndsWith(endWith)).Select(Path.GetFileName).ToList());
                }
                batchItem.MatchingFiles = matchingFiles;
                batchItem.SelectedIndex = matchingFiles.Count > 0 ? 0 : -1;
                batchItems.Add(batchItem);
                affectedAssetsList.Items.Add(new ListViewItem(batchItem.ToArray()));
            }
        }
Пример #6
0
 public abstract bool ExecutePlugin(IWin32Window owner, AssetsWorkspace workspace, List <AssetContainer> selectedAssets);
Пример #7
0
        public static void GetUAAENameFast(AssetsWorkspace workspace, AssetItem item, out string type, out string name)
        {
            var file     = workspace.LoadedFiles[item.FileID].file;
            var cldb     = workspace.Am.classFile;
            var classId  = item.TypeID;
            var cldbType = AssetHelper.FindAssetClassByID(cldb, classId);
            var reader   = file.reader;

            if (file.typeTree.hasTypeTree)
            {
                var ttType = classId == 0x72 ?
                             AssetHelper.FindTypeTreeTypeByScriptIndex(file.typeTree, item.MonoID) :
                             AssetHelper.FindTypeTreeTypeByID(file.typeTree, classId);


                type = ttType.typeFieldsEx[0].GetTypeString(ttType.stringTable);
                switch (ttType.typeFieldsEx.Length)
                {
                case > 1 when ttType.typeFieldsEx[1].GetNameString(ttType.stringTable) == "m_Name":
                {
                    reader.Position = item.Position;
                    name            = reader.ReadCountStringInt32();
                    if (name != "")
                    {
                        return;
                    }
                    break;
                }

                default:
                    switch (type)
                    {
                    case "GameObject":
                    {
                        reader.Position = item.Position;
                        var size          = reader.ReadInt32();
                        var componentSize = file.header.format > 0x10 ? 0x0c : 0x10;
                        reader.Position += size * componentSize;
                        reader.Position += 0x04;
                        name             = reader.ReadCountStringInt32();
                        name             = name == "" ? "Unnamed asset" : $"{type} {name}";
                        return;
                    }

                    case "MonoBehaviour":
                        reader.Position  = item.Position;
                        reader.Position += 0x1c;
                        name             = reader.ReadCountStringInt32();
                        name             = name == "" ? "Unnamed asset" : $"{type} {name}";
                        return;
                    }
                    break;
                }
                name = "Unnamed asset";
                return;
            }

            if (cldbType == null)
            {
                type = $"0x{classId:X8}";
                name = "Unnamed asset";
                return;
            }

            type = cldbType.name.GetString(cldb);
            switch (cldbType.fields.Count)
            {
            case 0:
                name = "Unnamed asset";
                return;

            case > 1 when cldbType.fields[1].fieldName.GetString(cldb) == "m_Name":
            {
                reader.Position = item.Position;
                name            = reader.ReadCountStringInt32();
                if (name != "")
                {
                    return;
                }
                break;
            }

            default:
                switch (type)
                {
                case "GameObject":
                {
                    reader.Position = item.Position;
                    var size          = reader.ReadInt32();
                    var componentSize = file.header.format > 0x10 ? 0x0c : 0x10;
                    reader.Position += size * componentSize;
                    reader.Position += 0x04;
                    name             = reader.ReadCountStringInt32();
                    name             = name == "" ? "Unnamed asset" : $"{type} {name}";
                    return;
                }

                case "MonoBehaviour":
                {
                    reader.Position  = item.Position;
                    reader.Position += 0x1c;
                    name             = reader.ReadCountStringInt32();
                    name             = name == "" ? "Unnamed asset" : $"{type} {name}";
                    return;
                }
                }
                break;
            }
            name = "Unnamed asset";
        }
Пример #8
0
 public AddAssets(AssetsWorkspace workspace)
 {
     InitializeComponent();
     Workspace = workspace;
     Items     = new List <AssetItem>();
 }
Пример #9
0
 public GoToAssetDialog(AssetsWorkspace workspace)
 {
     InitializeComponent();
     this.workspace = workspace;
 }