[NodeCanvas] Unable to serialize private field

Forums 💬 NodeCanvas ⚙️ Support [NodeCanvas] Unable to serialize private field

  • This topic has 0 replies, 2 voices, and was last updated 3 years ago by Gavalakis.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #15635
    dominatorduck
    Participant

      I’m attempting to serialize a private field as shown in 1, but NodeCanvas is failing to serialize the field as shown in 2. 3 Shows Unity serializing the field in a ScriptableObject.
      [attachment file=”InkedHowToSerializePvtField_LI.jpg”]

      Here you can see the value as serialized in the graph asset file:
      [attachment file=”image_2022-06-08_211119396.png”]

      I’m using Unity 2020.1.6f1 and NodeCanvas 3.2.2.
      Do I have to create a custom ObjectDrawer for this case?

      #15638
      Gavalakis
      Keymaster

        Hello there,

        The inspectors in NodeCanvas do not expose private fields by default even if they are set as [Serializable]. While this is different than Unity inspectors, it always felt incorrect to expose private fields.

        With that said, you can simply add the [ParadoxNotion.Design.ExposeField] attribute on your private field to expose it in the NodeCanvas inspector (no custom object drawer required).

        Let me know if that works for you.

        Thanks!

        #15637
        dominatorduck
        Participant

          That definitelly works!

          Thanks Gavalakis!
          I’m loving NodeCanvas.

          #15636
          Gavalakis
          Keymaster

            I am very glad to hear that! Thank you! 🙂

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