Exemplo n.º 1
0
    // 유틸 : 번들 패킹 시작 및 아웃풋
    static bool MakeAssetBundle(BuildTarget eTarget, string strOutputPath, Dictionary <string, AssetBundleInfo> dicBundles)
    {
        // 디렉토리 정리
        SHUtils.DeleteDirectory(strOutputPath);
        SHUtils.CreateDirectory(strOutputPath);

        // 번들 빌드 정보 만들기
        List <AssetBundleBuild> pBuildList = new List <AssetBundleBuild>();

        SHUtils.ForToDic(dicBundles, (pKey, pValue) =>
        {
            List <string> pAssets = new List <string>();
            SHUtils.ForToDic(pValue.m_dicResources, (pResKey, pResValue) =>
            {
                pAssets.Add(string.Format("{0}/{1}{2}", "Assets/Resources", pResValue.m_strPath, pResValue.m_strExtension));
            });

            AssetBundleBuild pAssetInfo = new AssetBundleBuild();
            pAssetInfo.assetBundleName  = string.Format("{0}.unity3d", pValue.m_strBundleName);
            pAssetInfo.assetNames       = pAssets.ToArray();
            pBuildList.Add(pAssetInfo);
        });

        // 빌드할 번들이 없으면 종료
        if (0 == pBuildList.Count)
        {
            return(true);
        }

        // 번들 빌드하기
        AssetBundleManifest pManifest = BuildPipeline.BuildAssetBundles(strOutputPath, pBuildList.ToArray(), BuildAssetBundleOptions.DeterministicAssetBundle, eTarget);

        if (null == pManifest)
        {
            Debug.LogErrorFormat("Error!!! Make Assets Bundle : {0}", strOutputPath);
            return(false);
        }

        // 후 처리
        SHUtils.ForToList(pBuildList, (pBundle) =>
        {
            // 번들 크기와 해시코드 기록
            string strKey = pBundle.assetBundleName.Substring(0, pBundle.assetBundleName.Length - ".unity3d".Length).ToLower();
            if (true == dicBundles.ContainsKey(strKey))
            {
                dicBundles[strKey].m_pHash128    = pManifest.GetAssetBundleHash(pBundle.assetBundleName);
                dicBundles[strKey].m_lBundleSize = (new FileInfo(string.Format("{0}/{1}", strOutputPath, pBundle.assetBundleName))).Length;
            }

            // Manifest제거 ( 사용하지 않는 불필요한 파일이라 그냥 제거시킴 )
            SHUtils.DeleteFile(string.Format("{0}/{1}.manifest", strOutputPath, pBundle.assetBundleName));
        });
        SHUtils.DeleteFile(string.Format("{0}/{1}", strOutputPath, SHHard.GetStrToPlatform(eTarget)));
        SHUtils.DeleteFile(string.Format("{0}/{1}.manifest", strOutputPath, SHHard.GetStrToPlatform(eTarget)));

        return(true);
    }
Exemplo n.º 2
0
 static void SelectToDeletePersistentData()
 {
     SHUtils.DeleteDirectory(Application.persistentDataPath);
     EditorUtility.DisplayDialog("알림", "PersistentData가 삭제되었습니다.", "확인");
 }