Log() private static method

private static Log ( LogType logType, string text ) : void
logType LogType
text string
return void
Beispiel #1
0
        // Where we actuall call WWW to download the assetBundle.
        static protected bool LoadAssetBundleInternal(string assetBundleName, bool isLoadingAssetBundleManifest)
        {
#if ENABLE_NDINFRA_DEBUG_INFO
            AssetBundleManager.Log(LogType.Info, "LoadAssetBundleInternal assetBundleName=" + assetBundleName);
#endif// ENABLE_NDINFRA_DEBUG_INFO

            // Already loaded.
            LoadedAssetBundle bundle = null;

#if ENABLE_NDINFRA_CUSTOM
            // assetBundleName may be with variant extention, but m_LoadedAssetBundles doesn't
            string shortKey = RemovePostVariant(assetBundleName);
            m_LoadedAssetBundles.TryGetValue(shortKey, out bundle);
#else
            m_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle);
#endif // ENABLE_NDINFRA_CUSTOM

            if (bundle != null)
            {
                bundle.m_ReferencedCount++;
                return(true);
            }

            // @TODO: Do we need to consider the referenced count of WWWs?
            // In the demo, we never have duplicate WWWs as we wait LoadAssetAsync()/LoadLevelAsync() to be finished before calling another LoadAssetAsync()/LoadLevelAsync().
            // But in the real case, users can call LoadAssetAsync()/LoadLevelAsync() several times then wait them to be finished which might have duplicate WWWs.
            if (m_DownloadingWWWs.ContainsKey(assetBundleName))
            {
                return(true);
            }

            WWW    download = null;
            string url      = m_BaseDownloadingURL + assetBundleName;

#if ENABLE_NDINFRA_CUSTOM
            // start check version
            // assetBundleName is with variant extension.

#if ENABLE_NDINFRA_DEBUG_INFO
            Debug.LogWarning("LoadAssetBundleInternal input and assemble url=" + url);
#endif // ENABLE_NDINFRA_DEBUG_INFO

            string keyWoVariant = RemovePostVariant(assetBundleName);

            bool isVersionExist = m_VersionTable.ContainsKey(keyWoVariant);
            int  targetVersion  = 0;
            if (isVersionExist)
            {
                targetVersion = m_VersionTable[keyWoVariant];
            }


            // check if we need to use local asset bundle
            bool isLocalExist     = m_LocalBundleTable.ContainsKey(keyWoVariant);
            bool isUseLocalBundle = isLocalExist &&
                                    (!isVersionExist || (isVersionExist &&
                                                         m_LocalBundleTable[keyWoVariant] >= m_VersionTable[keyWoVariant]));

            if (true == isUseLocalBundle)
            {
                targetVersion  = m_LocalBundleTable[keyWoVariant];
                isVersionExist = true;
                // change path to streaming assets path
                url = GetStreamingAssetsPath() + "/AssetBundles/" + Utility.GetPlatformName() + "/" + assetBundleName;
#if ENABLE_NDINFRA_DEBUG_INFO
                AssetBundleManager.Log(LogType.Info, "LoadAssetBundleInternal local bundle url=" + url);
#endif // ENABLE_NDINFRA_DEBUG_INFO
            }

            if (m_EnableVersionCheck && isVersionExist)
            {
                // url was used here
                download = WWW.LoadFromCacheOrDownload(url, targetVersion);
            }
            else
            {
#if ENABLE_NDINFRA_DEBUG_INFO
                AssetBundleManager.Log(LogType.Info, "LoadAssetBundleInternal version not exists, beware of caching.");
#endif // ENABLE_NDINFRA_DEBUG_INFO
#endif // ENABLE_NDINFRA_CUSTOM

            // For manifest assetbundle, always download it as we don't have hash for it.
            if (isLoadingAssetBundleManifest)
            {
                download = new WWW(url);
            }
            else
            {
                download = WWW.LoadFromCacheOrDownload(url, m_AssetBundleManifest.GetAssetBundleHash(assetBundleName), 0);
            }

#if ENABLE_NDINFRA_CUSTOM
        }
#endif  // ENABLE_NDINFRA_CUSTOM


            m_DownloadingWWWs.Add(assetBundleName, download);

            return(false);
        }