Ejemplo n.º 1
0
        public void Read(BinaryReader r)
        {
            pathId  = r.ReadInt64();
            changes = new List <ComponentChangeOrAdd>();
            int changesCount = r.ReadInt32();

            for (int i = 0; i < changesCount; i++)
            {
                ComponentChangeOrAdd change = new ComponentChangeOrAdd();
                change.Read(r);
                changes.Add(change);
            }
            int removesCount = r.ReadInt32();

            for (int i = 0; i < removesCount; i++)
            {
                ComponentRemove remove = new ComponentRemove();
                remove.Read(r);
                removes.Add(remove);
            }
        }
Ejemplo n.º 2
0
        public static AssetsReplacer DiffComponent(AssetFileInfoEx info, AssetTypeValueField baseField, ClassDatabaseFile cldb, ComponentChangeOrAdd compChange, ulong pathId)
        {
            //todo: shouldn't need to overwrite, using info.curFileType would probably work fine
            int classId = AssetHelper.FindAssetClassByName(cldb, compChange.componentType).classId;

            foreach (FieldChange fieldChange in compChange.changes)
            {
                AssetTypeValueField field = baseField;
                foreach (string curPath in fieldChange.fieldName.Split('/'))
                {
                    field = field.Get(curPath);
                }

                object value = DecodeValueByName(fieldChange.data, fieldChange.fieldType);
                if (value != null)
                {
                    //UnityEngine.Debug.Log("HKWE SV " + value.ToString());
                    field.GetValue().Set(value);
                }
                else
                {
                    //UnityEngine.Debug.Log("HKWE NV");
                }
            }

            byte[] moveAsset;
            using (MemoryStream memStream = new MemoryStream())
                using (AssetsFileWriter writer = new AssetsFileWriter(memStream))
                {
                    writer.bigEndian = false;
                    baseField.Write(writer);
                    moveAsset = memStream.ToArray();
                }

            return(new AssetsReplacerFromMemory(0, pathId, classId, 0xFFFF, moveAsset));
        }