-
-
Save kirillrybin/6027671 to your computer and use it in GitHub Desktop.
Unity3D
Скрипт для экспорта Asset Bundles под разные платформы (Windows, OSX, iOS, Android)
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
// C# Example | |
// Builds an asset bundle from the selected objects in the project view. | |
// Once compiled go to "Menu" -> "Assets" and select one of the choices | |
// to build the Asset Bundle | |
using UnityEngine; | |
public class ExportAssetBundles | |
{ | |
[UnityEditor.MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")] | |
static void ExportResource () | |
{ | |
// Bring up save panel | |
string path = UnityEditor.EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); | |
if (path.Length != 0) { | |
// Build the resource file from the active selection. | |
Object[] selection = UnityEditor.Selection.GetFiltered (typeof(Object), UnityEditor.SelectionMode.DeepAssets); | |
UnityEditor.BuildPipeline.BuildAssetBundle (UnityEditor.Selection.activeObject, selection, path, UnityEditor.BuildAssetBundleOptions.CollectDependencies | UnityEditor.BuildAssetBundleOptions.CompleteAssets); | |
UnityEditor.Selection.objects = selection; | |
} | |
} | |
[UnityEditor.MenuItem("Assets/Build AssetBundle From Selection - Track dependencies iPhone")] | |
static void ExportAssetBundleIOSComplete () | |
{ | |
// Bring up save panel | |
string path = UnityEditor.EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); | |
if (path.Length != 0) { | |
// Build the resource file from the active selection. | |
Object[] selection = UnityEditor.Selection.GetFiltered (typeof(Object), UnityEditor.SelectionMode.DeepAssets); | |
// | |
UnityEditor.BuildPipeline.BuildAssetBundle (UnityEditor.Selection.activeObject, selection, path, UnityEditor.BuildAssetBundleOptions.CollectDependencies | UnityEditor.BuildAssetBundleOptions.CompleteAssets, UnityEditor.BuildTarget.iPhone); | |
UnityEditor.Selection.objects = selection; | |
} | |
} | |
[UnityEditor.MenuItem("Assets/Build AssetBundle From Selection - Track dependencies Android")] | |
static void ExportAssetBundleAndroidComplete () | |
{ | |
// Bring up save panel | |
string path = UnityEditor.EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); | |
if (path.Length != 0) { | |
// Build the resource file from the active selection. | |
Object[] selection = UnityEditor.Selection.GetFiltered (typeof(Object), UnityEditor.SelectionMode.DeepAssets); | |
// | |
UnityEditor.BuildPipeline.BuildAssetBundle (UnityEditor.Selection.activeObject, selection, path, UnityEditor.BuildAssetBundleOptions.CollectDependencies | UnityEditor.BuildAssetBundleOptions.CompleteAssets, UnityEditor.BuildTarget.Android); | |
UnityEditor.Selection.objects = selection; | |
} | |
} | |
[UnityEditor.MenuItem("Assets/Build AssetBundle From Selection - No dependency tracking")] | |
static void ExportResourceNoTrack () | |
{ | |
// Bring up save panel | |
string path = UnityEditor.EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); | |
if (path.Length != 0) { | |
// Build the resource file from the active selection. | |
UnityEditor.BuildPipeline.BuildAssetBundle (UnityEditor.Selection.activeObject, UnityEditor.Selection.objects, path); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment