Child nodes in my custom system

Forums 💬 NodeCanvas 🗨️ General Discussion Child nodes in my custom system

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #14741
    facebookuser2
    Participant

      Hi guys,
      I write my tree system to visualize data tree. I need in creating and childing nodes at runtime to their base node. So what the best way to do that?

      #14751
      facebookuser2
      Participant

        I can create new node by graph.AddNewNode(MyTestNode), but I got exeption when I select this node in Graph window, because MyTestNode have public property like: public IMyInterface MyProperty { get; set; }. So how to prevent parsing some public proprties by EditorUtils?

        And how to addNewNode as child to other node (with connection)?

        Sorry for the dumb questions.

        #14750
        Gavalakis
        Keymaster

          Hello,

          Are you creating your own node system?
          You are probably using an old version of NC and that is why you are getting the error of EditorUtils parsing the public property. This has been changed and properties are no longer parsed.

          Regarding creating a whole tree through code, the current API has some limitations especialy when it comes to assigning Task (actions, conditions). If you are creating your onw system where you wont use tasks, then you probably wont have any difficulties. It depends on the system.

          The API for creating trees from code in runtime will be improved in the future to be faster (for example make use of generics)

          You can connect 2 nodes together with ConnectNode(Node, Node). Here is an example:

          Using ConnectNode, node2 will be connected to the last port index of node1.

          Let me know,
          Gavalakis Vaggelis

          #14749
          facebookuser2
          Participant

            Gavalakis, thank you very much!

            Yes I’m creating my own node system to visualize my serialized game data.
            So, one last question, can NodeCanvas sort all nodes positions? Currently all new nodes are instantiated at the same place.

            #14748
            Gavalakis
            Keymaster

              You are welcome 🙂

              No, currently there exit no auto position sorting for the nodes, since well, it’s primary designed to create trees from the editor window 🙂

              If you want to position your nodes, or even create your own sorting method, use the nodeRect property of the node which is available only in editor (#if UNITY_EDITOR) and adjust it’s center (node.nodeRect.center) which is a Vector2. Top left of the canvas is 0,0.

              Let me know if you have any questions.
              Cheers!

              #14747
              facebookuser2
              Participant

                Thanks!

                #14746
                facebookuser2
                Participant

                  Hey Gavalakis!
                  Is it possible to hide some nodes (which extended from my base node) from graph context menu?

                  Thanks!)

                  #14745
                  facebookuser2
                  Participant

                    Sorry for the bunch of questions 🙂
                    1) How to disable creation new node from connection port in the other node?
                    2) How to disable node deleting?
                    3) How to disable connection deleting?

                    #14744
                    Gavalakis
                    Keymaster

                      Hello,

                      No worries, but I am a bit confused 🙂

                      0. What do you mean hide nodes? Hide them in the graph?
                      1. What do you mean by disabling new node creation from connection port?
                      2,3. You mean disable the UI for deleting nodes and connections? Why you would want to do that? 🙂

                      Sorry, but I am confused 🙂

                      #14743
                      facebookuser2
                      Participant

                        Sorry, but I am confused 🙂

                        Sorry, for that 🙂 Let me explain)

                        0. I mean hide some nodes from a context menu – http://i.gyazo.com/28667a1734a7489787544de527a823f6.png;
                        1. At now I can click on the port and create new node with context menu – http://i.gyazo.com/28667a1734a7489787544de527a823f6.png I want to prevent this action;
                        2,3. As I said above in my previous posts, I write my own Node System for my own data framework for the Unity. All instances of my framework creates at runtime. So my NodeSystem just visualize my framework instances relations tree. So I don’t need to remove nodes or connections from graph, because my graph builds in runtime automaticaly.

                        #14742
                        Gavalakis
                        Keymaster

                          Don’t worry 🙂
                          So:

                          0. First of all, abstract node classes will not show. If you want to hide a non abstract node you can use [DoNotList] attribute on the node class and it will not be listed in the menu.

                          1. You will need to change the source code for that. Do you want to do that?

                          2,3. You will also need to change the source code for this.

                          I dont understand the practical reason that you want to remove those UI feature. I mean, if you don’t want to delete a node, then you can simply don’t delete it 🙂 and since it’s created at runtime there is no possibility that someone else is going to delete something that you don’t want to.

                          🙂

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