Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Texture2D 2020.2.2f1 failed. #50

Closed
keel opened this issue Jun 2, 2021 · 7 comments
Closed

Replace Texture2D 2020.2.2f1 failed. #50

keel opened this issue Jun 2, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@keel
Copy link

keel commented Jun 2, 2021

The code, repalce one image:

import os
import UnityPy
from PIL import Image

if __name__ == '__main__':
  path = r'./data.unity3d'    
  env = UnityPy.load(path);
  for obj in env.objects:
      if obj.type == "Texture2D":
        data = obj.read();
        target = 'sactx-4-2048x2048-Crunch-Opening-f2cb946e';
        if data.name == target:
            print('save');
            data.image = Image.open(r''+target+'.png')
            data.save();
  open(path + '_2', 'wb').write(env.file.save());
  print('done');

The log:

E/Unity: Could not open file /data/app/r****.t2-hvUp7W4EeakH85PlEo-8Xg==/base.apk/assets/bin/Data/archive:/CAB-UnityPy_Mod.resS for read

 E/Unity: async texture load: failed to load sactx-4-2048x2048-Crunch-Opening-f2cb946e from /data/app/r*****.t2-hvUp7W4EeakH85PlEo-8Xg==/base.apk/assets/bin/Data/archive:/CAB-UnityPy_Mod.resS

UnityPy version : 1.7.6

@keel keel added the bug Something isn't working label Jun 2, 2021
@keel
Copy link
Author

keel commented Jun 2, 2021

This is a powerful project! Thanks for open. Please check this issue, I think it will be perfect tool for unity mod.

@K0lb3
Copy link
Owner

K0lb3 commented Jun 3, 2021

Can you post the complete traceback of the exception?

Considering the log you wrote,
I would guess that you're trying to edit an asset you already edited once, which causes problems atm.

@keel
Copy link
Author

keel commented Jun 4, 2021

There's no more exception, just this two lines error log, and I checked the assets ,make sure it's not edited , but the problem is same. Maybe 2020.2.2f1 have some changes? Is there anything I can try?

@andrewpedia
Copy link

same issue

@K0lb3
Copy link
Owner

K0lb3 commented Jun 19, 2021

Sorry, I was a bit busy irl.

I guess that the load failed because the resource file created by UnityPy isn't flagged as to be loaded intermediately.

I added a new function in 1.7.7 that can be used to decide yourself how the data of a Texture2D,
which currently always tries to store its data in a (newly created) cab, is stored.
The default arguments of Texture2D.set_image store the image data within the Texture2D object, so the error that showed up on your site should be solvable with it.

@K0lb3
Copy link
Owner

K0lb3 commented Oct 20, 2021

0bb34ed should have fixed the issue.

@keel
Copy link
Author

keel commented Oct 21, 2021

Thanks.

@keel keel closed this as completed Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants