コード例 #1
0
        private void LoadAssetSuccessCallback(string dataTableAssetName, object dataTableAsset, float duration, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GXException("Load data table info is invalid.");
            }

            try
            {
                if (!m_DataTableHelper.LoadDataTable(dataTableAsset, loadDataTableInfo.LoadType, loadDataTableInfo.UserData))
                {
                    throw new GXException(Utility.Text.Format("Load data table failure in helper, asset name '{0}'.", dataTableAssetName));
                }

                if (m_LoadDataTableSuccessEventHandler != null)
                {
                    LoadDataTableSuccessEventArgs loadDataTableSuccessEventArgs = LoadDataTableSuccessEventArgs.Create(dataTableAssetName, loadDataTableInfo.LoadType, duration, loadDataTableInfo.UserData);
                    m_LoadDataTableSuccessEventHandler(this, loadDataTableSuccessEventArgs);
                    ReferencePool.Release(loadDataTableSuccessEventArgs);
                }
            }
            catch (Exception exception)
            {
                if (m_LoadDataTableFailureEventHandler != null)
                {
                    LoadDataTableFailureEventArgs loadDataTableFailureEventArgs = LoadDataTableFailureEventArgs.Create(dataTableAssetName, loadDataTableInfo.LoadType, exception.ToString(), loadDataTableInfo.UserData);
                    m_LoadDataTableFailureEventHandler(this, loadDataTableFailureEventArgs);
                    ReferencePool.Release(loadDataTableFailureEventArgs);
                    return;
                }

                throw;
            }
            finally
            {
                ReferencePool.Release(loadDataTableInfo);
                m_DataTableHelper.ReleaseDataTableAsset(dataTableAsset);
            }
        }
コード例 #2
0
        private void LoadAssetOrBinaryFailureCallback(string dataTableAssetName, LoadResourceStatus status, string errorMessage, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GXException("Load data table info is invalid.");
            }

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

            if (m_LoadDataTableFailureEventHandler != null)
            {
                LoadDataTableFailureEventArgs loadDataTableFailureEventArgs = LoadDataTableFailureEventArgs.Create(dataTableAssetName, loadDataTableInfo.LoadType, appendErrorMessage, loadDataTableInfo.UserData);
                m_LoadDataTableFailureEventHandler(this, loadDataTableFailureEventArgs);
                ReferencePool.Release(loadDataTableFailureEventArgs);
                return;
            }

            throw new GXException(appendErrorMessage);
        }