Example #1
0
        bool CreateAssetBunldesALL(Object[] SelectedAsset, string targetPath, BuildTarget BT)
        {
            foreach (Object o in SelectedAsset)
            {
                if (ABTools.MissingMono(o))
                {
                    return(false);
                }
            }

            if (SelectedAsset == null || SelectedAsset.Length == 0)
            {
                //EditorUtility.DisplayDialog("AssetBunlde", "Nothing is Selected", "Close");
                Debuger.LogError("Nothing is Selected or targetPath is invalid");

                return(false);
            }

            if (File.Exists(targetPath))
            {
                //if (EditorUtility.DisplayDialog("AssetBunlde", "Target is Exist, Is Delete?", "Delete", "No Delete"))
                {
                    File.Delete(targetPath);

                    AssetDatabase.Refresh();
                }
            }

            if (BuildPipeline.BuildAssetBundle(null,
                                               SelectedAsset,
                                               targetPath,
                                               BuildAssetBundleOptions.CollectDependencies,
                                               BT))
            {
                AssetDatabase.Refresh();

                return(true);
            }
            else
            {
                AssetDatabase.Refresh();

                return(false);
            }
        }
Example #2
0
        public void ExecCreateAssetBunldes()
        {
            //取得在 Project 视图中选择的资源(包含子目录中的资源)
            Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
            if (SelectedAsset == null)
            {
                EditorUtility.DisplayDialog("AssetBunlde", "Nothing is Selected", "Close");

                return;
            }

            foreach (Object obj in SelectedAsset)
            {
                if (ABTools.MissingMono(obj))
                {
                    continue;
                }

#if UNITY_IPHONE
                string targetPath = ABConfig.OutputFolderIPhone + obj.name + ABConfig.extensionName;
#elif UNITY_STANDALONE_WIN
                string targetPath = ABConfig.OutputFolderWindows32 + obj.name + ABConfig.extensionName;
#elif UNITY_ANDROID
                string targetPath = ABConfig.OutputFolderAndroid + obj.name + ABConfig.extensionName;
#else
                string targetPath = ABConfig.OutputFolderWindows32 + obj.name + ABConfig.extensionName;
#endif  //	UNITY_STANDALONE_WIN

                if (File.Exists(targetPath))
                {
                    File.Delete(targetPath);
                }

#if UNITY_IPHONE
                //建立 AssetBundle
                if (BuildPipeline.BuildAssetBundle(obj,
                                                   null,
                                                   targetPath,
                                                   BuildAssetBundleOptions.CollectDependencies,                                                     // | BuildAssetBundleOptions.CompleteAssets,
                                                   BuildTarget.iPhone))
                {
                    Debuger.Log(targetPath + "建立完成");
                }
                else
                {
                    Debuger.LogError(obj.name + "建立失败");
                }
#elif UNITY_STANDALONE_WIN
                //建立 AssetBundle
                if (BuildPipeline.BuildAssetBundle(obj,
                                                   null,
                                                   targetPath,
                                                   BuildAssetBundleOptions.CollectDependencies,                                                     // | BuildAssetBundleOptions.CompleteAssets,
                                                   BuildTarget.StandaloneWindows))
                {
                    Debuger.Log(targetPath + "建立完成");
                }
                else
                {
                    Debuger.LogError(obj.name + "建立失败");
                }
#elif UNITY_ANDROID
                //建立 AssetBundle
                if (BuildPipeline.BuildAssetBundle(obj,
                                                   null,
                                                   targetPath,
                                                   BuildAssetBundleOptions.CollectDependencies, // | BuildAssetBundleOptions.CompleteAssets,
                                                   BuildTarget.Android))
                {
                    Debuger.Log(targetPath + "建立完成");
                }
                else
                {
                    Debuger.LogError(obj.name + "建立失败");
                }
#endif  //	UNITY_STANDALONE_WIN
                AssetDatabase.Refresh();
            }

            EditorUtility.DisplayDialog("AssetBunlde", "BuildTarget.StandaloneWindows Over", "Close");
        }