Пример #1
0
    private void PatchDependencyPointers(byte[] bytes)
    {
        Debug.Log("Patching dependency pointers...");

        var dependencyMap = DependencyPathIdMap.Load().OptimizedMap;

        int count     = 0;
        var memStream = new MemoryStream(bytes);

        using (var s = new BinaryReader(memStream))
        {
            while (s.BaseStream.Position < s.BaseStream.Length - 8)
            {
                long ourPathId = s.ReadInt64();
                s.BaseStream.Position -= 7;

                if (dependencyMap.ContainsKey(ourPathId))
                {
                    long origPathId = dependencyMap[ourPathId];
                    var  wr         = new BinaryWriter(memStream);
                    wr.Seek((int)wr.BaseStream.Position - 1, SeekOrigin.Begin);
                    wr.Write(origPathId);
                    wr.Flush();

                    count++;
                }
            }
        }

        Debug.Log($"Replaced {count} dependency path IDs.");
    }
Пример #2
0
    private void OnGUI()
    {
        if (_pathIdMap == null)
        {
            _pathIdMap = DependencyPathIdMap.Load();
        }

        if (_pathIdMap == null)
        {
            EditorGUILayout.HelpBox("DependencyPathIdMap missing! Please create it in the Resources folder.", MessageType.Error);
            return;
        }

        _srcAbName   = EditorGUILayout.TextField("Custom AssetBundle", _srcAbName);
        _dstAbName   = EditorGUILayout.TextField("Original AssetBundle", _dstAbName);
        _showPathIds = EditorGUILayout.ToggleLeft("Show Path IDs", _showPathIds);
        if (GUILayout.Button("Load"))
        {
            LoadAssets();
        }

        if (_srcAb == null || _dstAb == null || _srcAssetsByType == null || _dstAssetsByType == null)
        {
            EditorGUILayout.HelpBox("No AssetBundles loaded.", MessageType.Info);
            return;
        }

        EditorGUILayout.Separator();
        using (new EditorGUILayout.HorizontalScope())
        {
            EditorGUILayout.LabelField("Source Asset", EditorStyles.boldLabel);
            EditorGUILayout.LabelField("Type", EditorStyles.boldLabel);
            EditorGUILayout.LabelField("Destination Asset", EditorStyles.boldLabel);
        }

        using (var scrollView = new EditorGUILayout.ScrollViewScope(_scrollPos))
        {
            _scrollPos = scrollView.scrollPosition;
            DrawMainGUI();
        }
    }