Beispiel #1
0
        public static void LoadText(string fileName, GameFrameworkAction <string> action)
        {
            GameEntry.Resource.LoadAsset(AssetUtility.GetDataTableAsset(fileName, LoadType.Bytes), new LoadAssetCallbacks(
                                             (assetName, asset, duration, userData) =>
            {
                Log.Info("Load UIItem prefab '{0}' OK.", assetName);
                action(asset.ToString());
            },

                                             (assetName, status, errorMessage, userData) =>
            {
                Log.Error("Can not load UIItem prefab '{0}' error message '{1}'.", assetName, errorMessage);
                action("");
            }));
        }
Beispiel #2
0
        public static void LoadDataTable(this DataTableComponent dataTableComponent, string dataTableName, LoadType loadType, object userData = null)
        {
            if (string.IsNullOrEmpty(dataTableName))
            {
                Log.Warning("Data table name is invalid.");
                return;
            }

            string[] splitNames = dataTableName.Split('_');
            if (splitNames.Length > 2)
            {
                Log.Warning("Data table name is invalid.");
                return;
            }

            string dataRowClassName = DataRowClassPrefixName + splitNames[0];

            Type dataRowType = Type.GetType(dataRowClassName);

            if (dataRowType == null)
            {
                Log.Warning("Can not get data row type with class name '{0}'.", dataRowClassName);
                return;
            }

            string dataTableNameInType = splitNames.Length > 1 ? splitNames[1] : null;

            dataTableComponent.LoadDataTable(dataRowType, dataTableName, dataTableNameInType, AssetUtility.GetDataTableAsset(dataTableName, loadType), loadType, Constant.AssetPriority.DataTableAsset, userData);
        }