private static void OnPlayModeStateChanged(PlayModeStateChange state) { switch (state) { case PlayModeStateChange.ExitingEditMode: { if (GetAutoRebuildEnabled() && AssetBundlesBuilder.CheckAssetBundlesExist(true)) { AssetBundlesBuilder.Build(GetLocalBuildTargetTyped(), BuildAssetBundleOptions.StrictMode, false); } return; } case PlayModeStateChange.EnteredPlayMode: { if (GetAutoRebuildEnabled() && AssetBundlesBuilder.CheckAssetBundlesExist(false)) { Debug.Log("AssetBundles: Bundles were built before Playing"); } break; } case PlayModeStateChange.ExitingPlayMode: { if (GetCleanCacheAfterPlayEnabled()) { AssetBundle.UnloadAllAssetBundles(false); Caching.ClearCache(); Debug.Log("AssetBundles: Cache cleaned"); } break; } } }
/* * Private. */ private static void OnBuildPlayer(BuildPlayerOptions options) { // While building to a device we always use target platform build target. var buildAssetBundles = GetAutoRebuildEnabled() && AssetBundlesBuilder.CheckAssetBundlesExist(true); if (buildAssetBundles) { AssetBundlesBuilder.Build(EditorUserBuildSettings.activeBuildTarget, BuildAssetBundleOptions.StrictMode, false); } BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options); if (buildAssetBundles) { Debug.Log("AssetBundles: Bundles were built before Building project"); } }
public static void Clean() { AssetBundlesBuilder.Clean(); }
public static void Rebuild() { AssetBundlesBuilder.Build(AssetBundlesProcessor.GetLocalBuildTargetTyped(), BuildAssetBundleOptions.StrictMode | BuildAssetBundleOptions.ForceRebuildAssetBundle); }
private void OnGUI() { var changed = false; var enabled = !Application.isPlaying; if (GUI.enabled != enabled) { GUI.enabled = enabled; changed = true; } GUILayout.BeginVertical(); GUILayout.Space(Padding); GUILayout.BeginHorizontal(); GUILayout.Space(6); GUILayout.Label("Build Target:", GUILayout.Width(75)); var buildTarget = AssetBundlesProcessor.GetLocalBuildTarget(); var buildTargetNew = (AssetBundleBuildTarget)EditorGUILayout.EnumPopup(buildTarget); if (buildTargetNew != buildTarget) { AssetBundlesProcessor.SetLocalBuildTarget(buildTargetNew); } var buildTargetTyped = AssetBundlesProcessor.GetLocalBuildTargetTyped(); if (GUILayout.Button("Build", GUILayout.Width(60), GUILayout.Height(18))) { AssetBundlesBuilder.Build(buildTargetTyped, BuildAssetBundleOptions.StrictMode); } if (GUILayout.Button("Rebuild", GUILayout.Width(60), GUILayout.Height(18))) { AssetBundlesBuilder.Build(buildTargetTyped, BuildAssetBundleOptions.StrictMode | BuildAssetBundleOptions.ForceRebuildAssetBundle); } GUILayout.Space(6); GUILayout.EndHorizontal(); GUILayout.Space(3); GUILayout.BeginHorizontal(); GUILayout.Space(Padding); GUILayout.Space(76); var autoRebuildEnabled = AssetBundlesProcessor.GetAutoRebuildEnabled(); var autoRebuildEnabledNew = GUILayout.Toggle(autoRebuildEnabled, "Auto rebuild"); if (autoRebuildEnabled != autoRebuildEnabledNew) { AssetBundlesProcessor.SetAutoRebuildEnabled(autoRebuildEnabledNew); } GUILayout.Space(10); var cleanCacheOnPlayEnabled = AssetBundlesProcessor.GetCleanCacheAfterPlayEnabled(); var cleanCacheOnPlayEnabledNew = GUILayout.Toggle(cleanCacheOnPlayEnabled, "Clean Cache after Play"); if (cleanCacheOnPlayEnabled != cleanCacheOnPlayEnabledNew) { AssetBundlesProcessor.SetCleanCacheAfterPlayEnabled(cleanCacheOnPlayEnabledNew); } GUILayout.FlexibleSpace(); GUILayout.Space(Padding); GUILayout.EndHorizontal(); GUILayout.Space(Padding); GUILayout.EndVertical(); if (changed) { GUI.enabled = !enabled; } }