{"id":15292755,"url":"https://github.com/mitmadness/assetbundlecompiler","last_synced_at":"2025-04-13T09:32:34.551Z","repository":{"id":84011344,"uuid":"86568434","full_name":"mitmadness/AssetBundleCompiler","owner":"mitmadness","description":":package: Node.js wrapper around Unity3D's BuildPipeline to create AssetBundles from any files","archived":false,"fork":false,"pushed_at":"2023-08-17T15:27:31.000Z","size":152,"stargazers_count":51,"open_issues_count":4,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-20T05:02:53.425Z","etag":null,"topics":["assetbundle","build-automation","nodejs","unity3d"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mitmadness.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-03-29T10:20:34.000Z","updated_at":"2024-02-25T04:14:46.000Z","dependencies_parsed_at":"2024-01-22T03:58:02.850Z","dependency_job_id":"59c67b4c-a192-45f6-b252-7712c09a34cc","html_url":"https://github.com/mitmadness/AssetBundleCompiler","commit_stats":{"total_commits":100,"total_committers":2,"mean_commits":50.0,"dds":0.06999999999999995,"last_synced_commit":"40cee7abcb54ec0e81f9ce1489fdbcdeb50bb1a3"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitmadness%2FAssetBundleCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitmadness%2FAssetBundleCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitmadness%2FAssetBundleCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitmadness%2FAssetBundleCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitmadness","download_url":"https://codeload.github.com/mitmadness/AssetBundleCompiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219846682,"owners_count":16556429,"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":["assetbundle","build-automation","nodejs","unity3d"],"created_at":"2024-09-30T16:26:32.875Z","updated_at":"2024-10-14T21:23:30.305Z","avatar_url":"https://github.com/mitmadness.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/mitmadness/AssetBundleCompiler/raw/master/abcompiler-logo.png\" alt=\"AssetBundleCompiler logo\" align=\"right\"\u003e\n\n# [AssetBundle](https://docs.unity3d.com/Manual/AssetBundlesIntro.html)Compiler\n\n[![npm version](https://img.shields.io/npm/v/@mitm/assetbundlecompiler.svg?style=flat-square)](https://www.npmjs.com/package/@mitm/assetbundlecompiler) ![license](https://img.shields.io/github/license/mitmadness/AssetBundleCompiler.svg?style=flat-square) [![Travis Build](https://img.shields.io/travis/mitmadness/AssetBundleCompiler.svg?style=flat-square)](https://travis-ci.org/mitmadness/AssetBundleCompiler) ![npm total downloads](https://img.shields.io/npm/dt/@mitm/assetbundlecompiler.svg?style=flat-square)\n\nNode.js wrapper around Unity3D's BuildPipeline to create AssetBundles programmatically from any files, in order to simplify and automatize your workflow.\n\nFrom the [documentation](https://docs.unity3d.com/Manual/AssetBundlesIntro.html):\n\n\u003e AssetBundles are files which you can export from Unity to contain Assets of your choice, [that] can be loaded on demand by your application. This allows you to stream content, such as models, Textures, audio clips, or even entire Scenes [...].\n\n*:point_right: See also: [@mitm/chuck](https://github.com/mitmadness/chuck), a fully-featured webservice that builds asset bundles.*\n\n----------------\n\nBuild automation with Unity's CLI and generating asset bundles gives headaches. If you are integrating asset bundle generation in a Node.js server or want a simple tool to do it, AssetBundleCompiler may satisfy you:\n\n```typescript\nawait bundle(...assets).targeting(WebGL).to('/path/to/asset.bundle');\n```\n\n - [Installation \u0026 Usage](#package-installation--usage)\n - [Simple, fluent API](#link-simple-fluent-api)\n - Notes:\n   [Error handling](#error-handling), [Changing Unity's executable path](#changing-unitys-executable-path), [Unity activation](#unity-activation), [Future scope](https://github.com/mitmadness/AssetBundleCompiler/projects/1)\n\n----------------\n\n## :package: Installation \u0026 Usage\n\n**Requirements:**\n\n - Node.js, version 7 preferred\n - :warning: **An _activated_ installation of Unity on the machine** :warning:\n    - If Unity is not installed in the standard path, read [Changing Unity's executable path](#changing-unitys-executable-path)\n    - You must activate Unity if not already done, even with a free plan, read [Unity activation](#unity-activation)\n\nInstall it via the npm registry:\n\n```\nyarn add @mitm/assetbundlecompiler\n```\n\n## :link: Simple, fluent API\n\n```typescript\nimport { BuildTargets, bundle } from '@mitm/assetbundlecompiler';\n\nconst { WebGL } = BuildTargets;\n\n// bundle() is the entry function to the API.\n// Pass a list of assets to bundle into the resulting asset bundle.\n// Those assets could be anywhere on the filesystem.\n// To pass an array of paths, use bundle(...paths) syntax.\nawait bundle('/abs/path/to/fbx', '/abs/path/to/texture', /* ... */)\n    // .targeting() is mandatory and tells the library what platform your asset bundle targets.\n    // You can either pass a predefined constant in BuildTargets, or a string,\n    // matching the name of a member of the UnityEditor.BuildTarget enum.\n    // @see https://docs.unity3d.com/ScriptReference/BuildTarget.html\n    .targeting(WebGL)\n    \n    // Lets you install custom Editor scripts before asset bundle generation.\n    // This is very useful, for example, to create an Asset Postprocessor to customize how\n    // your resources are imported into the asset bundle, using AssetImporters for example.\n    // @see https://docs.unity3d.com/ScriptReference/AssetPostprocessor.html\n    .includingEditorScripts('/abs/path/to/script.dll', '/abs/path/to/script.cs')\n    \n    // Lets you define build options. Those are always flags, and the key names represent\n    // member names of the UnityEditor.BuildAssetBundleOptions enum.\n    // @see https://docs.unity3d.com/ScriptReference/BuildAssetBundleOptions.html\n    .withBuildOptions({ chunkBasedCompression: true, strictMode: true, /* etc */ })\n    \n    // This lets you define a simple logger to get simple text updates about the conversion.\n    .withLogger(message =\u003e console.log(message))\n    \n    // This lets you define a logger for the real-time output of Unity (stdout+stderr).\n    // Beware, it's very verbose :)\n    .withUnityLogger(message =\u003e console.log(`Unity: ${message}`))\n    \n    // This is the \"run\" function and marks the termination of the fluent calls\n    // by returning a Promise that resolves when the asset bundle generation ends.\n    // Give it a path to the asset bundle name or a fs.WriteStream.\n    .to('/abs/path/to/resources.assetbundle');\n```\n\nYou can also retrieve the manifest Unity generates during the build - the manifest contains informations about the asset bundle:\n\n```typescript\n// The promise gets resolved with the manifest as a plain JS object\nconst manifest = await bundle('...').to('...');\n\n/* manifest = { \n    CRC: 2924050344,\n    Assets: ['Assets/CopiedAssets/MyAsset.jpg'],\n    ...etc...\n} */\n```\n\nYou can also dump the original manifest file (a YAML file) alongside the assetbundle:\n\n```typescript\nconst manifest = await bundle('...')\n    // manifestFile can take a path or a fs.WriteStream too\n    .to('/path/to/resources.assetbundle', { manifestFile: '/path/to/resources.assetbundle.manifest' });\n```\n\n## :bulb: Notes\n\n### Error handling\n\n\u003e What could possibly go wrong?\n\n_AssetBundleCompiler_ will catch abnormal Unity process termination and throw an error in that case (and performs a rapid cleanup).\nThe error is an instance of `UnityCrashError` (exported on the main module) and its prototype looks like:\n\n```typescript\nclass UnityCrashError extends Error {\n    public readonly message: string; // Exception message\n    public readonly unityLog: string; // Unity Editor log (contains crash information)\n}\n```\n\nThe logs will also be dumped to you system temporary folder (ie. /tmp) in a file named `unity_crash.abcompiler.log` (the complete path will be reported in the error's message).\n\nPlease note that SIGINT and SIGTERM signals are also catched and the same cleanup is performed.\n\n### Changing Unity's executable path\n\nBy default, _AssetBundleCompiler_ will try to find Unity's executable on the expected locations. The library will look at the following paths:\n\n - `/opt/Unity/Editor/Unity` – Debian / Ubuntu [with the official .deb package](https://forum.unity3d.com/threads/unity-on-linux-release-notes-and-known-issues.350256/)\n - `/Applications/Unity/Unity.app/Contents/MacOS/Unity` – MacOS\n - `C:\\Program Files (x86)\\Unity\\Editor\\Unity.exe` – Windows, Unity x86\n - `C:\\Program Files\\Unity\\Editor\\Unity.exe` – Windows, Unity x64\n\nIf you have a custom installation of Unity on a \"non-standard\" path (ie. you have multiple versions installed), you can tell _AssetBundleCompiler_ where to look:\n\n```typescript\nimport { setUnityPath } from '@mitm/assetbundlecompiler';\n\n// given that you define the environment variable UNITY_EDITOR_PATH, to avoid hardcoded path:\nsetUnityPath(process.env.UNITY_EDITOR_PATH);\n```\n\n### Unity activation\n\nUnity is a proprietary software that requires to be activated with a valid account, even if that's not necessary for building asset bundles. This library does not handle activation, meaning that you _must_ already have an activated version of Unity on the machine.\n\n**Building asset bundles, does not requires a paid account.** You can log in with your free _Personal_ license.\n\nActivation via Unity's CLI is possible too (for automating installation for example) but is somewhat broken from times to times, and **does not works with personal licenses**. So, given you have a paid accound, you can do:\n\n```\n~$ /path/to/Unity -quit -batchmode -serial SB-XXXX-XXXX-XXXX-XXXX-XXXX -username 'JoeBloggs@example.com' -password 'MyPassw0rd'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitmadness%2Fassetbundlecompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitmadness%2Fassetbundlecompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitmadness%2Fassetbundlecompiler/lists"}