Beispiel #1
0
        static void ValidateAssetBundle(string bundleName, ref Dictionary <string, string> errors)
        {
            string path       = Utility.GetStreamingAssetsPath();
            string bundlePath = Path.Combine(path, bundleName);

            try
            {
                AssetBundle bundle = AssetBundle.LoadFromFile(bundlePath);
                if (bundle != null)
                {
                    bundle.Unload(true);
                }
            } catch (System.Exception e)
            {
                errors.Add(bundleName, e.Message);
            }
        }
Beispiel #2
0
        public static bool ValidateAssetBundles()
        {
            string path = Utility.GetStreamingAssetsPath();

            Debug.LogFormat("AssetBundle Path = {0}", path);

            Dictionary <string, string> errors = new Dictionary <string, string>();

            ValidateAssetBundle(Utility.GetPlatformName(), ref errors);

            string[] bundles = AssetDatabase.GetAllAssetBundleNames();
            float    p       = 0;

            foreach (var bundleName in bundles)
            {
                if (!Application.isBatchMode)
                {
                    EditorUtility.DisplayProgressBar("ValidateAssetBundles", bundleName, p++ *1f / bundles.Length);
                }
                ValidateAssetBundle(bundleName, ref errors);
            }

            if (!Application.isBatchMode)
            {
                EditorUtility.ClearProgressBar();
            }

            if (errors.Count > 0)
            {
                foreach (var error in errors)
                {
                    Debug.LogErrorFormat("[{0}]{1}", error.Key, error.Value);
                }
                return(false);
            }

            return(true);
        }