public static void ShowWindow() { AssetBundleWindow thisWindow = (AssetBundleWindow)EditorWindow.GetWindow(typeof(AssetBundleWindow)); thisWindow.title = "Bundle Creator"; ReadEditorPrefs(thisWindow); CreateAssetBundles.ReadBundleControlFile(Application.dataPath + thisWindow.exportLocation + CreateAssetBundles.bundleControlFileName, thisWindow.bundleVersions); CreateAssetBundles.ReadBundleContentsFile(Application.dataPath + thisWindow.exportLocation + CreateAssetBundles.bundleContentsFileName, thisWindow.bundleContents); thisWindow.ReadBundleFileSizes(); }
void OnGUI() { undoManager.CheckUndo(); GUILayout.Label("Export Settings", EditorStyles.boldLabel); assetBundleFolderLocation = EditorGUILayout.TextField("AssetBundles folder", assetBundleFolderLocation); GUILayout.Label("Application.dataPath "+ Application.dataPath, EditorStyles.label); exportLocation = EditorGUILayout.TextField("Export folder", exportLocation); bundleFileExtension = EditorGUILayout.TextField("Bundle file ext.", bundleFileExtension); setLowerCaseName = EditorGUILayout.Toggle("Names to lower case", setLowerCaseName); buildAssetBundleOptions = EditorGUILayout.BeginToggleGroup("BuildAssetBundleOptions", buildAssetBundleOptions); collectDependencies = EditorGUILayout.Toggle("CollectDependencies", collectDependencies); completeAssets = EditorGUILayout.Toggle("CompleteAssets", completeAssets); disableWriteTypeTree = EditorGUILayout.Toggle("DisableWriteTypeTree", disableWriteTypeTree); deterministicAssetBundle = EditorGUILayout.Toggle("DeterministicAssetBundle", deterministicAssetBundle); uncompressedAssetBundle = EditorGUILayout.Toggle("UncompressedAssetBundle", uncompressedAssetBundle); EditorGUILayout.EndToggleGroup(); optionalSettings = EditorGUILayout.BeginToggleGroup("Optional Settings", optionalSettings); buildTarget = (BuildTarget)EditorGUILayout.EnumPopup("Build Target", buildTarget); EditorGUILayout.EndToggleGroup(); undoManager.CheckDirty(); GUILayout.Label("Reset Settings", EditorStyles.boldLabel); if (GUILayout.Button("Reset")) { ClearPreferences(this); WriteEditorPrefs(this); CreateAssetBundles.ReadBundleControlFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleControlFileName, bundleVersions); CreateAssetBundles.ReadBundleContentsFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleContentsFileName, bundleContents); ReadBundleFileSizes(); } GUILayout.Label("Build", EditorStyles.boldLabel); if (GUILayout.Button("Build Asset Bundles")) { if (!CreateAssetBundles.ExportAssetBundleFolders(this)) { Debug.LogError("AssetBundle Build Failed! - Please check your settings in the Bundle Creator at Assets->Bundle Creator-> Asset Bundle Creator."); } else { //It worked, save the preferences and reload the control file WriteEditorPrefs(this); bundleVersions.Clear(); bundleContents.Clear(); bundleFileSizes.Clear(); CreateAssetBundles.ReadBundleControlFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleControlFileName, bundleVersions); CreateAssetBundles.ReadBundleContentsFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleContentsFileName, bundleContents); ReadBundleFileSizes(); } } GUILayout.Label("Bundle Versions", EditorStyles.boldLabel); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); foreach (KeyValuePair <string, int> bundleVersion in bundleVersions) { float bundleFileSize = 0; bundleFileSizes.TryGetValue(bundleVersion.Key, out bundleFileSize); if (GUILayout.Button(bundleVersion.Key + ", Version:" + bundleVersion.Value + ", Size: " + bundleFileSize + "kb")) { List <string> assetsInBundle = null; bundleContents.TryGetValue(bundleVersion.Key, out assetsInBundle); if (assetsInBundle != null) { CreateContentWindow(); contentWindow.SelectAssetBundle(bundleVersion.Key, assetsInBundle, Application.dataPath + exportLocation, bundleFileSize); contentWindow.ShowTab(); } } } EditorGUILayout.EndScrollView(); }