Cannot mark assets and scenes in one AssetBundle

Unity3D/Problems 2016. 9. 20. 12:07
반응형

static void CollectDownloadableAssets(string path, bool isTest = false)

{

        Debug.LogFormat("CollectDownloadableAssets[{0}]:{1}", isTest, path);


        int testVer = PlayerPrefs.GetInt(VERSION_TEST_KEY);


string[] directoryList = System.IO.Directory.GetDirectories(path);


        List<string> scenfolderPath = AssetBundleSettings.Instance.GetSceneFloderPath();


        foreach (string directory in directoryList)

{

            Debug.LogFormat("directory:{0}", directory);


            string dirPath = directory.Replace("\\", "/");


            AssetBundleData data = new AssetBundleData(Path.GetFileNameWithoutExtension(directory));


            SearchOption searchOption = scenfolderPath.Contains(dirPath) ? SearchOption.TopDirectoryOnly : SearchOption.AllDirectories;


            string[] filePaths = Directory.GetFiles(directory, "*.*", searchOption).Where(s => !s.EndsWith(".meta")).ToArray();



            int version = isTest ? testVer : 0;


List<Object> files = new List<Object>();


            string filePath;


            foreach (string p in filePaths)

{

                filePath = p.Replace("\\", "/");


                if(p.Contains(Application.dataPath))

                {

   filePath = "Assets" + p.Replace(Application.dataPath, "");

                }


                // check version file..

                if (Path.GetFileName(filePath) == VERSION_FILE_NAME)

                {

                    if (!isTest)

                    {

                        Object verObj = AssetDatabase.LoadAssetAtPath(filePath, typeof(Assets.Scripts.Editor.AssetBundleVersion));

                        version = (verObj as Assets.Scripts.Editor.AssetBundleVersion).version;

                    }


                    continue;

                }

                else if (Path.GetExtension(filePath) == ".asset")

                {

                    continue;

                }


                Object obj = AssetDatabase.LoadAssetAtPath(filePath, typeof(Object));

if(obj)

{

data.prefabs.Add(obj, filePath);

}


                Debug.Log(filePath);

}


data.version = version;

assetDatas.Add(data);

}

}

반응형
: