├── .gitignore ├── Assets ├── AssetBundleManager.meta ├── AssetBundleManager │ ├── Editor.meta │ ├── Editor │ │ ├── AssetBundleBuildSetting.asset │ │ ├── AssetBundleBuildSetting.asset.meta │ │ ├── BundleBuildPostprocessor.cs │ │ ├── BundleBuildPostprocessor.cs.meta │ │ ├── BundleBuilder.cs │ │ ├── BundleBuilder.cs.meta │ │ ├── BundleBuilderEditor.cs │ │ ├── BundleBuilderEditor.cs.meta │ │ ├── BundleBuilderMenuItems.cs │ │ ├── BundleBuilderMenuItems.cs.meta │ │ ├── CleanCache.cs │ │ ├── CleanCache.cs.meta │ │ ├── Commandline.cs │ │ ├── Commandline.cs.meta │ │ ├── SerializableDictionary.cs │ │ └── SerializableDictionary.cs.meta │ ├── Utility.cs │ └── Utility.cs.meta ├── Samples.meta └── Samples │ ├── ExternalProcessor.meta │ └── ExternalProcessor │ ├── Scripts.meta │ └── Scripts │ ├── Editor.meta │ └── Editor │ ├── BundleBuildSetting.asset │ ├── BundleBuildSetting.asset.meta │ ├── ExternalProcessor.asset │ ├── ExternalProcessor.asset.meta │ ├── ExternalProcessor.cs │ ├── ExternalProcessor.cs.meta │ ├── PrePostProcessorMenuItem.cs │ └── PrePostProcessorMenuItem.cs.meta ├── Images └── setting.png ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Autogenerated VS/MD solution and project files 9 | ExportedObj/ 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.tmp 15 | *.user 16 | *.userprefs 17 | *.pidb 18 | *.booproj 19 | *.svd 20 | 21 | 22 | # Unity3D generated meta files 23 | *.pidb.meta 24 | 25 | # Unity3D Generated File On Crash Reports 26 | sysinfo.txt 27 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d198e99773bd8c4abd9bb4a364bb89a 3 | folderAsset: yes 4 | timeCreated: 1457071530 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d0ad296b0f9b124696bf753d96b9e42 3 | folderAsset: yes 4 | timeCreated: 1457071536 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/AssetBundleBuildSetting.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/Assets/AssetBundleManager/Editor/AssetBundleBuildSetting.asset -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/AssetBundleBuildSetting.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3270519ba07c594db50535ac8d7d20f 3 | timeCreated: 1457150519 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/BundleBuildPostprocessor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace AssetBundles 5 | { 6 | /// 7 | /// A postprocessor to call a callback when the AssetBundle an asset is associated with changes. 8 | /// 9 | public class BundleBuildPostprocessor : AssetPostprocessor 10 | { 11 | void OnPostprocessAssetbundleNameChanged(string path, string previous, string next) 12 | { 13 | Debug.Log("AssetBundles: " + path + " old: " + previous + " new: " + next); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/BundleBuildPostprocessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a28aace7264d5b46988c023d3fd8134 3 | timeCreated: 1457074388 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/BundleBuilder.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// 3 | /// BundleBuilder.cs 4 | /// 5 | /// (c)2016 Kim, Hyoun Woo 6 | /// 7 | /////////////////////////////////////////////////////////////////////////////// 8 | using UnityEngine; 9 | using UnityEditor; 10 | using System; 11 | using System.IO; 12 | using System.Collections; 13 | using System.Collections.Generic; 14 | 15 | namespace AssetBundles 16 | { 17 | /// 18 | /// ScriptableObject class which provides assetbundle build options. 19 | /// 20 | /// Note: 21 | /// BuildAssetBundleOptions 22 | /// * CollectDependencies and DeterministicAssetBundle are always enabled. 23 | /// * CompleteAssets is ingored as we always start from assets rather than objects, it should be complete by default. 24 | /// * ForceRebuildAssetBundle is added. Even there is no change to the assets, you can force rebuild the AssetBundles by setting this flag. 25 | /// * IngoreTypeTreeChanges is added. Even type tree changes, you can ignore the type tree changes with this flag. 26 | /// * DisableWriteTypeTree conflicts with IngoreTypeTreeChanges. You can’t ignore type tree changes if you disable type tree. 27 | /// 28 | /// See the following for more details: 29 | /// http://docs.unity3d.com/500/Documentation/Manual/BuildingAssetBundles5x.html 30 | /// 31 | /// 32 | public class BundleBuilder : ScriptableObject 33 | { 34 | public ScriptableObject external; 35 | 36 | // Build target platform for the assetbunldes which are built. 37 | public BuildTarget buildTarget = BuildTarget.StandaloneWindows64; 38 | 39 | // used seirializable dictionary to serialize assetbundle options. 40 | [Serializable] 41 | public class OptionDictionary : SerializableDictionary { } 42 | [HideInInspector] 43 | public OptionDictionary EnabledOptions; 44 | 45 | 46 | 47 | // A place where to put the assetbundles. 48 | [HideInInspector] 49 | public string outputPath = string.Empty; 50 | 51 | // Set the delegate if there is anything to do before building assetbundles. 52 | public delegate void OnPreBuildProcessorHandler(BundleBuilder builder); 53 | public static OnPreBuildProcessorHandler OnPreBuildProcessor; 54 | 55 | // Set the delegate if there is anything to do after building assetbundles. 56 | public delegate void OnPostBuildProcessorHandler(BundleBuilder builder); 57 | public static OnPostBuildProcessorHandler OnPostBuildProcessor; 58 | 59 | void OnEnable() 60 | { 61 | if (EnabledOptions == null) 62 | EnabledOptions = new OptionDictionary(); 63 | 64 | foreach (string name in Enum.GetNames(typeof(BuildAssetBundleOptions))) 65 | { 66 | // the first enum value is 'None' so we skip it. 67 | if (string.IsNullOrEmpty(name) || name == "None") 68 | continue; 69 | 70 | BuildAssetBundleOptions key = (BuildAssetBundleOptions)Enum.Parse(typeof(BuildAssetBundleOptions), name); 71 | if (!EnabledOptions.ContainsKey(key)) 72 | { 73 | bool val = false; 74 | #if UNITY_5 75 | // Skip some options which are not neccessary on Unity 5.x 76 | // CollectDependencies and DeterministicAssetBundle are always enabled in the new AssetBundle build system introduced in 5.0. 77 | // CompleteAssets is ingored as we always start from assets rather than objects, it should be complete by default. 78 | if (key != BuildAssetBundleOptions.None && 79 | (key == BuildAssetBundleOptions.UncompressedAssetBundle || 80 | key == BuildAssetBundleOptions.DisableWriteTypeTree || 81 | key == BuildAssetBundleOptions.ForceRebuildAssetBundle || 82 | key == BuildAssetBundleOptions.IgnoreTypeTreeChanges || 83 | key == BuildAssetBundleOptions.AppendHashToAssetBundleName 84 | #if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2) // from Unity 5.3x, it supports ChunkBasedCompression 85 | || key == BuildAssetBundleOptions.ChunkBasedCompression)) 86 | #endif 87 | { 88 | EnabledOptions.Add(key, val); 89 | } 90 | #else 91 | EnabledOptions.Add(key, val); 92 | #endif 93 | } 94 | } 95 | } 96 | 97 | /// 98 | /// Retrievs current path of this project. 99 | /// Unity editor expects the current folder to be set to the project folder at all times. 100 | /// 101 | /// 102 | public static string GetProjectPath() 103 | { 104 | string projectPath = System.IO.Directory.GetCurrentDirectory(); 105 | projectPath = projectPath.Replace('\\', '/'); 106 | 107 | return projectPath; 108 | } 109 | 110 | static public string CreateAssetBundleDirectory(string rootFolder) 111 | { 112 | if (string.IsNullOrEmpty(rootFolder)) 113 | rootFolder = Utility.AssetBundlesOutputPath; 114 | 115 | // Choose the output path according to the build target. 116 | string path = Path.Combine(rootFolder, Utility.GetPlatformName()); 117 | if (!Directory.Exists(path)) 118 | Directory.CreateDirectory(path); 119 | 120 | return path; 121 | } 122 | 123 | /// 124 | /// BundleBuilder.outputPath stores relative path so it should be converted 125 | /// to the absolute path before building bundles. 126 | /// 127 | /// 128 | private string GetAbsoluteOutputPath(string outputPath) 129 | { 130 | string projPath = GetProjectPath(); 131 | string subFolder = outputPath; 132 | 133 | // remove '/' if the string start with that trailing char 134 | // otherwise Path.Combine return only the second string. 135 | if (subFolder.StartsWith("/") || subFolder.StartsWith("\\")) 136 | subFolder = subFolder.Substring(1); 137 | string absolutePath = Path.Combine(projPath, subFolder); 138 | 139 | absolutePath = absolutePath.Replace('\\', '/'); 140 | return absolutePath; 141 | } 142 | 143 | /// 144 | /// Export AssetsBundles under the specified output path. 145 | /// 146 | public void Build() 147 | { 148 | // preprocessing. 149 | if (OnPreBuildProcessor != null) 150 | OnPreBuildProcessor(this); 151 | 152 | // Choose the output path according to the build target. 153 | string absolutePath = GetAbsoluteOutputPath(outputPath); 154 | string platformOutputPath = CreateAssetBundleDirectory(absolutePath); 155 | 156 | // Specifies assetbundle build options. 157 | var options = BuildAssetBundleOptions.None; 158 | foreach (KeyValuePair enabled in EnabledOptions) 159 | { 160 | if (enabled.Key == BuildAssetBundleOptions.None) 161 | continue; 162 | 163 | if (enabled.Value) 164 | options |= enabled.Key; 165 | } 166 | 167 | //TODO: later, may be... 168 | /* 169 | bool shouldCheckODR = EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS; 170 | #if UNITY_TVOS 171 | shouldCheckODR |= EditorUserBuildSettings.activeBuildTarget == BuildTarget.tvOS; 172 | #endif 173 | if (shouldCheckODR) 174 | { 175 | #if ENABLE_IOS_ON_DEMAND_RESOURCES 176 | if (PlayerSettings.iOS.useOnDemandResources) 177 | options |= BuildAssetBundleOptions.UncompressedAssetBundle; 178 | #endif 179 | #if ENABLE_IOS_APP_SLICING 180 | options |= BuildAssetBundleOptions.UncompressedAssetBundle; 181 | #endif 182 | } 183 | */ 184 | 185 | // Build assetbundles. 186 | BuildPipeline.BuildAssetBundles(platformOutputPath, options, this.buildTarget); 187 | 188 | // postprocessing. 189 | if (OnPostBuildProcessor != null) 190 | OnPostBuildProcessor(this); 191 | } 192 | 193 | public static void CreateBuildSetting() 194 | { 195 | BundleBuilder instance = ScriptableObject.CreateInstance(); 196 | AssetDatabase.CreateAsset(instance, "Assets/AssetBundleManager/Editor/AssetBundleBuildSetting.asset"); 197 | AssetDatabase.SaveAssets(); 198 | } 199 | } 200 | 201 | } -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/BundleBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68f5446531c267a43b32981a47429b58 3 | timeCreated: 1457071577 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/BundleBuilderEditor.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// 3 | /// BundleBuilder.cs 4 | /// 5 | /// (c)2016 Kim, Hyoun Woo 6 | /// 7 | /////////////////////////////////////////////////////////////////////////////// 8 | using UnityEngine; 9 | using UnityEditor; 10 | using System; 11 | using System.Collections; 12 | using System.Collections.Generic; 13 | using System.IO; 14 | 15 | namespace AssetBundles 16 | { 17 | /// 18 | /// Custom inspector editor class to provide assetbundle build options. 19 | /// 20 | [CustomEditor(typeof(BundleBuilder))] 21 | public class BundleBuilderEditor : Editor 22 | { 23 | BundleBuilder builder; 24 | 25 | void OnEnable() 26 | { 27 | builder = target as BundleBuilder; 28 | } 29 | 30 | public override void OnInspectorGUI() 31 | { 32 | // Add header 33 | GUIStyle headerStyle = new GUIStyle(GUI.skin.label); 34 | headerStyle.fontSize = 14; 35 | headerStyle.normal.textColor = Color.white; 36 | headerStyle.fontStyle = FontStyle.Bold; 37 | EditorGUILayout.LabelField("AssetBundle Setting Tool", headerStyle, GUILayout.Height(20)); 38 | EditorGUILayout.Space(); 39 | 40 | // Set external scritableobject for preprcessing and postprocessing if it is necessary. 41 | builder.external = EditorGUILayout.ObjectField("External:", builder.external, typeof(ScriptableObject), true) as ScriptableObject; 42 | EditorGUILayout.Space(); 43 | 44 | // Set assetbundle build target. 45 | SetBuildTarget(); 46 | EditorGUILayout.Space(); 47 | 48 | // AssetBundle Options 49 | SetBundleOptions(); 50 | EditorGUILayout.Space(); 51 | 52 | // Output path setting 53 | EditorGUILayout.LabelField("Output Path:", EditorStyles.boldLabel); 54 | 55 | using (new EditorGUILayout.HorizontalScope()) 56 | { 57 | string path = string.Empty; 58 | if (string.IsNullOrEmpty(builder.outputPath)) 59 | path = BundleBuilder.GetProjectPath(); 60 | else 61 | path = builder.outputPath; 62 | 63 | builder.outputPath = GUILayout.TextField(builder.outputPath, GUILayout.MinWidth(250)); 64 | if (GUILayout.Button("...", GUILayout.Width(20))) 65 | { 66 | string projectFolder = Path.Combine(BundleBuilder.GetProjectPath(), builder.outputPath); 67 | path = EditorUtility.OpenFolderPanel("Select folder", projectFolder, ""); 68 | if (path.Length != 0) 69 | { 70 | builder.outputPath = path.Replace(BundleBuilder.GetProjectPath(), ""); 71 | } 72 | } 73 | } 74 | EditorGUILayout.Space(); 75 | 76 | // Build 77 | EditorGUILayout.LabelField("AssetBundle Build:", EditorStyles.boldLabel); 78 | if (GUILayout.Button("Build")) 79 | { 80 | //HACK: To prevent InvalidOperationException. 81 | // See http://answers.unity3d.com/questions/852155/invalidoperationexception-operation-is-not-valid-d-1.html 82 | EditorApplication.delayCall += builder.Build; 83 | } 84 | 85 | if (GUI.changed) 86 | { 87 | EditorUtility.SetDirty(builder); 88 | AssetDatabase.SaveAssets(); 89 | } 90 | } 91 | 92 | /// 93 | /// HACK: 94 | /// Not likely as the previous version, Unity 5.3.x seems to be able to build 95 | /// assetbundle without switching target platform in the build setting. 96 | /// (Not sure it also worked with Unity 5.2.x) 97 | /// So, it is more convenient to provide build target options in this setting tool. 98 | /// 99 | private void SetBuildTarget() 100 | { 101 | EditorGUILayout.LabelField("AssetBundle Build Target:", EditorStyles.boldLabel); 102 | 103 | builder.buildTarget = (BuildTarget)EditorGUILayout.EnumPopup(builder.buildTarget); 104 | } 105 | 106 | /// 107 | /// Provides GUI options to specify various bundle options. 108 | /// 109 | private void SetBundleOptions() 110 | { 111 | EditorGUILayout.LabelField("AssetBundle Options:", EditorStyles.boldLabel); 112 | string[] names = Enum.GetNames(typeof(BuildAssetBundleOptions)); 113 | for (int i = 0; i < names.Length; i++) 114 | { 115 | if (string.IsNullOrEmpty(names[i]) || names[i] == "None") 116 | continue; 117 | 118 | BuildAssetBundleOptions key = (BuildAssetBundleOptions)Enum.Parse(typeof(BuildAssetBundleOptions), names[i]); 119 | if (builder.EnabledOptions.ContainsKey(key)) 120 | { 121 | // provides toggle with tooltip. 122 | GUIContent toggleContent = new GUIContent(" " + names[i], GetTooltip(key)); 123 | builder.EnabledOptions[key] = EditorGUILayout.ToggleLeft(toggleContent, builder.EnabledOptions[key]); 124 | } 125 | } 126 | 127 | #if !(UNITY_4 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2) // for the version of Unity over 5.3x 128 | bool uncompressedAssetBundle; 129 | if (builder.EnabledOptions.TryGetValue(BuildAssetBundleOptions.UncompressedAssetBundle, out uncompressedAssetBundle)) 130 | { 131 | if (uncompressedAssetBundle) 132 | { 133 | bool chunkBasedCompression; 134 | if (builder.EnabledOptions.TryGetValue(BuildAssetBundleOptions.ChunkBasedCompression, out chunkBasedCompression)) 135 | { 136 | if (chunkBasedCompression) 137 | { 138 | if (EditorUtility.DisplayDialog("NOTE", 139 | "Force disable 'UncompressedAssetBundle' option due to the 'ChunkBasedCompression' option is enabled.", "Ok")) 140 | { 141 | builder.EnabledOptions[BuildAssetBundleOptions.UncompressedAssetBundle] = false; 142 | } 143 | } 144 | } 145 | } 146 | } 147 | #endif 148 | 149 | #if UNITY_5 150 | // DisableWriteTypeTree conflicts with IngoreTypeTreeChanges. So you can’t enable both of the options. 151 | bool disableWriteTypeTree; 152 | if (builder.EnabledOptions.TryGetValue(BuildAssetBundleOptions.DisableWriteTypeTree, out disableWriteTypeTree)) 153 | { 154 | if (disableWriteTypeTree) 155 | { 156 | bool ignoreTypeTreeChanges; 157 | if (builder.EnabledOptions.TryGetValue(BuildAssetBundleOptions.IgnoreTypeTreeChanges, out ignoreTypeTreeChanges)) 158 | { 159 | if (ignoreTypeTreeChanges) 160 | { 161 | //builder.EnabledOptions[BuildAssetBundleOptions.IgnoreTypeTreeChanges] = false; 162 | if (EditorUtility.DisplayDialog("NOTE", 163 | "You can’t ignore type tree changes if you disable type tree.", "Ok")) 164 | { 165 | builder.EnabledOptions[BuildAssetBundleOptions.IgnoreTypeTreeChanges] = false; 166 | } 167 | } 168 | } 169 | } 170 | } 171 | #endif 172 | using (new EditorGUILayout.HorizontalScope()) 173 | { 174 | GUILayout.FlexibleSpace(); 175 | if (GUILayout.Button("Use Default Setting", GUILayout.Width(150))) 176 | { 177 | UseDefaultSetting(); 178 | } 179 | } 180 | } 181 | 182 | /// 183 | /// Returns correspond tooltip string with BuildAssetBundleOptions. 184 | /// 185 | private string GetTooltip(BuildAssetBundleOptions option) 186 | { 187 | if (option == BuildAssetBundleOptions.UncompressedAssetBundle) 188 | return "Don't compress the data when creating the asset bundle."; 189 | if (option == BuildAssetBundleOptions.DisableWriteTypeTree) 190 | return "Do not include type information within the AssetBundle."; 191 | if (option == BuildAssetBundleOptions.DeterministicAssetBundle) 192 | return "Builds an asset bundle using a hash for the id of the object stored in the asset bundle."; 193 | if (option == BuildAssetBundleOptions.ForceRebuildAssetBundle) 194 | return "Force rebuild the assetBundles."; 195 | if (option == BuildAssetBundleOptions.IgnoreTypeTreeChanges) 196 | return "Ignore the type tree changes when doing the incremental build check."; 197 | if (option == BuildAssetBundleOptions.AppendHashToAssetBundleName) 198 | return "Append the hash to the assetBundle name."; 199 | #if !(UNITY_4 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2) // for the version of Unity over 5.3x 200 | if (option == BuildAssetBundleOptions.ChunkBasedCompression) 201 | return "Use chunk-based LZ4 compression when creating the AssetBundle."; 202 | #endif 203 | 204 | return string.Empty; 205 | } 206 | 207 | /// 208 | /// Disable all options. Same as BuildAssetBundleOptions.None 209 | /// 210 | private void UseDefaultSetting() 211 | { 212 | foreach(BuildAssetBundleOptions key in builder.EnabledOptions.Keys) 213 | { 214 | builder.EnabledOptions[key] = false; 215 | } 216 | } 217 | } 218 | } -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/BundleBuilderEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9979c70cb3d587344a2d639c90ed8785 3 | timeCreated: 1457071577 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/BundleBuilderMenuItems.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// 3 | /// BundleBuilderMenuItems.cs 4 | /// 5 | /// (c)2016 Kim, Hyoun Woo 6 | /// 7 | /////////////////////////////////////////////////////////////////////////////// 8 | using UnityEngine; 9 | using UnityEditor; 10 | using System.Collections; 11 | 12 | namespace AssetBundles 13 | { 14 | public class BundleBuilderMenuItems 15 | { 16 | [MenuItem("Tools/AssetBundles/Create Build Setting")] 17 | static public void CreateBuildSetting() 18 | { 19 | BundleBuilder.CreateBuildSetting(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/BundleBuilderMenuItems.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 492e096c79468db48bd11602055836e7 3 | timeCreated: 1457071607 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/CleanCache.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | 5 | /// 6 | /// An editor script which deletes cache info. 7 | /// 8 | /// NOTE: 9 | /// Delete all AssetBundle content that has been cached by the current application. 10 | /// This function is not available to WebPlayer applications that use the shared cache. 11 | /// 12 | /// See Also: 13 | /// http://docs.unity3d.com/Documentation/ScriptReference/Caching.CleanCache.html 14 | /// 15 | /// 16 | public class CacheTools : ScriptableObject 17 | { 18 | 19 | [MenuItem("Tools/Cache/Clean")] 20 | public static void CleanCache() 21 | { 22 | if (Caching.CleanCache()) 23 | { 24 | Debug.LogWarning("Successfully cleaned all caches."); 25 | } 26 | else 27 | { 28 | Debug.LogWarning("Cache was in use."); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/CleanCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a028d56594715e4a9672e9225367e04 3 | timeCreated: 1457071577 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/Commandline.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | 5 | /// 6 | /// A helper class which enables to build assetbundles via command-line options. 7 | /// 8 | public class Commandline 9 | { 10 | /// 11 | /// Call with command-line options to build assetbundles. 12 | /// 13 | public static void BuildAssetbundles() 14 | { 15 | string settingPath = "Assets/AssetBundleManager/Editor/AssetBundleBuildSetting.asset"; 16 | AssetBundles.BundleBuilder builder = (AssetBundles.BundleBuilder)AssetDatabase.LoadAssetAtPath(settingPath, typeof(AssetBundles.BundleBuilder)); 17 | if (builder != null) 18 | { 19 | builder.Build(); 20 | } 21 | else 22 | { 23 | EditorUtility.DisplayDialog("AssetBundle Build Error", "Failed to load builder", "ok"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/Commandline.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb4f49a8de5b0144bb55a4099ffd5950 3 | timeCreated: 1469183869 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/SerializableDictionary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using UnityEngine; 7 | 8 | /// 9 | /// Since 4.6 we got the ISerializationCallbackReceiver which allows us to use custom serialization to serialize types that Unity cannot. 10 | /// 11 | /// See: 12 | /// http://forum.unity3d.com/threads/finally-a-serializable-dictionary-for-unity-extracted-from-system-collections-generic.335797/ 13 | /// 14 | /// 15 | /// 16 | [Serializable, DebuggerDisplay("Count = {Count}")] 17 | public class SerializableDictionary : IDictionary 18 | { 19 | [SerializeField, HideInInspector] 20 | int[] _Buckets; 21 | [SerializeField, HideInInspector] 22 | int[] _HashCodes; 23 | [SerializeField, HideInInspector] 24 | int[] _Next; 25 | [SerializeField, HideInInspector] 26 | int _Count; 27 | [SerializeField, HideInInspector] 28 | int _Version; 29 | [SerializeField, HideInInspector] 30 | int _FreeList; 31 | [SerializeField, HideInInspector] 32 | int _FreeCount; 33 | [SerializeField, HideInInspector] 34 | TKey[] _Keys; 35 | [SerializeField, HideInInspector] 36 | TValue[] _Values; 37 | 38 | readonly IEqualityComparer _Comparer; 39 | 40 | // Mainly for debugging purposes - to get the key-value pairs display 41 | public Dictionary AsDictionary 42 | { 43 | get { return new Dictionary(this); } 44 | } 45 | 46 | public int Count 47 | { 48 | get { return _Count - _FreeCount; } 49 | } 50 | 51 | public TValue this[TKey key, TValue defaultValue] 52 | { 53 | get 54 | { 55 | int index = FindIndex(key); 56 | if (index >= 0) 57 | return _Values[index]; 58 | return defaultValue; 59 | } 60 | } 61 | 62 | public TValue this[TKey key] 63 | { 64 | get 65 | { 66 | int index = FindIndex(key); 67 | if (index >= 0) 68 | return _Values[index]; 69 | throw new KeyNotFoundException(key.ToString()); 70 | } 71 | 72 | set { Insert(key, value, false); } 73 | } 74 | 75 | public SerializableDictionary() 76 | : this(0, null) 77 | { 78 | } 79 | 80 | public SerializableDictionary(int capacity) 81 | : this(capacity, null) 82 | { 83 | } 84 | 85 | public SerializableDictionary(IEqualityComparer comparer) 86 | : this(0, comparer) 87 | { 88 | } 89 | 90 | public SerializableDictionary(int capacity, IEqualityComparer comparer) 91 | { 92 | if (capacity < 0) 93 | throw new ArgumentOutOfRangeException("capacity"); 94 | 95 | Initialize(capacity); 96 | 97 | _Comparer = (comparer ?? EqualityComparer.Default); 98 | } 99 | 100 | public SerializableDictionary(IDictionary dictionary) 101 | : this(dictionary, null) 102 | { 103 | } 104 | 105 | public SerializableDictionary(IDictionary dictionary, IEqualityComparer comparer) 106 | : this((dictionary != null) ? dictionary.Count : 0, comparer) 107 | { 108 | if (dictionary == null) 109 | throw new ArgumentNullException("dictionary"); 110 | 111 | foreach (KeyValuePair current in dictionary) 112 | Add(current.Key, current.Value); 113 | } 114 | 115 | public bool ContainsValue(TValue value) 116 | { 117 | if (value == null) 118 | { 119 | for (int i = 0; i < _Count; i++) 120 | { 121 | if (_HashCodes[i] >= 0 && _Values[i] == null) 122 | return true; 123 | } 124 | } 125 | else 126 | { 127 | var defaultComparer = EqualityComparer.Default; 128 | for (int i = 0; i < _Count; i++) 129 | { 130 | if (_HashCodes[i] >= 0 && defaultComparer.Equals(_Values[i], value)) 131 | return true; 132 | } 133 | } 134 | return false; 135 | } 136 | 137 | public bool ContainsKey(TKey key) 138 | { 139 | return FindIndex(key) >= 0; 140 | } 141 | 142 | public void Clear() 143 | { 144 | if (_Count <= 0) 145 | return; 146 | 147 | for (int i = 0; i < _Buckets.Length; i++) 148 | _Buckets[i] = -1; 149 | 150 | Array.Clear(_Keys, 0, _Count); 151 | Array.Clear(_Values, 0, _Count); 152 | Array.Clear(_HashCodes, 0, _Count); 153 | Array.Clear(_Next, 0, _Count); 154 | 155 | _FreeList = -1; 156 | _Count = 0; 157 | _FreeCount = 0; 158 | _Version++; 159 | } 160 | 161 | public void Add(TKey key, TValue value) 162 | { 163 | Insert(key, value, true); 164 | } 165 | 166 | private void Resize(int newSize, bool forceNewHashCodes) 167 | { 168 | int[] bucketsCopy = new int[newSize]; 169 | for (int i = 0; i < bucketsCopy.Length; i++) 170 | bucketsCopy[i] = -1; 171 | 172 | var keysCopy = new TKey[newSize]; 173 | var valuesCopy = new TValue[newSize]; 174 | var hashCodesCopy = new int[newSize]; 175 | var nextCopy = new int[newSize]; 176 | 177 | Array.Copy(_Values, 0, valuesCopy, 0, _Count); 178 | Array.Copy(_Keys, 0, keysCopy, 0, _Count); 179 | Array.Copy(_HashCodes, 0, hashCodesCopy, 0, _Count); 180 | Array.Copy(_Next, 0, nextCopy, 0, _Count); 181 | 182 | if (forceNewHashCodes) 183 | { 184 | for (int i = 0; i < _Count; i++) 185 | { 186 | if (hashCodesCopy[i] != -1) 187 | hashCodesCopy[i] = (_Comparer.GetHashCode(keysCopy[i]) & 2147483647); 188 | } 189 | } 190 | 191 | for (int i = 0; i < _Count; i++) 192 | { 193 | int index = hashCodesCopy[i] % newSize; 194 | nextCopy[i] = bucketsCopy[index]; 195 | bucketsCopy[index] = i; 196 | } 197 | 198 | _Buckets = bucketsCopy; 199 | _Keys = keysCopy; 200 | _Values = valuesCopy; 201 | _HashCodes = hashCodesCopy; 202 | _Next = nextCopy; 203 | } 204 | 205 | private void Resize() 206 | { 207 | Resize(PrimeHelper.ExpandPrime(_Count), false); 208 | } 209 | 210 | public bool Remove(TKey key) 211 | { 212 | if (key == null) 213 | throw new ArgumentNullException("key"); 214 | 215 | int hash = _Comparer.GetHashCode(key) & 2147483647; 216 | int index = hash % _Buckets.Length; 217 | int num = -1; 218 | for (int i = _Buckets[index]; i >= 0; i = _Next[i]) 219 | { 220 | if (_HashCodes[i] == hash && _Comparer.Equals(_Keys[i], key)) 221 | { 222 | if (num < 0) 223 | _Buckets[index] = _Next[i]; 224 | else 225 | _Next[num] = _Next[i]; 226 | 227 | _HashCodes[i] = -1; 228 | _Next[i] = _FreeList; 229 | _Keys[i] = default(TKey); 230 | _Values[i] = default(TValue); 231 | _FreeList = i; 232 | _FreeCount++; 233 | _Version++; 234 | return true; 235 | } 236 | num = i; 237 | } 238 | return false; 239 | } 240 | 241 | private void Insert(TKey key, TValue value, bool add) 242 | { 243 | if (key == null) 244 | throw new ArgumentNullException("key"); 245 | 246 | if (_Buckets == null) 247 | Initialize(0); 248 | 249 | int hash = _Comparer.GetHashCode(key) & 2147483647; 250 | int index = hash % _Buckets.Length; 251 | int num1 = 0; 252 | for (int i = _Buckets[index]; i >= 0; i = _Next[i]) 253 | { 254 | if (_HashCodes[i] == hash && _Comparer.Equals(_Keys[i], key)) 255 | { 256 | if (add) 257 | throw new ArgumentException("Key already exists: " + key); 258 | 259 | _Values[i] = value; 260 | _Version++; 261 | return; 262 | } 263 | num1++; 264 | } 265 | int num2; 266 | if (_FreeCount > 0) 267 | { 268 | num2 = _FreeList; 269 | _FreeList = _Next[num2]; 270 | _FreeCount--; 271 | } 272 | else 273 | { 274 | if (_Count == _Keys.Length) 275 | { 276 | Resize(); 277 | index = hash % _Buckets.Length; 278 | } 279 | num2 = _Count; 280 | _Count++; 281 | } 282 | _HashCodes[num2] = hash; 283 | _Next[num2] = _Buckets[index]; 284 | _Keys[num2] = key; 285 | _Values[num2] = value; 286 | _Buckets[index] = num2; 287 | _Version++; 288 | 289 | //if (num3 > 100 && HashHelpers.IsWellKnownEqualityComparer(comparer)) 290 | //{ 291 | // comparer = (IEqualityComparer)HashHelpers.GetRandomizedEqualityComparer(comparer); 292 | // Resize(entries.Length, true); 293 | //} 294 | } 295 | 296 | private void Initialize(int capacity) 297 | { 298 | int prime = PrimeHelper.GetPrime(capacity); 299 | 300 | _Buckets = new int[prime]; 301 | for (int i = 0; i < _Buckets.Length; i++) 302 | _Buckets[i] = -1; 303 | 304 | _Keys = new TKey[prime]; 305 | _Values = new TValue[prime]; 306 | _HashCodes = new int[prime]; 307 | _Next = new int[prime]; 308 | 309 | _FreeList = -1; 310 | } 311 | 312 | private int FindIndex(TKey key) 313 | { 314 | if (key == null) 315 | throw new ArgumentNullException("key"); 316 | 317 | if (_Buckets != null) 318 | { 319 | int hash = _Comparer.GetHashCode(key) & 2147483647; 320 | for (int i = _Buckets[hash % _Buckets.Length]; i >= 0; i = _Next[i]) 321 | { 322 | if (_HashCodes[i] == hash && _Comparer.Equals(_Keys[i], key)) 323 | return i; 324 | } 325 | } 326 | return -1; 327 | } 328 | 329 | public bool TryGetValue(TKey key, out TValue value) 330 | { 331 | int index = FindIndex(key); 332 | if (index >= 0) 333 | { 334 | value = _Values[index]; 335 | return true; 336 | } 337 | value = default(TValue); 338 | return false; 339 | } 340 | 341 | private static class PrimeHelper 342 | { 343 | public static readonly int[] Primes = new int[] 344 | { 345 | 3, 346 | 7, 347 | 11, 348 | 17, 349 | 23, 350 | 29, 351 | 37, 352 | 47, 353 | 59, 354 | 71, 355 | 89, 356 | 107, 357 | 131, 358 | 163, 359 | 197, 360 | 239, 361 | 293, 362 | 353, 363 | 431, 364 | 521, 365 | 631, 366 | 761, 367 | 919, 368 | 1103, 369 | 1327, 370 | 1597, 371 | 1931, 372 | 2333, 373 | 2801, 374 | 3371, 375 | 4049, 376 | 4861, 377 | 5839, 378 | 7013, 379 | 8419, 380 | 10103, 381 | 12143, 382 | 14591, 383 | 17519, 384 | 21023, 385 | 25229, 386 | 30293, 387 | 36353, 388 | 43627, 389 | 52361, 390 | 62851, 391 | 75431, 392 | 90523, 393 | 108631, 394 | 130363, 395 | 156437, 396 | 187751, 397 | 225307, 398 | 270371, 399 | 324449, 400 | 389357, 401 | 467237, 402 | 560689, 403 | 672827, 404 | 807403, 405 | 968897, 406 | 1162687, 407 | 1395263, 408 | 1674319, 409 | 2009191, 410 | 2411033, 411 | 2893249, 412 | 3471899, 413 | 4166287, 414 | 4999559, 415 | 5999471, 416 | 7199369 417 | }; 418 | 419 | public static bool IsPrime(int candidate) 420 | { 421 | if ((candidate & 1) != 0) 422 | { 423 | int num = (int)Math.Sqrt((double)candidate); 424 | for (int i = 3; i <= num; i += 2) 425 | { 426 | if (candidate % i == 0) 427 | { 428 | return false; 429 | } 430 | } 431 | return true; 432 | } 433 | return candidate == 2; 434 | } 435 | 436 | public static int GetPrime(int min) 437 | { 438 | if (min < 0) 439 | throw new ArgumentException("min < 0"); 440 | 441 | for (int i = 0; i < PrimeHelper.Primes.Length; i++) 442 | { 443 | int prime = PrimeHelper.Primes[i]; 444 | if (prime >= min) 445 | return prime; 446 | } 447 | for (int i = min | 1; i < 2147483647; i += 2) 448 | { 449 | if (PrimeHelper.IsPrime(i) && (i - 1) % 101 != 0) 450 | return i; 451 | } 452 | return min; 453 | } 454 | 455 | public static int ExpandPrime(int oldSize) 456 | { 457 | int num = 2 * oldSize; 458 | if (num > 2146435069 && 2146435069 > oldSize) 459 | { 460 | return 2146435069; 461 | } 462 | return PrimeHelper.GetPrime(num); 463 | } 464 | } 465 | 466 | public ICollection Keys 467 | { 468 | get { return _Keys.Take(Count).ToArray(); } 469 | } 470 | 471 | public ICollection Values 472 | { 473 | get { return _Values.Take(Count).ToArray(); } 474 | } 475 | 476 | public void Add(KeyValuePair item) 477 | { 478 | Add(item.Key, item.Value); 479 | } 480 | 481 | public bool Contains(KeyValuePair item) 482 | { 483 | int index = FindIndex(item.Key); 484 | return index >= 0 && 485 | EqualityComparer.Default.Equals(_Values[index], item.Value); 486 | } 487 | 488 | public void CopyTo(KeyValuePair[] array, int index) 489 | { 490 | if (array == null) 491 | throw new ArgumentNullException("array"); 492 | 493 | if (index < 0 || index > array.Length) 494 | throw new ArgumentOutOfRangeException(string.Format("index = {0} array.Length = {1}", index, array.Length)); 495 | 496 | if (array.Length - index < Count) 497 | throw new ArgumentException(string.Format("The number of elements in the dictionary ({0}) is greater than the available space from index to the end of the destination array {1}.", Count, array.Length)); 498 | 499 | for (int i = 0; i < _Count; i++) 500 | { 501 | if (_HashCodes[i] >= 0) 502 | array[index++] = new KeyValuePair(_Keys[i], _Values[i]); 503 | } 504 | } 505 | 506 | public bool IsReadOnly 507 | { 508 | get { return false; } 509 | } 510 | 511 | public bool Remove(KeyValuePair item) 512 | { 513 | return Remove(item.Key); 514 | } 515 | 516 | public Enumerator GetEnumerator() 517 | { 518 | return new Enumerator(this); 519 | } 520 | 521 | IEnumerator IEnumerable.GetEnumerator() 522 | { 523 | return GetEnumerator(); 524 | } 525 | 526 | IEnumerator> IEnumerable>.GetEnumerator() 527 | { 528 | return GetEnumerator(); 529 | } 530 | 531 | public struct Enumerator : IEnumerator> 532 | { 533 | private readonly SerializableDictionary _Dictionary; 534 | private int _Version; 535 | private int _Index; 536 | private KeyValuePair _Current; 537 | 538 | public KeyValuePair Current 539 | { 540 | get { return _Current; } 541 | } 542 | 543 | internal Enumerator(SerializableDictionary dictionary) 544 | { 545 | _Dictionary = dictionary; 546 | _Version = dictionary._Version; 547 | _Current = default(KeyValuePair); 548 | _Index = 0; 549 | } 550 | 551 | public bool MoveNext() 552 | { 553 | if (_Version != _Dictionary._Version) 554 | throw new InvalidOperationException(string.Format("Enumerator version {0} != Dictionary version {1}", _Version, _Dictionary._Version)); 555 | 556 | while (_Index < _Dictionary._Count) 557 | { 558 | if (_Dictionary._HashCodes[_Index] >= 0) 559 | { 560 | _Current = new KeyValuePair(_Dictionary._Keys[_Index], _Dictionary._Values[_Index]); 561 | _Index++; 562 | return true; 563 | } 564 | _Index++; 565 | } 566 | 567 | _Index = _Dictionary._Count + 1; 568 | _Current = default(KeyValuePair); 569 | return false; 570 | } 571 | 572 | void IEnumerator.Reset() 573 | { 574 | if (_Version != _Dictionary._Version) 575 | throw new InvalidOperationException(string.Format("Enumerator version {0} != Dictionary version {1}", _Version, _Dictionary._Version)); 576 | 577 | _Index = 0; 578 | _Current = default(KeyValuePair); 579 | } 580 | 581 | object IEnumerator.Current 582 | { 583 | get { return Current; } 584 | } 585 | 586 | public void Dispose() 587 | { 588 | } 589 | } 590 | } -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Editor/SerializableDictionary.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc3d19ee34cd24c41948fc0d2b7fcfce 3 | timeCreated: 1457071577 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Utility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | #if UNITY_EDITOR 3 | using UnityEditor; 4 | #endif 5 | 6 | namespace AssetBundles 7 | { 8 | public class Utility 9 | { 10 | public const string AssetBundlesOutputPath = "AssetBundles"; 11 | 12 | public static string GetPlatformName() 13 | { 14 | #if UNITY_EDITOR 15 | return GetPlatformForAssetBundles(EditorUserBuildSettings.activeBuildTarget); 16 | #else 17 | return GetPlatformForAssetBundles(Application.platform); 18 | #endif 19 | } 20 | 21 | #if UNITY_EDITOR 22 | private static string GetPlatformForAssetBundles(BuildTarget target) 23 | { 24 | switch (target) 25 | { 26 | case BuildTarget.Android: 27 | return "Android"; 28 | #if UNITY_TVOS 29 | case BuildTarget.tvOS: 30 | return "tvOS"; 31 | #endif 32 | case BuildTarget.iOS: 33 | return "iOS"; 34 | case BuildTarget.WebGL: 35 | return "WebGL"; 36 | case BuildTarget.WebPlayer: 37 | return "WebPlayer"; 38 | case BuildTarget.StandaloneWindows: 39 | case BuildTarget.StandaloneWindows64: 40 | return "Windows"; 41 | case BuildTarget.StandaloneOSXIntel: 42 | case BuildTarget.StandaloneOSXIntel64: 43 | case BuildTarget.StandaloneOSXUniversal: 44 | return "OSX"; 45 | // Add more build targets for your own. 46 | // If you add more targets, don't forget to add the same platforms to GetPlatformForAssetBundles(RuntimePlatform) function. 47 | default: 48 | return null; 49 | } 50 | } 51 | 52 | #endif 53 | 54 | private static string GetPlatformForAssetBundles(RuntimePlatform platform) 55 | { 56 | switch (platform) 57 | { 58 | case RuntimePlatform.Android: 59 | return "Android"; 60 | case RuntimePlatform.IPhonePlayer: 61 | return "iOS"; 62 | #if UNITY_TVOS 63 | case RuntimePlatform.tvOS: 64 | return "tvOS"; 65 | #endif 66 | case RuntimePlatform.WebGLPlayer: 67 | return "WebGL"; 68 | case RuntimePlatform.OSXWebPlayer: 69 | case RuntimePlatform.WindowsWebPlayer: 70 | return "WebPlayer"; 71 | case RuntimePlatform.WindowsPlayer: 72 | return "Windows"; 73 | case RuntimePlatform.OSXPlayer: 74 | return "OSX"; 75 | // Add more build targets for your own. 76 | // If you add more targets, don't forget to add the same platforms to GetPlatformForAssetBundles(RuntimePlatform) function. 77 | default: 78 | return null; 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Assets/AssetBundleManager/Utility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94837352c30fdf5418876581301f4f9f 3 | timeCreated: 1457071627 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Samples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c84bfe53ecd27054dbded293b449b232 3 | folderAsset: yes 4 | timeCreated: 1457235384 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c689b230813abd94d84c5e9bbcf14058 3 | folderAsset: yes 4 | timeCreated: 1457235447 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57abdef9b1d4d17499061b47904d09cc 3 | folderAsset: yes 4 | timeCreated: 1457235393 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e60c16ff8f976bf4a87de13bc3b76e38 3 | folderAsset: yes 4 | timeCreated: 1457235549 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor/BundleBuildSetting.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/Assets/Samples/ExternalProcessor/Scripts/Editor/BundleBuildSetting.asset -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor/BundleBuildSetting.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c893ce0275539304eb126f74db996755 3 | timeCreated: 1457236559 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor/ExternalProcessor.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/Assets/Samples/ExternalProcessor/Scripts/Editor/ExternalProcessor.asset -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor/ExternalProcessor.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 914597a78fc62b0488d8833aa7d56aa9 3 | timeCreated: 1457235884 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor/ExternalProcessor.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// 3 | /// ExternalProcessor.cs 4 | /// 5 | /// (c)2016 Kim, Hyoun Woo 6 | /// 7 | /////////////////////////////////////////////////////////////////////////////// 8 | using UnityEngine; 9 | using AssetBundles; 10 | 11 | /// 12 | /// Drop this into the object field on the BundleSetting.asset file. 13 | /// 14 | /// 15 | public class ExternalProcessor : ScriptableObject 16 | { 17 | /// 18 | /// Whenever the BundleBuilder scriptableobject file is selected within editor, 19 | /// ExternalProcossor is also instantiated if it is already dropped onto the BundleBuilder asset file. 20 | /// 21 | void OnEnable() 22 | { 23 | // Specifies preprocessor and postprocessor for the delegates of the BundleBuilder. 24 | BundleBuilder.OnPreBuildProcessor = OnPreprocessor; 25 | BundleBuilder.OnPostBuildProcessor = OnPostprocessor; 26 | } 27 | 28 | public void OnPreprocessor(BundleBuilder builder) 29 | { 30 | // Do something before building assetbundlers here. 31 | // e.g. Do mark assets which are built as assetbundle etc. 32 | Debug.Log("OnPreprocessor."); 33 | } 34 | 35 | public void OnPostprocessor(BundleBuilder builder) 36 | { 37 | // Do something after building assetbundlers here. 38 | // e.g. Copy assetbundles under the StreamingAssets folder etc. 39 | Debug.Log("OnPostprocessor."); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor/ExternalProcessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da467553d5e440d4e801d3012e7cc8b0 3 | timeCreated: 1457235618 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor/PrePostProcessorMenuItem.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// 3 | /// ExternalProcessorMenuItem.cs 4 | /// 5 | /// (c)2016 Kim, Hyoun Woo 6 | /// 7 | /////////////////////////////////////////////////////////////////////////////// 8 | using UnityEngine; 9 | using UnityEditor; 10 | 11 | public class ExternalProcessorMenuItem 12 | { 13 | /// 14 | /// Create ExternalProcessor.asset file. 15 | /// 16 | [MenuItem("Tools/AssetBundles/Create ExternalProcessor")] 17 | static public void CreateBuildSetting() 18 | { 19 | ExternalProcessor instance = ScriptableObject.CreateInstance(); 20 | AssetDatabase.CreateAsset(instance, "Assets/Samples/ExternalProcessor/Scripts/Editor/ExternalProcessor.asset"); 21 | AssetDatabase.SaveAssets(); 22 | } 23 | } -------------------------------------------------------------------------------- /Assets/Samples/ExternalProcessor/Scripts/Editor/PrePostProcessorMenuItem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c739706a79af6548945341fc7a5e0b5 3 | timeCreated: 1457235536 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Images/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/Images/setting.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Kim, Hyoun Woo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.3.3f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kimsama/Unity5-AssetBundleSetting/0a6657d02bc6121fcc56926549c5b6edef793f17/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AssetBundleSetting Tool for Unity 5.x 2 | ================================ 3 | 4 | A tool which provides a simple editor setting to build assetbundles especially on Unity5.x. 5 | 6 | 7 | ![ setting](./Images/setting.png "setting") 8 | 9 | 10 | It provides a simple editor tool to set various assetbundle options regardless of Unity's minor version so it works on any version of Unity5.x. and makes it easy to build assetbundles. 11 | If the version of Unity is 5.3.x, it provides *[ChunkBasedCompression](http://docs.unity3d.com/ScriptReference/BuildAssetBundleOptions.ChunkBasedCompression.html)* option which is newly added on Unity 5.3.x. 12 | 13 | 14 | Usage 15 | ----- 16 | 17 | * Select 'Tools/AssetBundles/Create Build Setting' menu item. 18 | * Select the created *'AssetBundleBuildSetting.asset'* setting file which is found under the *'Assets/AssetBundleManager/Editor'* directory. 19 | * Set assetbundle options. 20 | * Set output directory where the created bundles are placed. 21 | * Build it! 22 | 23 | Use *'OnPreBuildProcessor'* and *'OnPostBuildProcessor'* delegates if you have something to do befor or after 24 | building assetbundles. See *'ExternalProcessor'* sample under the *'Samples'* folder for more details. 25 | 26 | ```csharp 27 | // Set the delegate if there is anything to do before building assetbundles. 28 | public delegate void OnPreBuildProcessorHandler(BundleBuilder builder); 29 | public static OnPreBuildProcessorHandler OnPreBuildProcessor; 30 | 31 | // Set the delegate if there is anything to do after building assetbundles. 32 | public delegate void OnPostBuildProcessorHandler(BundleBuilder builder); 33 | public static OnPostBuildProcessorHandler OnPostBuildProcessor; 34 | ``` 35 | 36 | You can also build assetbundle via commandline options with the following .bat file on windows: 37 | 38 | 39 | ``` 40 | @echo off 41 | SET UNITY_BIN="C:\Program Files (x86)\Unity\Editor\Unity.exe" 42 | SET PROJECT_PATH="PATH_YOUR_UNITY_PROJECT_WITHOUT_ASSETS_FOLDER" 43 | %UNITY_BIN% -quit -batchmode -nographics -projectPath %PROJECT_PATH% -logFile bundlebuild_log.txt -executeMethod Commandline.BuildAssetbundles 44 | 45 | ``` 46 | 47 | See the [Command line arguments page](http://docs.unity3d.com/420/Documentation/Manual/CommandLineArguments.html) for more details. 48 | 49 | 50 | Known Issues 51 | ------------ 52 | * Highly recommended to use on Unity 5.x. (may work on Unity 4.x but not recommended) 53 | * It does not contain any script to load assetbundles, See [an asset bundle demo for Unity5 on bitbucket site](https://bitbucket.org/Unity-Technologies/assetbundledemo) or other stuff for that. 54 | * Duplicate a setting asset file if you need multiple settings for each of target platform. 55 | 56 | 57 | Additional Notes 58 | ---------------- 59 | 60 | It is also available to mark an asset as an assetbunle by setting its name with *[AssetImporter.assetBundleName](http://docs.unity3d.com/ScriptReference/AssetImporter-assetBundleName.html)*. 61 | Consider it to use spreadsheet or xml file for those configuration to do it as batching job instead of doing tedious thing like mouse click on every assets which are needed to be assetbundles. 62 | 63 | The following codesnip shows to do that: 64 | 65 | ```csharp 66 | [MenuItem("Tools/AssetBundles/Set AssetBundles from Spreadsheet", false, 0)] 67 | static void SetAssetBundlesFromSpreadsheet() 68 | { 69 | // Assume that each cells of the worksheet has path of an asset and a name of assetbundle 70 | foreach (string path in sheet.cells) 71 | { 72 | ... 73 | // Retrieve assetimporter for the given path 74 | AssetImporter assetImporter = AssetImporter.GetAtPath(path); 75 | 76 | // Specify bundle name for the asset. 77 | assetImporter.assetBundleName = asset.name; 78 | 79 | // Save the changes. 80 | assetImporter.SaveAndReimport(); 81 | ... 82 | } 83 | } 84 | 85 | ``` 86 | 87 | See [Unity-QuickSheet](https://github.com/kimsama/Unity-QuickSheet) to get spreadsheet work with Unity. 88 | 89 | 90 | References 91 | ---------- 92 | * [Official Unity3D document page for AssetBundle5x](http://docs.unity3d.com/500/Documentation/Manual/BuildingAssetBundles5x.html) 93 | * [Official Unity3D tutorial page for Assetbundles and the Assetbundle Manager](https://unity3d.com/kr/learn/tutorials/topics/scripting/assetbundles-and-assetbundle-manager) 94 | * [An asset bundle demo for Unity5 on bitbucket site](https://bitbucket.org/Unity-Technologies/assetbundledemo) 95 | * [A comprehensive document on the changes of assetbundle on Unity 5.3.x at the blog page of テラシュールブログ](http://tsubakit1.hateblo.jp/entry/2015/12/16/233336) 96 | * [Official Unity3D document page for Asset Bundle Compression](http://docs.unity3d.com/Manual/AssetBundleCompression.html) 97 | * [LZ4 compression related - AssetBundleのパフォーマンスを計測したかった~Unity5.3.1編~](http://veniegames.com/?p=262) 98 | * [LZ4 compression related - Unity5.3のAssetBundleパフォーマンス計測](https://www.google.co.kr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=6&cad=rja&uact=8&ved=0ahUKEwjllNOiwqbLAhVBpJQKHQN7DHUQFghJMAU&url=http%3A%2F%2Fqiita.com%2Fvui%2Fitems%2Fe25dacb22c085606e15f&usg=AFQjCNGYACO0hGvksrgCrjs_eecA6Aa5wA&sig2=-8DI6h-Rs8itXw85xmEVkQ&bvm=bv.115339255,d.dGo) 99 | * [Improved Unity asset bundle file compression on Rich Geldreich's Tech Blog](http://richg42.blogspot.kr/2015/01/improved-unity-asset-bundle-file.html) 100 | 101 | 102 | Other Stuffs 103 | ------------ 104 | 105 | * [AssetGraph](https://github.com/unity3d-jp/AssetGraph) - A visual toolset lets you configure and create Unity's AssetBundles. A toolset which uses different approach on handling AssetBundles. 106 | * [BundleVersionChecker](https://github.com/kayy/BundleVersionChecker) - Smart workaround to get Unity's bundle version information from PlayerSettings.bundleVersion in your source code by automatic code generation from a Unity editor class. 107 | 108 | License 109 | ------- 110 | 111 | This code is distributed under the terms and conditions of the MIT license. 112 | 113 | * *'SerializableDictionary'* code is borrowed from @vexe at [here](http://forum.unity3d.com/threads/finally-a-serializable-dictionary-for-unity-extracted-from-system-collections-generic.335797/). 114 | * *'Utility.cs' code is borrowed from [an asset bundle demo](https://bitbucket.org/Unity-Technologies/assetbundledemo). 115 | 116 | The license of the that follow those. 117 | 118 | Copyright (c) 2016 Kim, Hyoun Woo 119 | --------------------------------------------------------------------------------