{"id":14970888,"url":"https://github.com/ishotihadus/mikunyan","last_synced_at":"2025-08-20T10:31:35.688Z","repository":{"id":56883702,"uuid":"96236978","full_name":"Ishotihadus/mikunyan","owner":"Ishotihadus","description":"Scriptable Unity asset deserializer for Ruby","archived":false,"fork":false,"pushed_at":"2023-06-28T05:13:25.000Z","size":1102,"stargazers_count":64,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-19T10:08:56.278Z","etag":null,"topics":["ruby-gem","unity","unity3d"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/mikunyan","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ishotihadus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-04T16:35:38.000Z","updated_at":"2024-12-02T23:24:54.000Z","dependencies_parsed_at":"2022-08-20T13:10:42.518Z","dependency_job_id":null,"html_url":"https://github.com/Ishotihadus/mikunyan","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishotihadus%2Fmikunyan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishotihadus%2Fmikunyan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishotihadus%2Fmikunyan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishotihadus%2Fmikunyan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ishotihadus","download_url":"https://codeload.github.com/Ishotihadus/mikunyan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230415317,"owners_count":18222158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby-gem","unity","unity3d"],"created_at":"2024-09-24T13:44:18.344Z","updated_at":"2024-12-19T10:08:59.901Z","avatar_url":"https://github.com/Ishotihadus.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mikunyan\n\nA Ruby library to deserialize AssetBundle files (\\*.unity3d) and asset files of Unity.\n\nThe name “Mikunyan” is derived from [Miku Maekawa](http://www.project-imas.com/wiki/Miku_Maekawa).\n\nRuby-Doc: http://www.rubydoc.info/gems/mikunyan/\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mikunyan'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install mikunyan\n\nIf you want to install development build:\n\n    $ git clone https://github.com/Ishotihadus/mikunyan\n    $ cd mikunyan\n    $ bundle install\n    $ rake build\n    $ gem install -l pkg/mikunyan-3.9.x.gem\n\n## Usage\n\n### Basic Usage\n\n```ruby\nrequire 'mikunyan'\n\n# load an AssetBundle file\nbundle = Mikunyan::AssetBundle.file(filename)\n\n# you can also load a bundle from blob\n# bundle = Mikunyan::AssetBundle.load(blob)\n\n# select asset (a bundle normally contains only one asset)\nasset = bundle.assets[0]\n\n# or you can directly load an asset from an asset file\n# asset = Mikunyan::Asset.file(filename)\n\n# get a list of objects\nobjects = asset.objects\n\n# get PathIds of objects\npath_ids = asset.path_ids\n\n# get an container table of objects (if available)\ncontainers = asset.containers\n\n# load an object (Mikunyan::ObjectValue)\nobj = asset.parse_object(objects[0])\n\n# load an object to Ruby data structures\nobj_hash = asset.parse_object_simple(objects[0])\n\n# a Hash can be serialized to JSON\nrequire 'json'\nobj_hash.to_json\n```\n\n### Mikunyan::ObjectValue\n\n`Mikunyan::ObjectValue` is formed in 3 types: value, array, and key-value table.\n\n```ruby\n# get whether obj is value or not\nobj.value?\n\n# get a value\nobj.value\n\n# same as obj.value\nobj[]\n\n\n# get whether obj is array or not\nobj.array?\n\n# get an array\nobj.value\n\n# you can directly access by index\nobj[0]\n\n\n# get keys (if obj is key-value table)\nobj.keys\n\n# get child objects\nobj[key]\n\n# same as obj[key]\nobj.key\n```\n\n### Unpack Texture2D\n\nMikunyan generates `ChunkyPNG::Image` images directly from Texture2D objects.\n\nMikunyan can decode images in basic texture formats (1–5, 7, 9, 13–20, 22, 62, 63), DXT1 (10), DXT5 (12), PVRTC1 (30–33), ETC (34), EAC (41–44), ETC2 (45–47), ASTC (48–59), HDR ASTC (66–71), or Crunched format (28, 29, 64, 65).\n\n```ruby\n# get some Texture2D asset\nobj = asset.parse_object(path_ids[1])\n\n# you can get image data\nimg = obj.generate_png\n\n# save it!\nimg.save('mikunyan.png')\n```\n\n### JSON / YAML Outputter\n\n`mikunyan-json` is an executable command for converting unity3d to JSON.\n\n    $ mikunyan-json bundle.unity3d \u003e bundle.json\n\nAvailable options:\n\n- `--as-asset` (`-a`): interpret input file as not AssetBundle but Asset\n- `--pretty` (`-p`): prettify output JSON\n- `--yaml` (`-y`): YAML mode\n\n### Image Outputter\n\n`mikunyan-image` is an executable command for unpacking images from unity3d.\n\n    $ mikunyan-image bundle.unity3d\n\nThe command generates JSON text, which contains information about unpacked images.\n\n```json\n[\n  {\n    \"name\": \"bg_x\",\n    \"width\": 512,\n    \"height\": 512,\n    \"format\": 56,\n    \"path_id\": -8556635666641176453\n  },\n  {\n    \"name\": \"bg\",\n    \"width\": 1024,\n    \"height\": 1024,\n    \"format\": 56,\n    \"path_id\": -1848302546424191165\n  }\n]\n```\n\nIf the option `--sprite` is specified, `mikunyan-image` will output sprites. The logged JSON also contains information about sprites.\n\n```json\n[\n  {\n    \"name\": \"bg_x\",\n    \"width\": 512,\n    \"height\": 512,\n    \"format\": 56,\n    \"path_id\": -8556635666641176453,\n    \"sprites\": [\n      {\n        \"name\": \"bg_4\",\n        \"x\": 171.0,\n        \"y\": 1.0,\n        \"width\": 168.0,\n        \"height\": 510.0,\n        \"path_id\": -9129589624490902606\n      },\n      {\n        \"name\": \"bg_5\",\n        \"x\": 341.0,\n        \"y\": 45.0,\n        \"width\": 168.0,\n        \"height\": 210.0,\n        \"path_id\": -4692216110975580946\n      },\n      {\n        \"name\": \"bg_2\",\n        \"x\": 1.0,\n        \"y\": 1.0,\n        \"width\": 168.0,\n        \"height\": 510.0,\n        \"path_id\": 5129117526830897711\n      },\n      {\n        \"name\": \"bg_3\",\n        \"x\": 341.0,\n        \"y\": 301.0,\n        \"width\": 168.0,\n        \"height\": 210.0,\n        \"path_id\": 8564534684796303817\n      }\n    ]\n  },\n  {\n    \"name\": \"bg\",\n    \"width\": 1024,\n    \"height\": 1024,\n    \"format\": 56,\n    \"path_id\": -1848302546424191165,\n    \"sprites\": [\n      {\n        \"name\": \"bg_1\",\n        \"x\": 1.0,\n        \"y\": 1.0,\n        \"width\": 720.0,\n        \"height\": 258.0,\n        \"path_id\": -3411127056098763138\n      },\n      {\n        \"name\": \"bg_0\",\n        \"x\": 1.0,\n        \"y\": 303.0,\n        \"width\": 1022.0,\n        \"height\": 720.0,\n        \"path_id\": 7486118431221564872\n      }\n    ]\n  }\n]\n```\n\nAvailable options:\n\n- `--as-asset` (`-a`): interpret input file as not AssetBundle but Asset\n- `--outputdir` (`-o`): specify an output directory (default is a basename of input file without an extension)\n- `--sprite` (`-s`): output sprites instead of textures\n- `--pretty` (`-p`): prettify output JSON\n\n## Dependencies\n\n- [json](https://rubygems.org/gems/json)\n- [extlz4](https://rubygems.org/gems/extlz4)\n- [extlzma2](https://rubygems.org/gems/extlzma2)\n  - extlzma2 requires liblzma. You may need a `--with-liblzma-dir=` argument to install extlzma2.\n- [bin_utils](https://rubygems.org/gems/bin_utils)\n- [chunky_png](https://rubygems.org/gems/chunky_png)\n\nMikunyan uses [oily_png](https://rubygems.org/gems/oily_png) instead of chunky_png if available.\n\nNote: extlz4 0.3 (current version) has a fatal bug because of LZ4 v1.9.0. In case of SIGSEGV in extlz4, you need to build extlz4 with the latest LZ4.\n\n## Implementation in other languages\n\n- TypeScript: [shibunyan](https://github.com/AnemoneStar/shibunyan)\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/Ishotihadus/mikunyan.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n## Acknowledgements\n\nThis project contains following softwares.\n\n- [Unity's crunch/crnlib](https://github.com/Unity-Technologies/crunch) (zlib License)\n- [FP16](https://github.com/Maratyszcza/FP16/) (MIT License)\n- [endianness.h](https://gist.github.com/jtbr/7a43e6281e6cca353b33ee501421860c) (MIT License)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishotihadus%2Fmikunyan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fishotihadus%2Fmikunyan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishotihadus%2Fmikunyan/lists"}