예제 #1
0
def test_read():
    import UnityPy
    for f in os.listdir(SAMPLES):
        am = UnityPy.AssetsManager(os.path.join(SAMPLES, f))
        for asset in am.assets.values():
            for obj in asset.objects.values():
                obj.read()
예제 #2
0
def test_sprite():
    import UnityPy
    for f in os.listdir(SAMPLES):
        am = UnityPy.AssetsManager(os.path.join(SAMPLES, f))
        for asset in am.assets.values():
            for obj in asset.objects.values():
                if obj.type == "Sprite":
                    obj.read().image.save("test.png")
예제 #3
0
def test_texture2d():
    import UnityPy
    for f in os.listdir(SAMPLES):
        am = UnityPy.AssetsManager(os.path.join(SAMPLES, f))
        for asset in am.assets.values():
            for obj in asset.objects.values():
                if obj.type == "Texture2D":
                    obj.read().image
예제 #4
0
try:
    import UnityPy
except ImportError:
    raise ImportError('Please pip install UnityPy')

logging.basicConfig(level=logging.INFO)

orig_path = Path.cwd()

for asset_fn in sys.argv[1:]:
    os.chdir(orig_path)
    # UnityPy searches for .resource files relative to current directory
    # not relative to .assets dir...
    os.chdir(Path(asset_fn).parent)

    am = UnityPy.AssetsManager()
    am.load_file(asset_fn)

    sf, = am.assets.values()
    msk = [v for v in sf.objects.values() if v.type == 'AudioClip']
    for m in msk:
        obj = m.read()

        for filename, mem in obj.samples.items():
            target = orig_path / filename
            try:
                with open(target, 'xb') as fp:
                    fp.write(mem)
            except FileExistsError:
                print(f"Will not overwrite exisisting file {filename}")
            else: