Duplicate GlobalBlackboard warnings when using GBBs as prefabs

NodeCanvas Forums Support Duplicate GlobalBlackboard warnings when using GBBs as prefabs

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12416
    zsoik
    Participant

    I’ve upgraded to 2.6.3 yesterday and we now have lots of new warnings about duplicate GlobalBlackboard instances in our scenes, even though there is just one global blackboard! But it’s a prefab instance, so the same GlobalBlackboard lives a “silent” live in the asset database, too.

    I guess I could track it down to the change of the global blackboard registering behaviour. In 2.6.2 they registered themselves in OnEnable, now they do it in Awake. The catch is that Awake will be called for prefabs, but OnEnable will not, so this explains why we’re getting this error now.

    Edit: Looks like OnEnable will also be called for Prefabs (Maybe a 2017 thing?)
    Edit2: Actually, I was wrong all the time. It’s the OnValidate() implementation 🙂

    Repro:
    – Create a new scene
    – Add a GlobalBlackboard to it
    – Store the GameObject with the GlobalBlackboard as a prefab
    – Close/Reopen scene
    – Observe “Duplicate GlobalBlackboard” error.

    NC 2.6.3 / Unity 2017.1.0p1

    #12417
    zsoik
    Participant

    I could hotfix it by changing the condition in OnValidate from
    !allGlobals.Contains(this)
    to
    UnityEditor.PrefabUtility.GetPrefabType(this) != UnityEditor.PrefabType.Prefab && !allGlobals.Contains(this)

    And
    gameObject.scene.IsValid() && !allGlobals.Contains(this)
    would also work.

    #12419
    Gavalakis
    Keymaster

    Hey,

    I’ve recently been reported this problem by someone else too 🙂
    I fixed this by adding this piece of code at the start of both OnEnable and OnValidate methods of GlobalBlackboard.cs:

    This is very similar to what you have done of course 🙂

    Join us on Discord: https://discord.gg/97q2Rjh

    #12424
    zsoik
    Participant

    Oh, I looked through the posts and couldn’t find a similar report 🙂 Thanks for the validation!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.