Beispiel #1
0
        private void LoadDataTableFailureCallback(string dataTableAssetName, string errorMessage, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

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

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

            if (LoadDataTableFailure != null)
            {
                LoadDataTableFailure(dataTableAssetName, appendErrorMessage, loadDataTableInfo.UserData);
                return;
            }

            throw new Exception(appendErrorMessage);
        }
Beispiel #2
0
        private void LoadDataTableSuccessCallback(string dataTableAssetName, UnityEngine.Object dataTableAsset, float duration, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

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

            try
            {
                if (!CreateDataTable(dataTableAssetName, dataTableAsset, loadDataTableInfo.DataTableType, loadDataTableInfo.UserData))
                {
                    throw new Exception(TextUtil.Format("Load data table failure in helper, asset name '{0}'.", dataTableAssetName));
                }
            }
            catch (Exception exception)
            {
                if (LoadDataTableFailure != null)
                {
                    LoadDataTableFailure(dataTableAssetName, exception.ToString(), loadDataTableInfo.UserData);
                    return;
                }

                throw;
            }
            finally
            {
                GameEntry.Resource.UnloadAsset(dataTableAsset);
            }

            if (LoadDataTableSuccess != null)
            {
                LoadDataTableSuccess(dataTableAssetName, duration, loadDataTableInfo.UserData);
            }
        }