pathName | The path of folder to save InstantAssetTable file and bundles. |
directories | The paths of folders where assets packing operation is performed. |
size | Size per bundle in bytes. |
targetPlatform | The target platform for asset packing. |
bool Return true if asset packing is successful, return false if it fails.
Pakcing assets from the specified folders to some bundles, and generate an InstantAssetTable to record asset information.
InstantAssetTable is saved in a single file with a name based on the folder path(e.g., InstantAssetTable_Assets_Test for assets in Assets/Test).
using UnityEditor; using UnityEngine;
public class BasicBuildExample { [MenuItem("Tools/Build Instant Assets/Basic Directory Build")] public static void BuildAssetsFromDirectories() { string outputPath = "Assets/Output/InstantAssets"; string[] directories = { "Assets/Resources/UI", "Assets/Resources/Models" }; int maxBundleSize = 1024 * 1024; // 1MB per bundle bool success = InstantAssetEditorUtility.BuildAssetPacker( outputPath, directories, maxBundleSize, BuildTarget.StandaloneWindows64);
if (success) { Debug.Log("Instant Asset packages built successfully!"); } else { Debug.LogError("Failed to build Instant Asset packages."); } } }
pathName | The path of folder to save InstantAssetTable file and bundles. |
size | Size per bundle in bytes. |
targetPlatform | The target platform for asset packing. |
instantAssetAliasTables | Array of alias tables specifying directories or specific assets. |
buildOptions | Build options (compression method, rebuild behavior, etc.). |
bool Return true if asset packing is successful, return false if it fails.
Provides fine-grained control over the asset packing process, allowing custom alias table names, specific asset lists, and build options including compression settings.
using UnityEditor; using UnityEngine;
public class AdvancedBuildExample { [MenuItem("Tools/Build Instant Assets/Advanced Custom Build")] public static void BuildAssetsAdvanced() { string outputPath = "Assets/Output/CustomInstantAssets";
var aliasTables = new[] { new InstantAssetAliasTable { aliasTableName = "UITable", buildDirectoryPath = "Assets/Resources/UI" }, new InstantAssetAliasTable { aliasTableName = "CharacterModels", assetNames = new[] { "Assets/Models/Player.fbx", "Assets/Models/NPC.fbx" } } };
var options = InstantAssetOptions.CompressionLz4HC | InstantAssetOptions.ForceRebuild; int maxBundleSize = 2 * 1024 * 1024; // 2MB per bundle
bool success = InstantAssetEditorUtility.BuildAssetPacker( outputPath, aliasTables, options, maxBundleSize, BuildTarget.Android);
if (success) { Debug.Log("Advanced Instant Asset packages built successfully!"); } else { Debug.LogError("Failed to build advanced Instant Asset packages."); } } }