Exemplo n.º 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);
    }
Exemplo n.º 2
0
    public override bool?LoadJsonTable(JSONNode pJson, string strFileName)
    {
        if (null == pJson)
        {
            return(false);
        }

        int iMaxTable = pJson["ResourcesList"].Count;

        for (int iLoop = 0; iLoop < iMaxTable; ++iLoop)
        {
            JSONNode             pDataNode = pJson["ResourcesList"][iLoop];
            SHResourcesTableInfo pData     = new SHResourcesTableInfo();
            pData.m_strName      = GetStrToJson(pDataNode, "s_Name");
            pData.m_strFileName  = GetStrToJson(pDataNode, "s_FileName");
            pData.m_strExtension = GetStrToJson(pDataNode, "s_Extension");
            pData.m_strSize      = GetStrToJson(pDataNode, "s_Size");
            //pData.m_strLastWriteTime    = GetStrToJson(pDataNode, "s_LastWriteTime");
            pData.m_strHash       = GetStrToJson(pDataNode, "s_Hash");
            pData.m_strPath       = GetStrToJson(pDataNode, "s_Path");
            pData.m_eResourceType = SHHard.GetResourceTypeToExtension(pData.m_strExtension);

            AddResources(pData.m_strName, pData);
        }

        return(true);
    }
Exemplo n.º 3
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
    }
Exemplo n.º 4
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.º 5
0
    SHUIWidget_Stick CreateStickSlot(eStickType eType)
    {
        if ((eStickType.None == eType) || (eStickType.Max == eType))
        {
            return(null);
        }

        return(Single.ObjectPool.Get <SHUIWidget_Stick>(SHHard.GetStickName(eType),
                                                        ePoolReturnType.ChangeScene, ePoolDestroyType.ChangeScene));
    }
Exemplo n.º 6
0
    // 유틸 : 언어설정
    eLanguage GetLanguage()
    {
        m_eLanguage = (eLanguage)SHPlayerPrefs.GetInt("ApplicationInfo_Language", 0);
        if (eLanguage.None == m_eLanguage)
        {
            SetLanguage(SHHard.GetSystemLanguage());
        }

        return(m_eLanguage);
    }
Exemplo n.º 7
0
    SHUIWidget_Monster CreateMonsterSlot(eMonsterType eType)
    {
        if ((eMonsterType.None == eType) || (eMonsterType.Max_NormalMonster == eType) || (eMonsterType.Max == eType))
        {
            return(null);
        }

        return(Single.ObjectPool.Get <SHUIWidget_Monster>(SHHard.GetMonsterName(eType),
                                                          ePoolReturnType.ChangeScene, ePoolDestroyType.ChangeScene));
    }
Exemplo n.º 8
0
    public eServiceMode GetClientServiceMode()
    {
        var pTable = GetTable <JsonClientConfiguration>();

        if (null == pTable)
        {
            return(eServiceMode.None);
        }

        return(SHHard.GetEnumToServiceMode(pTable.GetServiceMode()));
    }
Exemplo n.º 9
0
    private SHUIWidget_Monster CreateMonster(eMonsterType eType, float fFactor, float fStartPosY)
    {
        var pMonster = Single.ObjectPool.Get <SHUIWidget_Monster>(SHHard.GetMonsterName(eType));

        if (null == pMonster)
        {
            return(null);
        }

        SHGameObject.SetParent(pMonster.transform, Single.UI.GetRootToScene());
        Single.ObjectPool.SetStartTransform(pMonster.gameObject);
        pMonster.SetActive(true);
        pMonster.Initialize(eType, fFactor, Single.Balance.GetMonsterSpeed(), fStartPosY);
        return(pMonster);
    }
Exemplo n.º 10
0
    private SHUIWidget_Stick CreateStick()
    {
        m_pStick = Single.ObjectPool.Get <SHUIWidget_Stick>(
            SHHard.GetStickName(GetStickType()));
        if (null == m_pStick)
        {
            return(null);
        }

        SHGameObject.SetParent(m_pStick.transform, Single.UI.GetRootToScene());
        Single.ObjectPool.SetStartTransform(m_pStick.gameObject);
        m_pStick.SetActive(true);
        m_pStick.Initialize(GetStickType());

        return(m_pStick);
    }
Exemplo n.º 11
0
    public override bool?LoadJsonTable(JSONNode pJson, string strFileName)
    {
        if (null == pJson)
        {
            return(false);
        }

        int iMaxTable = pJson["AssetBundleInfo"].Count;

        for (int iLoop = 0; iLoop < iMaxTable; ++iLoop)
        {
            JSONNode        pDataNode = pJson["AssetBundleInfo"][iLoop];
            AssetBundleInfo pData     = new AssetBundleInfo();
            pData.m_strBundleName = GetStrToJson(pDataNode, "s_BundleName");
            pData.m_lBundleSize   = (long)GetIntToJson(pDataNode, "s_BundleSize");
            pData.m_pHash128      = SHHash.GetHash128(GetStrToJson(pDataNode, "s_BundleHash"));

            int iMaxUnit = pDataNode["p_Resources"].Count;
            for (int iLoopUnit = 0; iLoopUnit < iMaxUnit; ++iLoopUnit)
            {
                JSONNode             pUnitNode = pDataNode["p_Resources"][iLoopUnit];
                SHResourcesTableInfo pUnit     = new SHResourcesTableInfo();
                pUnit.m_strName      = GetStrToJson(pUnitNode, "s_Name");
                pUnit.m_strFileName  = GetStrToJson(pUnitNode, "s_FileName");
                pUnit.m_strExtension = GetStrToJson(pUnitNode, "s_Extension");
                pUnit.m_strSize      = GetStrToJson(pUnitNode, "s_Size");
                //pUnit.m_strLastWriteTime    = GetStrToJson(pUnitNode, "s_LastWriteTime");
                pUnit.m_strHash       = GetStrToJson(pUnitNode, "s_Hash");
                pUnit.m_strPath       = GetStrToJson(pUnitNode, "s_Path");
                pUnit.m_eResourceType = SHHard.GetResourceTypeToExtension(pUnit.m_strExtension);

                pData.AddResourceInfo(pUnit);
            }

            AddData(pData.m_strBundleName, pData);
        }

        return(true);
    }
Exemplo n.º 12
0
 public string GetStrToRuntimePlatform()
 {
     return(SHHard.GetStrToPlatform(GetRuntimePlatform()));
 }
Exemplo n.º 13
0
 // 인터페이스 : 현재 씬 얻기
 public eSceneType GetActiveScene()
 {
     return(SHHard.GetSceneTypeToString(SceneManager.GetActiveScene().name));
 }
Exemplo n.º 14
0
    // 인터페이스 : 번들정보 업데이트( 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());
    }
 public string GetBundleCDN(string strMode, string strVersion)
 {
     return(GetBundleCDN(SHHard.GetEnumToServiceMode(strMode), strVersion));
 }
Exemplo n.º 16
0
 // 경로 : (Root : Root/GetPathToAssetBundlesMakeInfo/플랫폼/)
 public static string GetPathToAssetBundlesMakeInfo(BuildTarget eTarget)
 {
     return(string.Format("{0}/{1}/{2}", GetPathToRoot(), "AssetBundlesInfo", SHHard.GetStrToPlatform(eTarget)));
 }