Last active
December 29, 2015 07:58
-
-
Save benloong/7639598 to your computer and use it in GitHub Desktop.
generate assetbundle at specific assets folder
This file contains hidden or 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
public static ExportMenu { | |
[MenuItem("Export/Config")] | |
static public void ExportConfig() | |
{ | |
string platInfo = "PC"; | |
BuildTarget target = BuildTarget.StandaloneWindows; | |
#if UNITY_ANDROID | |
target = BuildTarget.Android; | |
platInfo = "Android"; | |
#endif | |
#if UNITY_IPHONE | |
target = BuildTarget.iPhone; | |
platInfo = "IOS"; | |
#endif | |
List<Object> assets = new List<Object>(); | |
Object selection = Selection.activeObject; | |
var configfolder = AssetDatabase.LoadAssetAtPath("Assets/Resources/config", typeof(Object)); | |
Selection.activeObject = configfolder; | |
foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets)) | |
{ | |
assets.Add(o); | |
} | |
Selection.activeObject = selection; | |
var directory = "../release/"+platInfo + "/config/"; | |
if(!Directory.Exists(directory)) { | |
Directory.CreateDirectory(directory); | |
} | |
string basePath = directory+"maincfg.u3ys"; | |
BuildPipeline.BuildAssetBundle(null, assets.ToArray(), basePath, BuildAssetBundleOptions.CollectDependencies|BuildAssetBundleOptions.CompleteAssets, target); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment