Last active
September 25, 2023 20:02
-
-
Save clucle/18a69d2dad3c59b53e790b61ebf88f21 to your computer and use it in GitHub Desktop.
Unity Build DLC for Mobile (Android, iOS, OSX)
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.IO; | |
public class BuildAsssetBundles : MonoBehaviour { | |
[MenuItem ("Bundles/Build AssetBundles")] | |
static void BuildAllAssetBundles () { | |
var path = "./AssetsBundle/default"; | |
if (!Directory.Exists(path)) { | |
Directory.CreateDirectory(path); | |
} | |
BuildPipeline.BuildAssetBundles (path, BuildAssetBundleOptions.None, BuildTarget.StandaloneOSXUniversal); | |
} | |
[MenuItem ("Bundles/Build iOS Bundles")] | |
static void BuildAllAssetBundlesIOS() { | |
var path = "./AssetsBundle/iOS"; | |
if (!Directory.Exists(path)) { | |
Directory.CreateDirectory(path); | |
} | |
BuildPipeline.BuildAssetBundles (path, | |
BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.iOS); | |
} | |
[MenuItem ("Bundles/Build Android Bundles")] | |
static void BuildAllAssetBundlesAndroid () | |
{ | |
var path = "./AssetsBundle/Android"; | |
if (!Directory.Exists(path)) { | |
Directory.CreateDirectory(path); | |
} | |
BuildPipeline.BuildAssetBundles (path, | |
BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android); | |
} | |
} | |
/* | |
// Bring up save panel | |
string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d"); | |
if (path.Length != 0) { | |
// Build the resource file from the active selection. | |
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); | |
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, | |
BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.iOS); | |
Selection.objects = selection; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment