关于史诗战利品与珠宝工艺不兼容问题报错解决方法-英灵神殿论坛-游戏讨论区-资源工坊-游戏模组资源分享

关于史诗战利品与珠宝工艺不兼容问题报错解决方法

2个插件在同时运行时不会报错,在进入游戏后打开英灵神殿概要中点击【宝藏与赏金】、【宝石效果】控制台中会出现以下错误:

[Error : Unity Log] NullReferenceException
Stack trace:
Jewelcrafting.GemEffects.CompendiumDisplay+DisplayGemEffectOverview.Postfix (TextsDialog __instance, TextsDialog+TextInfo text) (at <6b8d9d5760c94e0cbce45e16b652c5d6>:0)
(wrapper dynamic-method) TextsDialog.DMDTextsDialog::OnSelectText(TextsDialog,TextsDialog/TextInfo)
TextsDialog+<>c__DisplayClass5_0.<FillTextList>b__0 () (at <2959d3c128e64c61a08dcc9bb6744ec3>:0)
UnityEngine.Events.InvokableCall.Invoke () (at <80fe1a4e36fe44618284312cb721a597>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <80fe1a4e36fe44618284312cb721a597>:0)
UnityEngine.UI.Button.Press () (at <e97aac8d17514bea83fadfd039e9187a>:0)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at <e97aac8d17514bea83fadfd039e9187a>:0)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at <e97aac8d17514bea83fadfd039e9187a>:0)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at <e97aac8d17514bea83fadfd039e9187a>:0)
UnityEngine.EventSystems.EventSystem:Update()

根据索引找到Jewelcrafting源码中Jewelcrafting\Effects\CompendiumDisplay.cs文件 代码添加日志输出判断发现m_textArea对象为空

源代码:

private static void postfix(textsdialog __instance, textsdialog.textinfo text)
		{
			transform content = __instance.m_textarea.transform.parent;

			jc_ui_elements.foreach (object.destroy) ;
			jc_ui_elements.clear();
			content.getcomponent<verticallayoutgroup>().spacing = 10;
			if (text == compendiumpage)
			{
				render(__instance);
			}
		}

判断代码:

private static void Postfix(TextsDialog __instance, TextsDialog.TextInfo text)
        {
            if (__instance == null)
            {
                Debug.Log("TextsDialog为空");
                return;
            }

            if (__instance.m_textArea == null)
            {
                Debug.Log("m_textArea为空");
                return;
            }

            Transform content = __instance.m_textArea.transform.parent;

            if (JC_UI_Elements != null)
            {
                JC_UI_Elements.ForEach(Object.Destroy);
                JC_UI_Elements.Clear();
                Debug.Log("JC_UI_Elements已清空");
            }
            else
            {
                Debug.Log("JC_UI_Elements为空");
            }

            if (content != null)
            {
                content.GetComponent<VerticalLayoutGroup>().spacing = 10;
                Debug.Log("VerticalLayoutGroup间距已设置为10");
            }
            else
            {
                Debug.Log("content为空");
            }

            if (text != null && text == compendiumPage)
            {
                Render(__instance);
                Debug.Log("正在渲染compendiumPage");
            }
            else
            {
                Debug.Log("text为空或不等于compendiumPage");
            }
        }

通过控制台输出日志找到EpicLoot\TextsDialog_Patch.cs文件中代码

原代码 :

这段代码的作用是在游戏中显示文本对话框,并将文本分成标题和段落,然后在 UI 中显示它们。在这段代码中,有一段代码会销毁 TextContainer 中的所有子对象:

for (var i = 0; i < TextContainer.childCount; i++)
            {
                Object.Destroy(TextContainer.GetChild(i).gameObject);
            }

如果在 TextContainer 中有其他对象,而你不想销毁它们,可以使用类似于上面提供的代码,只销毁非 m_textArea 子对象。

如果你想修改这段代码,可以尝试以下代码:

修改后代码:

for (var i = 0; i < TextContainer.childCount; i++)
            {
                var child = TextContainer.GetChild(i);
                if (child != __instance.m_textArea.transform)
                {
                    Object.Destroy(child.gameObject);
                }
            }

这段代码会遍历 TextContainer 的所有子对象。如果子对象不是 m_textArea,那么就会销毁它。

因此如果装了史诗战利品与其它一起使用的模组中有 添加英灵神殿概要的都出现这个错误:无法获取m_textArea 对象

关于史诗战利品与珠宝工艺不兼容问题报错解决方法-资源工坊-游戏模组资源分享

请登录后发表评论

    没有回复内容