EllanJiang/GameFramework · error · GameFrameworkException

Results is invalid.

Error message

Results is invalid.

What it means

The list overload of GetUIForms requires a non-null results list to fill. Passing null results throws GameFrameworkException('Results is invalid.') after the asset name passes validation, because the method clears and appends into that list.

Solutions

  1. Instantiate the List<IUIForm> before calling GetUIForms(name, results)
  2. Check for null and create the list if needed at the call site
  3. Prefer the allocation-free overload only when you genuinely own a reusable list

Example fix

// before
List<IUIForm> results = null;
uiGroup.GetUIForms("GameOver", results);
// after
List<IUIForm> results = new List<IUIForm>();
uiGroup.GetUIForms("GameOver", results);
Defensive patterns

Strategy: validation

Validate before calling

var results = resultsList ?? new List<IUIForm>();

Type guard

bool HasResults(List<IUIForm> list) => list != null;

Try / catch

try { uiGroup.GetUIForms(name, results); } catch (GameFrameworkException ex) when (ex.Message.Contains("Results is invalid")) { results = new List<IUIForm>(); uiGroup.GetUIForms(name, results); }

Prevention

When it happens

Trigger: Calling UIGroup.GetUIForms(validName, null); a results variable that was declared but never instantiated; a helper returning null lists.

Common situations: Developers expecting the method to allocate the list for them; refactors where list initialization was removed; nullable fields defaulting to null.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/72bf7f412a8884bc. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/UI/UIManager.UIGroup.cs:281

                return results.ToArray();
            }

            /// <summary>
            /// 从界面组中获取界面。
            /// </summary>
            /// <param name="uiFormAssetName">界面资源名称。</param>
            /// <param name="results">要获取的界面。</param>
            public void GetUIForms(string uiFormAssetName, List<IUIForm> results)
            {
                if (string.IsNullOrEmpty(uiFormAssetName))
                {
                    throw new GameFrameworkException("UI form asset name is invalid.");
                }

                if (results == null)
                {
                    throw new GameFrameworkException("Results is invalid.");
                }

                results.Clear();
                foreach (UIFormInfo uiFormInfo in m_UIFormInfos)
                {
                    if (uiFormInfo.UIForm.UIFormAssetName == uiFormAssetName)
                    {
                        results.Add(uiFormInfo.UIForm);
                    }
                }
            }

            /// <summary>
            /// 从界面组中获取所有界面。
            /// </summary>
            /// <returns>界面组中的所有界面。</returns>
            public IUIForm[] GetAllUIForms()
            {

View on GitHub (pinned to d0c010b051)