EllanJiang/GameFramework · error · GameFrameworkException
You must set resource manager first.
Error message
You must set resource manager first.
What it means
CreateDataTable<T> throws this when the DataTableManager's ResourceManager has not been assigned via SetResourceManager. The manager needs the resource manager to load table assets; without it, table creation cannot proceed, so it fails fast.
Solutions
- Call dataTableManager.SetResourceManager(resourceManager) before any CreateDataTable<T> call.
- Prefer creating the manager through the framework component (DataTableComponent) so dependencies are wired automatically.
- If bootstrapping manually, ensure SetResourceManager and SetDataProviderHelper are both called during startup before any table access.
- Move CreateDataTable calls after the framework initialization lifecycle point (e.g. after the component's Start).
Example fix
// before
var dataManager = new DataTableManager();
dataManager.CreateDataTable<MyRow>("MyTable");
// after
var dataManager = new DataTableManager();
dataManager.SetResourceManager(resourceManager);
dataManager.SetDataProviderHelper(dataProviderHelper);
dataManager.CreateDataTable<MyRow>("MyTable"); Defensive patterns
Strategy: validation
Validate before calling
if (dataTableManager.ResourceManager == null)
throw new InvalidOperationException("Call SetResourceManager before CreateDataTable."); Type guard
bool IsDataTableManagerReady(DataTableManager m) => m != null && m.ResourceManager != null && m.DataProviderHelper != null;
Try / catch
try { var table = dataTableManager.CreateDataTable<MyRow>("MyTable"); }
catch (GameFrameworkException ex) { Log.Error("DataTableManager not initialized: {0}", ex.Message); } Prevention
- Call SetResourceManager and SetDataProviderHelper immediately after constructing the manager.
- Create tables only after the framework component's initialization lifecycle (not in Awake before dependencies are set).
- Use DataTableComponent rather than manually new-ing DataTableManager.
When it happens
Trigger: Calling CreateDataTable<T>("Name") before calling dataTableManager.SetResourceManager(...), or on a DataTableManager instance that was constructed manually without the initialization the GameFramework component normally performs.
Common situations: Bypassing the framework's Unity component (DataTableComponent) and new-ing up DataTableManager directly; calling table creation in an Awake/Start that runs before the framework's initialization step; forgetting SetResourceManager after switching to a custom bootstrap.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Data row type is invalid.
- Data row type ' ' is invalid.
- Results is invalid.
- Data table is invalid.
- You must add web request agent first.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/8bd7b086267536fd.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/DataTable/DataTableManager.cs:326
/// </summary>
/// <param name="dataRowType">数据表行的类型。</param>
/// <returns>要创建的数据表。</returns>
public DataTableBase CreateDataTable(Type dataRowType)
{
return CreateDataTable(dataRowType, string.Empty);
}
/// <summary>
/// 创建数据表。
/// </summary>
/// <typeparam name="T">数据表行的类型。</typeparam>
/// <param name="name">数据表名称。</param>
/// <returns>要创建的数据表。</returns>
public IDataTable<T> CreateDataTable<T>(string name) where T : class, IDataRow, new()
{
if (m_ResourceManager == null)
{
throw new GameFrameworkException("You must set resource manager first.");
}
if (m_DataProviderHelper == null)
{
throw new GameFrameworkException("You must set data provider helper first.");
}
TypeNamePair typeNamePair = new TypeNamePair(typeof(T), name);
if (HasDataTable<T>(name))
{
throw new GameFrameworkException(Utility.Text.Format("Already exist data table '{0}'.", typeNamePair));
}
DataTable<T> dataTable = new DataTable<T>(name);
dataTable.SetResourceManager(m_ResourceManager);
dataTable.SetDataProviderHelper(m_DataProviderHelper);
m_DataTables.Add(typeNamePair, dataTable);
return dataTable;View on GitHub (pinned to d0c010b051)