SerializedObject / SerializedProperty in Task Inspector

Forums 💬 NodeCanvas 🗨️ General Discussion SerializedObject / SerializedProperty in Task Inspector

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14162
    deemen
    Participant

      Hi Gavalakis,

      Been a while since I posted here and I’m happy to say we are still using NodeCanvas in a major way after 2 years. Great job!

      I’ve been writing lots of Unity Editor tools lately and I’ve been using SerializedObject / SerializedProperty to cut a lot of the tedium out of writing a custom inspector. Using these classes you get free Undo/Redo, free Prefab support and you can use PropertyDrawers, which helps keep code modular. I noticed NodeCanvas is still using an entirely custom TaskInspectorGUI and I was wondering if you’d be open to supporting PropertyDrawers. This would save us a lot of time since we use PropertyDrawers to display lots of custom classes, when these show up in NodeCanvas nodes, the task inspector doesn’t know how to handle them.

      Have you looked into this at all? Is there some key problem I am missing about the implementation?

      Cheers!

      #14165
      Gavalakis
      Keymaster

        Hey,
        That’s great to hear! I am very glad you are working with NodeCanvas still! Thanks 🙂

        Yes, I have looked into this in the past, but there is indeed a key problem that makes it impossible to support Unity’s native Object/Property Drawers as is, in NodeCanvas. The problem is that these work with SerializedProperty and SerializedProperty is only possible to get out of fields that are directly serialized in a UnityEngine.Object. Alas, NodeCanvas uses JSON for serialization and the classes serialized in a Task for example, are not really directly serialized within a UnityEngine.Object. As such creating a SerializedProperty for these, is unfortunately not really possible. I’ve also tried hacking my way around this, but nothing really could be done as far as I know.

        Due to that reason, I had to create a custom solution for Object/Property Drawers specifically for NodeCanvas:
        [DOCUMENTATION LINK]

        Of course this solution is NodeCanvas specific, but once again, using Unity’s native Object/Property Drawer solution within NodeCanvas (and pretty much any asset using custom serialization) is unfortunately not possible in any way I know of due to the above reasons.

        I hope that makes sense.

        By the way, if you are using NodeCanvas in one of your games and you’d like to share it in the Showcase section of the website, let me know 😉
        Thanks again!

        #14164
        deemen
        Participant

          Hey Gavalakis,

          Yeah I started looking into it and discovered the same problem you had. It’s a shame Unity doesn’t allow you to plug into their code. You used to use Unity objects in NodeCanvas though. Why did you decide to switch to JSON?

          I do think Object Drawers for NodeCanvas makes a lot of sense though. I was excited when I saw the documentation. We just need to update to the latest version.

          Thanks for the quick response!

          #14163
          Gavalakis
          Keymaster

            Hey,

            I decided to go with a custom serialization (JSON in this case), because it is far more flexible in handling complex structures like graphs, and for not having to manage Unity object instances and references all the time, which was becoming a pain, especially the deeper you go into that structure. 🙂

            I strongly recommend updating to the new version on your next project if you are still using 1.6. There are so many improvements and features worth the upgrade 🙂

            Thanks!

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