public override eErrorCode LoadJsonTable(JsonData pJson)
    {
        if (null == pJson)
        {
            return(eErrorCode.Table_LoadFailed);
        }

        int iMaxTable = pJson.Count;

        for (int iLoop = 0; iLoop < iMaxTable; ++iLoop)
        {
            var             pDataNode = pJson[iLoop];
            SHResourcesInfo pData     = new SHResourcesInfo();
            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_strHash       = GetStrToJson(pDataNode, "s_Hash");
            pData.m_strPath       = GetStrToJson(pDataNode, "s_Path");
            pData.m_eResourceType = SHUtils.GetResourceTypeByExtension(pData.m_strExtension);

            AddResources(pData.m_strName, pData);
        }

        return(eErrorCode.Succeed);
    }
Exemplo n.º 2
0
    private void LoadAsync <T>(SHResourcesInfo pTable, Action <T> pCallback) where T : UnityEngine.Object
    {
        if (null == pTable)
        {
            pCallback(null);
            return;
        }

        if (true == m_dicResources.ContainsKey(pTable.m_strName.ToLower()))
        {
            pCallback(m_dicResources[pTable.m_strName.ToLower()] as T);
            return;
        }

        Action <T> pLoadedAction = (pObject) =>
        {
            if (null == pObject)
            {
                Debug.LogError(string.Format("[LSH] {0}을 로드하지 못했습니다!!\n리소스 테이블에는 목록이 있으나 실제 파일은 없을 수도 있습니다.", pTable.m_strPath));
            }
            else
            {
                if (false == m_dicResources.ContainsKey(pTable.m_strName.ToLower()))
                {
                    m_dicResources.Add(pTable.m_strName.ToLower(), pObject);
                }
                else
                {
                    m_dicResources[pTable.m_strName.ToLower()] = pObject;
                }
            }

            pCallback(pObject);
        };

        DateTime pStartTime = DateTime.Now;

        //var pBundleData = Single.AssetBundle.GetBundleData(Single.Table.GetBundleInfoToResourceName(pTable.m_strName));
        //if (null != pBundleData)
        //{
        //    Single.Coroutine.Async(pBundleData.m_pBundle.LoadAssetAsync<T>(pTable.m_strName), (pRequest) =>
        //    {
        //        pLoadedAction((pRequest as ResourceRequest).asset);
        //    });
        //}
        //else
        {
            Single.Coroutine.Async(Resources.LoadAsync <T>(pTable.m_strPath), (pRequest) =>
            {
                var pAsset = (pRequest as ResourceRequest).asset;
                if (null != pAsset)
                {
                    Single.AppInfo.SetLoadResource(string.Format("Load : {0}({1}sec)",
                                                                 pTable.m_strName, ((DateTime.Now - pStartTime).TotalMilliseconds / 1000.0f)));
                }

                pLoadedAction(pAsset as T);
            });
        }
    }
Exemplo n.º 3
0
    // 유틸 : 파일로 부터 정보얻어서 테이블 데이터 객체만들기
    SHResourcesInfo MakeResourceInfo(FileInfo pFile)
    {
        // 예외처리 : 리스팅에서 제외할 파일
        if (true == CheckExceptionFile(pFile))
        {
            return(null);
        }

        // 알리아싱
        string strRoot      = "Resources";
        string strFullName  = pFile.FullName.Substring(pFile.FullName.IndexOf(strRoot) + strRoot.Length + 1).Replace("\\", "/");
        string strExtension = Path.GetExtension(strFullName);

        // 기록
        var pInfo = new SHResourcesInfo();

        pInfo.m_strName      = Path.GetFileNameWithoutExtension(strFullName);
        pInfo.m_strFileName  = Path.GetFileName(strFullName);
        pInfo.m_strExtension = strExtension;
        pInfo.m_strSize      = pFile.Length.ToString();
        pInfo.m_strHash      = SHHash.GetMD5ToFile(pFile.FullName);
        pInfo.m_strPath      = strFullName.Substring(0, strFullName.Length - strExtension.Length);

        return(pInfo);
    }
Exemplo n.º 4
0
    // 유틸 : 리소스 리스트 추가
    void AddResourceInfo(SHResourcesInfo pInfo)
    {
        if (null == pInfo)
        {
            return;
        }

        m_dicResources[pInfo.m_strFileName] = pInfo;
    }
Exemplo n.º 5
0
    // 인터페이스 : 파일정보 Json 포맷으로 만들어주기
    public static JsonData MakeResourceJsonData(SHResourcesInfo pInfo)
    {
        JsonData pJsonData = new JsonData();

        pJsonData["s_Name"]      = pInfo.m_strName;
        pJsonData["s_FileName"]  = pInfo.m_strFileName;
        pJsonData["s_Extension"] = pInfo.m_strExtension;
        pJsonData["s_Size"]      = pInfo.m_strSize;
        pJsonData["s_Hash"]      = pInfo.m_strHash;
        pJsonData["s_Path"]      = pInfo.m_strPath;

        return(pJsonData);
    }
Exemplo n.º 6
0
    // 유틸 : 번들로 묶지 않을 파일에 대한 필터링
    bool CheckFilteringToAssetBundleInfo(SHResourcesInfo pInfo)
    {
        // 프리팹 파일 필터링
        if (".prefab" == pInfo.m_strExtension)
        {
            return(true);
        }

        // 테이블 파일 필터링
        if (".bytes" == pInfo.m_strExtension)
        {
            return(true);
        }

        return(false);
    }
Exemplo n.º 7
0
    private T LoadSync <T>(SHResourcesInfo pTable) where T : UObject
    {
        if (null == pTable)
        {
            return(null);
        }

        if (true == m_dicResources.ContainsKey(pTable.m_strName.ToLower()))
        {
            return(m_dicResources[pTable.m_strName.ToLower()] as T);
        }

        DateTime pStartTime = DateTime.Now;

        T pObject = null;

        //var pBundleData = Single.AssetBundle.GetBundleData(Single.Table.GetBundleInfoToResourceName(pTable.m_strName));
        //if (null != pBundleData)
        //    pObject = pBundleData.m_pBundle.LoadAsset<T>(pTable.m_strName);
        //else
        pObject = Resources.Load <T>(pTable.m_strPath);

        if (null == pObject)
        {
            Debug.LogError(string.Format("[LSH] {0}을 로드하지 못했습니다!!\n리소스 테이블에는 목록이 있으나 실제 파일은 없을 수 있습니다.", pTable.m_strPath));
            return(null);
        }

        Single.AppInfo.SetLoadResource(string.Format("Load : {0}({1}sec)", pTable.m_strName, ((DateTime.Now - pStartTime).TotalMilliseconds / 1000.0f)));

        if (true == m_dicResources.ContainsKey(pTable.m_strName.ToLower()))
        {
            m_dicResources[pTable.m_strName.ToLower()] = pObject;
        }
        else
        {
            m_dicResources.Add(pTable.m_strName.ToLower(), pObject);
        }

        return(pObject);
    }
Exemplo n.º 8
0
    // 유틸 : 번들 리스트 추가
    // 1. 리소스의 최상위 폴더이름을 번들이름으로 하여 등록시킴.
    // 2. 프리팹을 제외한 모든 리소스를 번들 리스트로 등록시킴.
    void AddAssetBundleInfo(SHResourcesInfo pInfo)
    {
        //if (null == pInfo)
        //    return;

        //if (true == CheckFilteringToAssetBundleInfo(pInfo))
        //    return;

        //// 번들이름 만들기
        //string strBundleName    = "Root";
        //string[] strSplitPath   = pInfo.m_strPath.Split(new char[] { '/' });
        //if (1 < strSplitPath.Length)
        //    strBundleName = strSplitPath[0];

        //// 번들정보 생성하기
        //if (false == m_dicAssetBundles.ContainsKey(strBundleName))
        //{
        //    var pBundleInfo = new AssetBundleInfo();
        //    pBundleInfo.m_strBundleName = strBundleName;
        //    m_dicAssetBundles.Add(strBundleName, pBundleInfo);
        //}

        //m_dicAssetBundles[strBundleName].AddResourceInfo(pInfo);
    }
 void AddResources(string strKey, SHResourcesInfo pData)
 {
     m_pData[strKey.ToLower().Trim()] = pData;
 }