ArborFSMのプレハブでSetParameterを使用すると、NullReferenceExceptionが発生する

Here is a forum for reporting failure to Arbor developer.
Please read the forum rules carefully and enter the information necessary to confirm the problem.

Note:
  • Please read the "Update Guide" carefully when updating Arbor.
  • The bugs that we already know are summarized in "Known Issues", so please check once.
  • Please check ReleaseNote and use the latest version if possible before reporting a bug.
  • Unity beta and alpha versions are not supported. Please use the official release version.
  • In principle, defects caused by the introduction of other assets are not supported. If you find a defect, please report it after isolating which asset is the problem.

ここは、Arbor開発者へ不具合を報告するためのフォーラムです。
フォーラムルールをよく読み、不具合確認に必要な情報を記載するようお願いします。

注意点:
  • Arborを更新する際は「アップデートガイド」をよく読み行ってください。
  • 既に把握している不具合は「既知の問題」にまとめてありますので一度確認してみてください。
  • 不具合報告をする前にReleaseNoteを確認し、なるべく最新バージョンを使用して下さい。
  • Unityのベータ版およびアルファ版はサポート対象外です。正式リリース版をご利用ください。
  • 他アセット導入による不具合は原則サポート対象外です。不具合を見つけた場合はどのアセットの問題であるか切り分けた上でのご報告をお願いいたします。

Forum rules
The items necessary for reporting are as follows.
  • OS(Required)
  • Unity version(Required)
  • Arbor version(Required)
  • How to reproduce(Required)
    The reproduction method should be described accurately so that anyone can read the same procedure.
    If you do not know the exact reproduction procedure, as long as you can remember it, so please tell us what you were doing immediately before and the last time you edited it.
  • Build platform
  • Reproduction project (Minimum configuration not including Arbor and other assets) or video

Note:
  • Please read the "Update Guide" carefully when updating Arbor.
  • The bugs that we already know are summarized in "Known Issues", so please check once.
  • Please check ReleaseNote and use the latest version if possible before reporting a bug.
  • Unity beta and alpha versions are not supported. Please use the official release version.
  • In principle, defects caused by the introduction of other assets are not supported. If you find a defect, please report it after isolating which asset is the problem.

報告に必要な項目は以下の通りです。
  • OS(必須)
  • Unityバージョン(必須)
  • Arborバージョン(必須)
  • 再現方法(必須)
    再現方法については、誰が読んでも同様の手順を行えるよう正確に記述するようにお願いいたします。
    もし正確な再現手順が不明な場合、覚えている限りで構いませんので直前に行っていたことや最後に編集した時のことを教えてください。
  • ビルドプラットフォーム
  • 再現プロジェクト(Arborや他アセットなどを含まない最小構成)もしくは動画

注意点:
  • Arborを更新する際は「アップデートガイド」をよく読み行ってください。
  • 既に把握している不具合は「既知の問題」にまとめてありますので一度確認してみてください。
  • 不具合報告をする前にReleaseNoteを確認し、なるべく最新バージョンを使用して下さい。
  • Unityのベータ版およびアルファ版はサポート対象外です。正式リリース版をご利用ください。
  • 他アセット導入による不具合は原則サポート対象外です。不具合を見つけた場合はどのアセットの問題であるか切り分けた上でのご報告をお願いいたします。
ooee

ArborFSMのプレハブでSetParameterを使用すると、NullReferenceExceptionが発生する

Post by ooee »

いつもお世話になっています。

件名の不具合に遭遇したので、ご報告いたします。

OS: Windows11
Unityバージョン: 2021.3.30f1
Arborバージョン: 3.9.10
再現方法:
1. ArborFSMのプレハブを作成
2. プレハブでArborFSMをOpen Editorして、SetParameterを追加
3. Arbor Editorで何かしら値を編集すると、以下のエラーが発生する

NullReferenceException
Arbor.NodeBehaviour.get_nodeGraph () (at Assets/Plugins/Arbor/Internal/Scripts/NodeBehaviour.cs:76)
Arbor.ParameterBehaviours.SetParameterBehaviourInternal.SetupIsInGraphParameter () (at Assets/Plugins/Arbor/Internal/Scripts/StateMachine/ParameterBehaviours/SetParameterBehaviourInternal.cs:294)
Arbor.ParameterBehaviours.SetParameterBehaviourInternal.SerializeVer1 () (at Assets/Plugins/Arbor/Internal/Scripts/StateMachine/ParameterBehaviours/SetParameterBehaviourInternal.cs:329)
Arbor.ParameterBehaviours.SetParameterBehaviourInternal.Serialize () (at Assets/Plugins/Arbor/Internal/Scripts/StateMachine/ParameterBehaviours/SetParameterBehaviourInternal.cs:347)
Arbor.ParameterBehaviours.SetParameterBehaviourInternal.Arbor.INodeBehaviourSerializationCallbackReceiver.OnBeforeSerialize () (at Assets/Plugins/Arbor/Internal/Scripts/StateMachine/ParameterBehaviours/SetParameterBehaviourInternal.cs:363)
Arbor.NodeBehaviour.UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize () (at Assets/Plugins/Arbor/Internal/Scripts/NodeBehaviour.cs:384)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

MissingReferenceException: The object of type 'SetParameterBehaviour' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Arbor.NodeBehaviour.get_nodeGraph () (at Assets/Plugins/Arbor/Internal/Scripts/NodeBehaviour.cs:76)
Arbor.ParameterBehaviours.SetParameterBehaviourInternal.SetupIsInGraphParameter () (at Assets/Plugins/Arbor/Internal/Scripts/StateMachine/ParameterBehaviours/SetParameterBehaviourInternal.cs:294)
Arbor.ParameterBehaviours.SetParameterBehaviourInternal.SerializeVer1 () (at Assets/Plugins/Arbor/Internal/Scripts/StateMachine/ParameterBehaviours/SetParameterBehaviourInternal.cs:329)
Arbor.ParameterBehaviours.SetParameterBehaviourInternal.Serialize () (at Assets/Plugins/Arbor/Internal/Scripts/StateMachine/ParameterBehaviours/SetParameterBehaviourInternal.cs:347)
Arbor.ParameterBehaviours.SetParameterBehaviourInternal.Arbor.INodeBehaviourSerializationCallbackReceiver.OnAfterDeserialize () (at Assets/Plugins/Arbor/Internal/Scripts/StateMachine/ParameterBehaviours/SetParameterBehaviourInternal.cs:368)
Arbor.NodeBehaviour.UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize () (at Assets/Plugins/Arbor/Internal/Scripts/NodeBehaviour.cs:393)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

現在は、SetParameterのかわりにCalcParameterを代用しています。
User avatar
caitsithware
管理人
Posts: 493
Joined: 2015/08/17 12:41

Re: ArborFSMのプレハブでSetParameterを使用すると、NullReferenceExceptionが発生する

Post by caitsithware »

ご報告ありがとうございます。

こちらでも再現確認できました。
Unity側のプレハブ周りの仕様変更の関係か、Projectウィンドウのプレハブを直接Arbor Editorで開いて編集している場合に正常にシリアライズが行われないタイミングが発生する問題が起きているのを確認しました。
プレハブの直接編集ではSetParameterに限らず他にも何かしらの問題が起きている可能性もありそうです。
また、プレハブをダブルクリックしプレハブモードに切り替えてからHierachy上のオブジェクトを選択&編集した場合は再現しませんでした。
根本的な原因を調査の上修正いたします。

暫定対処方法
  1. プレハブをダブルクリックしプレハブモードに切り替える
  2. Hierachy上のオブジェクトを選択しInspectorのOpen Editorボタンをクリック
  3. Arbor Editorで編集する
User avatar
caitsithware
管理人
Posts: 493
Joined: 2015/08/17 12:41

Re: ArborFSMのプレハブでSetParameterを使用すると、NullReferenceExceptionが発生する

Post by caitsithware »

根本的な原因を調査したところ、Unityの不具合の可能性があったためUnityへバグレポートを送信いたしました。
この不具合が直るまでプレハブの直接編集ができないのも辛いかと思いますので次回更新時に以下の回避策を組み込みます。

回避策
  1. Assets/Plugins/Arbor/Internal/Scripts/NodeBehaviour.csをコードエディタで開く。
  2. 381行目(OnBeforeSerializeメソッド内の先頭)に以下コードを追加。

    Code: Select all

    try
    {
    	if (this == null)
    		return;
    }
    catch
    {
    	return;
    }
    
  3. 399行目(OnAfterDeserializeメソッド内の先頭)にも同様のコードを追加。

    Code: Select all

    try
    {
    	if (this == null)
    		return;
    }
    catch
    {
    	return;
    }
    
ooee

Re: ArborFSMのプレハブでSetParameterを使用すると、NullReferenceExceptionが発生する

Post by ooee »

回避策を問題が発生している手持ちのプロジェクトで確認したところ、エラーが発生しなくなりました。

確認ありがとうございました。
Post Reply