コード例 #1
0
        private void LoadAssetSuccessCallback(string dictionaryAssetName, object dictionaryAsset, float duration, object userData)
        {
            LoadDictionaryInfo loadDictionaryInfo = (LoadDictionaryInfo)userData;

            if (loadDictionaryInfo == null)
            {
                throw new GXException("Load dictionary info is invalid.");
            }

            try
            {
                if (!m_LocalizationHelper.LoadDictionary(dictionaryAsset, loadDictionaryInfo.LoadType, loadDictionaryInfo.UserData))
                {
                    throw new GXException(Utility.Text.Format("Load dictionary failure in helper, asset name '{0}'.", dictionaryAssetName));
                }

                if (m_LoadDictionarySuccessEventHandler != null)
                {
                    LoadDictionarySuccessEventArgs loadDictionarySuccessEventArgs = LoadDictionarySuccessEventArgs.Create(dictionaryAssetName, loadDictionaryInfo.LoadType, duration, loadDictionaryInfo.UserData);
                    m_LoadDictionarySuccessEventHandler(this, loadDictionarySuccessEventArgs);
                    ReferencePool.Release(loadDictionarySuccessEventArgs);
                }
            }
            catch (Exception exception)
            {
                if (m_LoadDictionaryFailureEventHandler != null)
                {
                    LoadDictionaryFailureEventArgs loadDictionaryFailureEventArgs = LoadDictionaryFailureEventArgs.Create(dictionaryAssetName, loadDictionaryInfo.LoadType, exception.ToString(), loadDictionaryInfo.UserData);
                    m_LoadDictionaryFailureEventHandler(this, loadDictionaryFailureEventArgs);
                    ReferencePool.Release(loadDictionaryFailureEventArgs);
                    return;
                }

                throw;
            }
            finally
            {
                ReferencePool.Release(loadDictionaryInfo);
                m_LocalizationHelper.ReleaseDictionaryAsset(dictionaryAsset);
            }
        }
コード例 #2
0
        private void LoadAssetOrBinaryFailureCallback(string dictionaryAssetName, LoadResourceStatus status, string errorMessage, object userData)
        {
            LoadDictionaryInfo loadDictionaryInfo = (LoadDictionaryInfo)userData;

            if (loadDictionaryInfo == null)
            {
                throw new GXException("Load dictionary info is invalid.");
            }

            string appendErrorMessage = Utility.Text.Format("Load dictionary failure, asset name '{0}', status '{1}', error message '{2}'.", dictionaryAssetName, status.ToString(), errorMessage);

            if (m_LoadDictionaryFailureEventHandler != null)
            {
                LoadDictionaryFailureEventArgs loadDictionaryFailureEventArgs = LoadDictionaryFailureEventArgs.Create(dictionaryAssetName, loadDictionaryInfo.LoadType, appendErrorMessage, loadDictionaryInfo.UserData);
                m_LoadDictionaryFailureEventHandler(this, loadDictionaryFailureEventArgs);
                ReferencePool.Release(loadDictionaryFailureEventArgs);
                return;
            }

            throw new GXException(appendErrorMessage);
        }