Пример #1
0
    public static bool PackingAssetBundle(BuildTarget eTarget, eBundlePackType ePackType, bool bIsDelOriginal, string strOutputPath)
    {
        strOutputPath = string.Format("{0}/{1}", strOutputPath, SHHard.GetStrToPlatform(eTarget));

        // 정보 테이블 준비
        var pTableData = CreateTableData(eTarget);

        // 패킹할 번들정보 얻기
        var dicBundles = GetPackingBundleList(pTableData, ePackType);

        // 번들 패킹 시작 및 아웃풋
        if (false == MakeAssetBundle(eTarget, strOutputPath, dicBundles))
        {
            return(false);
        }

        // 원본리소스 모두 제거
        if (true == bIsDelOriginal)
        {
            DeleteOriginalResource(pTableData);
        }

        // 번들정보파일 업데이트 및 아웃풋
        UpdateBundleInfoTable(eTarget, pTableData, dicBundles, strOutputPath);

        // 메시지 출력
        Debug.LogFormat("Success Make AssetBundles!!(Count : {0})", dicBundles.Count);

        return(true);
    }
Пример #2
0
    // 경로 : (Root : 사용자디렉토리/AppData/LocalLow/회사이름/프로덕트이름/플랫폼)
    public static string GetPathToPersistentData()
    {
#if UNITY_EDITOR
        return(string.Format("{0}/{1}", Application.persistentDataPath, SHHard.GetStrToPlatform(EditorUserBuildSettings.activeBuildTarget)));
#else
        return(string.Format("{0}/{1}", Application.persistentDataPath, SHHard.GetStrToPlatform(Single.AppInfo.GetRuntimePlatform())));
#endif
    }
Пример #3
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);
    }
Пример #4
0
 public string GetStrToRuntimePlatform()
 {
     return(SHHard.GetStrToPlatform(GetRuntimePlatform()));
 }
    // 인터페이스 : 번들정보 업데이트( Streaming기준으로 추가/변경/제거된 번들목록을 갱신한다. )
    public Dictionary <string, AssetBundleInfo> UpdateAssetBundlesMakeInfoByStreamingPath(string strCDN, BuildTarget eTarget)
    {
        // Download 경로
        var strDownloadPath = string.Format("{0}/{1}/{2}.json", strCDN, SHHard.GetStrToPlatform(eTarget), m_strFileName);

        // CDN에 있는 AssetBundleInfo.Json 다운로드
        var pCDNInfo = new JsonAssetBundleInfo();

        pCDNInfo.LoadJsonTable((new SHJson()).LoadWWW(strDownloadPath), m_strFileName);

        // 로컬 Streaming에 저장된 AssetBundleInfo 로드
        var pStreamingInfo = new JsonAssetBundleInfo();

        pStreamingInfo.LoadJsonTable((new SHJson()).LoadToStreamingForLocal(m_strFileName), m_strFileName);

        // StreamingPath기준으로 목록 갱신
        SHUtils.ForToDic(pStreamingInfo.GetContainer(), (pStreamingKey, pStreamingValue) =>
        {
            var pCDNBundleInfo = pCDNInfo.GetBundleInfo(pStreamingKey);

            // 추가 : 번들자체가 CDN에는 없고, Streaming에는 있는 경우
            if (null == pCDNBundleInfo)
            {
                pStreamingValue.m_lBundleSize = 0;
                pStreamingValue.m_pHash128    = SHHash.GetHash128("0");
                return;
            }

            // 변경 : 번들자체가 CDN과 Streaming이 다르다면 비교할 수 있게 CDN내용을 복사
            pStreamingValue.m_lBundleSize = pCDNBundleInfo.m_lBundleSize;
            pStreamingValue.m_pHash128    = pCDNBundleInfo.m_pHash128;

            // 리소스 업데이트 체크
            SHUtils.ForToDic(pStreamingValue.m_dicResources, (pResKey, pResValue) =>
            {
                var pCDNResInfo = pCDNBundleInfo.GetResourceInfo(pStreamingKey);

                // 추가 : 리소스가 CDN에는 없고, Streaming에는 있는 경우
                if (null == pCDNResInfo)
                {
                    pResValue.m_strSize = "0";
                    pResValue.m_strHash = "0";
                }
                // 변경 : 리소스가 CDN과 Streaming이 다르다면 비교할 수 있게 CDN내용을 복사
                else
                {
                    pResValue.CopyTo(pCDNResInfo);
                }
            });

            // 추가 : 리소스가 CDN에는 있고, Streaming 에는 없는 경우 비교할 수 있게 CDN내용 추가
            SHUtils.ForToDic(pCDNBundleInfo.m_dicResources, (pResKey, pResValue) =>
            {
                if (true == pStreamingValue.IsIncludeResource(pResKey))
                {
                    return;
                }

                pStreamingValue.AddResourceInfo(pResValue);
            });
        });

        return(pStreamingInfo.GetContainer());
    }
Пример #6
0
 // 경로 : (Root : Root/GetPathToAssetBundlesMakeInfo/플랫폼/)
 public static string GetPathToAssetBundlesMakeInfo(BuildTarget eTarget)
 {
     return(string.Format("{0}/{1}/{2}", GetPathToRoot(), "AssetBundlesInfo", SHHard.GetStrToPlatform(eTarget)));
 }