Blackboard losing its referenced objects

NodeCanvas Forums Support Blackboard losing its referenced objects

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9637

    I’m running into a problem where a Blackboard will lose the proper UnityEngine.Object references setup. The issue is strange and you’ll think it is some kind of user-error, but please read through.

    Let’s start with this blackbaord:

    CustomMonoBehaviour is simply a script file from my project. There are 2 variables in the BB, both of them assigned by dragging a game object onto the variable field.

    For some BB, when the project recompiles, the BB variable value2 get set to value1.

    Ok, it sounds like I’m crazy now, but I’ve spent a lot of time to figuring this out.

    It boils down to jsUnityObjectConverter, in the Serialize function: database.Contains((UnityEngine.Object)instance) is used to determine if the current reference is already tracked. Under some conditions this will return TRUE when it shouldn’t. In the case of the BB above, the check value1 == value2 returns TRUE while a basic Debug.Log on the object shows they are different.

    I don’t know what’s special about the moment when Unity recompiles but it certainly happens then (Serialize is called right after the project has compiled, that is also unclear why to me). Unity does internal serialization during recompile, play and build so I would believe this problem could happen then as well. I saw other posts on the forums that sound suspiciously similar to this: Button conditions lost when building application

    I do not know either why it happens with some BB and not others, no idea. Clearly, I don’t have all the answer or even really understand what is going on, but there is an issue there.

    I have a workaround. Actually, if you take a look at fsCyclicReferenceManager.cs in FullSerializer, you will notice the comment:

    Unity is infamous for messing with the == and Equals() on gameobjects (see unity’s blog) so the idea is to use ReferenceEquals instead of the basic Equals (which is used by Contains/IndexOf).

    I hope this makes sense…

    Alain-Daniel

    #9639
    pjohalloran
    Participant

    Yes, I have seen this issue too. Its an odd one. Nice job on tracking it down.

    #9638
    Gavalakis
    Keymaster

    Hello,

    Thanks a lot for the bug find and solution provided.
    I will implement this in the next version.

    Thanks and Cheers!

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

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