Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //From http://blogs.floriancavallo.fr/post/2012/07/28/Unity-Ajout-dynamique-delements-Partie-I-Asset-Bundle.aspx
- [@MenuItem("Assets/Build AssetBundles From Scene")]
- static void BuildAssetBundle()
- {
- string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);
- //make sure user has a scene selected:
- if (Selection.objects.Length != 1 || !assetPath.Contains(".unity"))
- {
- EditorUtility.DisplayDialog("Scene Asset Bundle Creation", "Please select a single scene in your project.", "OK");
- return;
- }
- //set a save location for the bundle:
- string savePath = EditorUtility.SaveFilePanel("Save Scene Asset Bundle", "", "", "unity3d");
- if (savePath == "")
- {
- return;
- }
- //save asset bundles for iphone and android:
- string[] pathPieces = savePath.Split('.');
- BuildPipeline.BuildStreamedSceneAssetBundle(new string[] { assetPath }, pathPieces[0] + "." +pathPieces[1], BuildTarget.WebPlayer);
- //complete:
- EditorApplication.Beep();
- EditorUtility.DisplayDialog("Scene Asset Bundle Creation", "Done!", "OK");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement