Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- using UnityEngine;
- using UnityEditor;
- using UnityEngine.SceneManagement;
- using System;
- public class BundleCreatorCaller
- {
- static BundleCrator instace = new BundleCrator();
- [MenuItem("Assets/Publish map to the bundle")]
- static void Create() => instace.Execute();
- class BundleCrator
- {
- const string OutputFolder = "C:/vespiary/Lastest build/Bundles/locations20";
- public void Execute()
- {
- PrefabUtility.SaveAsPrefabAsset(rootObject, prefabPath);
- AssetImporter.GetAtPath(prefabPath).SetAssetBundleNameAndVariant(bundleName, "");
- BuildPipeline.BuildAssetBundles(OutputFolder, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
- AssetDatabase.DeleteAsset(prefabPath);
- AssetDatabase.RemoveUnusedAssetBundleNames();
- Debug.Log($"Bundle {bundleName} is done");
- }
- Scene scene => SceneManager.GetActiveScene();
- GameObject rootObject => GameObject.Find("map");
- string bundleName => sceneFolder.ToLower();
- string prefabPath => "Assets/map.prefab";
- string sceneName => scene.path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
- string sceneFolder => scene.path.Replace(sceneName,string.Empty).Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement