Пример #1
0
        private static void CompressBundleImpl(string unity3DFilePath, bool randomizeCab)
        {
            using (var parser = Plugins.OpenUnity3d(unity3DFilePath))
                using (var editor = new Unity3dEditor(parser, false))
                {
                    // GetAssetNames does more than the name suggests, needs to stay
                    var _ = editor.GetAssetNames(true);

                    if (randomizeCab)
                    {
                        if (parser.FileInfos != null && parser.FileInfos.Count > 1)
                        {
                            Console.WriteLine("Could not randomize CAB string because the bundle contains multiple cabinets. Path: " + unity3DFilePath);
                        }
                        else
                        {
                            var rnbuf = new byte[16];
                            rng.GetBytes(rnbuf);
                            var newCab = "CAB-" + string.Concat(rnbuf.Select((x) => ((int)x).ToString("X2")).ToArray()).ToLower();
                            editor.RenameCabinet(0, newCab);
                        }
                    }

                    editor.SaveUnity3d(false, ".unit-y3d", false, true, -1, 2, 262144);
                }
        }
Пример #2
0
        private static void CompressBundleImpl(string unity3DFilePath, bool randomizeCab)
        {
            using (var parser = Plugins.OpenUnity3d(unity3DFilePath))
                using (var editor = new Unity3dEditor(parser, false))
                {
                    // GetAssetNames does more than the name suggests, needs to stay
                    var _ = editor.GetAssetNames(true);

                    if (randomizeCab)
                    {
                        var rnbuf = new byte[16];
                        rng.GetBytes(rnbuf);
                        var newCab = "CAB-" + string.Concat(rnbuf.Select((x) => ((int)x).ToString("X2")).ToArray()).ToLower();
                        editor.RenameCabinet(0, newCab);
                    }

                    editor.SaveUnity3d(false, ".unit-y3d", false, true, -1, 2, 262144);
                }
        }
Пример #3
0
        private static int HashFileContentsImpl(string unity3DFilePath)
        {
            using (var parser = Plugins.OpenUnity3d(unity3DFilePath))
                using (var editor = new Unity3dEditor(parser, false))
                {
                    var sbResult = new StringBuilder();
                    var names    = editor.GetAssetNames(false);
                    for (var i = 0; i < names.Length; i++)
                    {
                        var asset = editor.Parser.Cabinet.Components[i];
                        sbResult.AppendFormat(CultureInfo.InvariantCulture, "{0}\0{1}\0{2}\0{3}\n", asset.pathID, asset.classID1, asset.classID2, names[i]);
                        //Console.WriteLine("PathID=" + asset.pathID.ToString("D") + " id1=" + (int)asset.classID1 + "/" + asset.classID1 + " id2=" + asset.classID2 + " " + names[i]);
                        if (asset is NotLoaded notLoaded)
                        {
                            sbResult.AppendFormat(CultureInfo.InvariantCulture, "{0}\0{1}\n", notLoaded.offset, notLoaded.size);
                        }
                    }

                    return(GetStableHashCode(sbResult));
                }
        }