-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Description
After modifying the texture2d data in the bundle file using at2/at3, there is a probability that this error will occur:
Mismatched serialization in the builtin class 'Texture2D'. (Read 264 bytes but expected 240 bytes)
I will experience stable issues when using AT2 and AT3 separately.
var assetsMananger = new AssetsManager();
assetsMananger.LoadClassPackage(newtpk);
var bunInst = assetsMananger.LoadBundleFile(ab);
int fileTotal = bunInst.file.GetAllFileNames().Count;
for (int i = 0; i< fileTotal; i++)
{
var inst = assetsMananger.LoadAssetsFileFromBundle(bunInst, i, false);
assetsMananger.LoadClassDatabaseFromPackage(inst.file.Metadata.UnityVersion);
foreach(var inf in inst.file.GetAssetsOfType(AssetClassID.Texture2D))
{
var baseField = assetsMananger.GetBaseField(inst, inf);
var width = baseField["m_Width"].AsInt;
var height = baseField["m_Height"].AsInt;
var tf = TextureFile.ReadTextureFile(baseField);
var bytes = ..... // my new datas
tf.SetTextureDataRaw(bytes, width, height);
tf.m_TextureFormat = (int)TextureFormat.ETC_RGB4;
tf.m_MipMap = false;
tf.m_MipCount = 1;
tf.WriteTo(baseField);
inf.SetNewData(baseField);
......When I Console.WriteLine SetNewData method baseField.WriteToByteArray().Length is 240 (Unity Expected).
This problem does not necessarily occur, I have a recurring AB here.
My production environment:
- Unity Editor: 2021.2.18
- Platform: WebGL
Metadata
Metadata
Assignees
Labels
No labels