Search Unity

GraphView throws error if a custom Node doesn't have the correct elements in its uxml.

Discussion in 'UI Toolkit' started by WF_Bart, Apr 6, 2021.

  1. WF_Bart

    WF_Bart

    Joined:
    Apr 16, 2014
    Posts:
    29
    image (10).png

    I don't have the text version of the errror handy anymore, but this happens when you try to open the contextual menu on a node that doesn't have the elements 'input' or 'output' defined in their uxml.

    image (11).png

    The problem is that in its constructor Node tries to assign them to `this.[in/out]putContainer`, fails and assigns them as null. The DisconnectAllStatus() method then tries to Query<Port>() on the null elements.

    DisconnectAllStatus() should probably check if (e == null), or it should be made clear that each node needs to have an 'input' and 'output' element in its UXML file.
    (adding them in the constructor won't work, since that runs after the base class constructor).