Created
April 1, 2016 12:19
-
-
Save elmirjagudin/46c5fdfdc523488d4eb51903715a9641 to your computer and use it in GitHub Desktop.
create unity asset bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
using System; | |
using System.IO; | |
class MyEditorScript | |
{ | |
const string ASSET_NAME = "Assets/fbx/import.fbx"; | |
[MenuItem("Assets/orange")] | |
static void PerformBuild() | |
{ | |
Console.WriteLine("import asset"); | |
AssetDatabase.ImportAsset(ASSET_NAME, ImportAssetOptions.ForceSynchronousImport); | |
Console.WriteLine("build teh asset bundles"); | |
// Choose the output path according to the build target. | |
string outputPath = Path.Combine("AssetBundles", "Windows"); | |
if (!Directory.Exists(outputPath)) | |
Directory.CreateDirectory(outputPath); | |
AssetBundleBuild[] buildMap = new AssetBundleBuild[1]; | |
buildMap[0].assetBundleName = "import"; | |
string[] enemyAssets = new[] { ASSET_NAME }; | |
buildMap[0].assetNames = enemyAssets; | |
var manifest = BuildPipeline.BuildAssetBundles(outputPath, buildMap); | |
if (manifest == null) | |
{ | |
Debug.LogError("no manifest, build failed probably"); | |
} | |
AssetDatabase.DeleteAsset(ASSET_NAME); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment