[BUG] Custom Attribute Drawer, (float)instance cast is not working with BBParam

NodeCanvas Forums Support [BUG] Custom Attribute Drawer, (float)instance cast is not working with BBParam

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #15415
    Andy Miira
    Participant

    Hi, I may have discovered an error in the NodeCanvas documentation, in the “Creating Custom Object Drawers” page.
    https://nodecanvas.paradoxnotion.com/documentation/?section=creating-custom-object-drawers

    In the MyRangeDrawer class example, the “(float)instance” cast is not working.
    Unity throws the following error: InvalidCastException: Specified cast is not valid.

    I tested this with NodeCanvas v3.1.6, Unity 2020.1.17f1.

    The error happens when I apply my custom attribute to a BBParameter<float> variable.
    The documentation implies that cast should also work with BBParameter.

    #15420
    Gavalakis
    Keymaster

    Hello there,

    You are right. The code shown in the documentation is outdated and I have just updated that section. In practice, we need to check whether or not the type of the field we are currently “looking at” is of the required type we want and only if so proceed with the editor GUI code (and also the casting). Otherwise, we call MoveNextDrawer() by the end of the OnGUI method.

    Please take a look at the updated documentation. You can also take a look at the various implemented attribute drawers that can be found in AttributeDrawers.cs file for a few more examples.

    Please let me know if that works for you.
    Thanks!

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

    #15423
    Andy Miira
    Participant

    Thank you for updating the documentation!

    I managed to implement my attribute drawer correctly now 😀

    #15431
    Gavalakis
    Keymaster

    Awesome. I am glad you did 🙂

    Happy new year!

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

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