Renaming Tasks

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13699
    garethffoulkes
    Participant

      Hi,
      I was wondering how people working on larger projects approach ‘renaming’ ActionTasks and ConditionTasks on graphs? For some reason the NC console never catches the ‘missing type error’ so I have to go through all my graphs across all my scenes manually.

      Cheers.

      #13703
      Gavalakis
      Keymaster

        Hello and sorry for the very late reply (I was ill).

        Indeed the NC Console does not catch the ‘missing type errors’ right now and is something that needs to be improved upon. It is also something that I am working towards for the next version (along with some other workflow improvements like “search in graph”).
        Hopefully, I might be able to also add some tool, to batch rename missing type nodes in a graph to the new correct type. This will of course still be done manually by entering the new serialized full type name, but at least it could be done in batch.

        Having said that, there is already a useful attribute for handling this problem though, that attribute being [DeserializeFrom].
        You can use this attribute on top of your Task class to specify the full type name from which to deserialize from (eg the previously Full type name).

        Thus for example, if your task was MyNamespace.MyTask and you’ve renamed it to MyNamespace.MyAwesomeTask, you can solve this like this:

        Note also, that the [DeserializeFrom] arguments is not a single string, but rather a params string[]. As such, if you later on further rename the task, you can provide all previous names for safety. For example:

        Finally, [DeserializeFrom] works for everything serialized in a NodeCanvas graph, including nodes.

        Let me know if that works for you.
        Thanks and once again, sorry for the very late reply.

        #13702
        garethffoulkes
        Participant

          Hey sorry for my late reply, must of missed the notification email.

          Thanks a lot for your response, I just tried out [DeserializeFrom] and it works great, much like unitys [FormerlySerialized].
          Thanks again and keep up the good work!

          #13701
          garethffoulkes
          Participant

            Hey just a follow up after some use,
            Everything works fine but I get the following in the console every time I switch scenes, play, build etc.

            (Type Request Error)</b>: Type with name ‘…’ could not be resolved. UnityEngine.Logger:Log(LogType, String, Object, Object).

            I’m guessing the attribute requires me to load the graph again so it can reserialize? But its a bit hard to know where it’s coming from because my project has a lot of scenes behaviour trees etc. I’ll hold of renaming anything for now, but let me know if you find a solution.

            Thanks again.

            #13700
            Gavalakis
            Keymaster

              Hey,

              Thanks for the follow up. Yes indeed, the graph needs to be loaded again for it to serialize back into the correct type since it is not handled at deserialization time alone. I understand that this might not be as convenient as it could be. I will try find a better solution, possibly serialize back the graph automatically, or at least make the error able to point to the graph in question (which is something I am already planning to do anyway).

              Thank you!

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