3.2.0 • Published 12 months ago

@arkntools/unity-js v3.2.0

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
12 months ago

unity-js

NPM version

JS implementation of Unity AssetBundle unpacking.

Only the minimum implementation required for the project was done. If you need complete functionality, it is recommended to use a more complete library in other languages.

Currently only supports:

  • TextAsset
  • Texture2d
  • Sprite
  • SpriteAtlas
import fs from 'fs';
import { loadAssetBundle, AssetType } from '@arkntools/unity-js';

(async () => {
  const bundle = await loadAssetBundle(fs.readFileSync('character_table003334.ab'));
  for (const obj of bundle.objects) {
    if (obj.type === AssetType.TextAsset) {
      fs.writeFileSync(`${obj.name}.bytes`, obj.data);
      break;
    }
  }
})();

(async () => {
  const bundle = await loadAssetBundle(fs.readFileSync('spritepack_ui_char_avatar_h1_0.ab'));
  for (const obj of bundle.objects) {
    if (obj.type === AssetType.Sprite && obj.name === 'char_002_amiya') {
      fs.writeFileSync(`${obj.name}.png`, await obj.getImage()!);
      break;
    }
  }
})();

(async () => {
  const bundle = await loadAssetBundle(fs.readFileSync('char_1028_texas2.ab'), {
    // Some sprites may not give the PathID of the alpha texture, you can provide a custom function to find it.
    findAlphaTexture: (texture, assets) =>
      assets.find(({ name }) => name === `${texture.name}[alpha]`),
  });
  for (const obj of bundle.objects) {
    if (obj.type === AssetType.Sprite && obj.name === 'char_1028_texas2_1') {
      fs.writeFileSync(`${obj.name}.png`, await obj.getImage()!);
      break;
    }
  }
})();

References

3.0.0-alpha.6

1 year ago

3.0.0-alpha.1

1 year ago

3.0.0-alpha.0

1 year ago

3.0.0-alpha.3

1 year ago

3.0.0-alpha.2

1 year ago

3.0.0-alpha.5

1 year ago

3.0.0-alpha.4

1 year ago

3.0.1-alpha.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.2.0

12 months ago

3.1.1

12 months ago

3.0.2

1 year ago

3.1.0

1 year ago

3.0.1

1 year ago

3.0.7

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

3.0.0

1 year ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

1.0.0-alpha.0

2 years ago