Combining NC FSM with NData

Forums 💬 NodeCanvas 🗨️ General Discussion Combining NC FSM with NData

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #15070
    pathightree
    Participant

      Hi there,
      I’m trying to integrate NC FSM with the NData MVVM framework.
      Both are pretty new to me and I could use a couple of pointers.

      I want the FSM to run the ViewModel by setting its properties.
      My main problem right now is that the nData ViewModel monobehaviour itself does not contain the properties.
      It has a property of type Context which contains the properties I’m after.
      Unfortunately this Context class is not a monobehavour and therefore I cannot select it when specifying the Set Property action.

      Here is an example, I would like to be able to read/write the TestBool and TestFloat properties.

      Thanks in advance, Patrick

      #15075
      Gavalakis
      Keymaster

        Hello,

        Yes, the script control tasks are able to select the properties directly exposed on the monobehaviour. What you could do, is to create an intermediate monobehaviour class with the properties you would like to read/write and attach it on the same gameobject that ‘ViewModel’ is on. Something like this:

        #15074
        pathightree
        Participant

          Thanks for your help, that worked.
          That solves the flow of information from NC to NData.

          The other direction is also causing me problems:
          So far, the only way I have found to communicate a button click to NC is this: UIButton calls a function on my ViewModel, which in turn raises an event, which NC can detect. Is there a more compact way of doing this?
          I tried to detect a mouse click on the collider of the button, but it does not get detected when I click the button in the UI camera (the click probably gets eaten by NGUI).

          #15073
          Gavalakis
          Keymaster

            I don’t know how NData works, but you could make a condition that checks if an NGUI button is clicked. Here it is:

            #15072
            pathightree
            Participant

              Awesome, works like a charm 🙂
              Thanks for getting me up to speed!

              #15071
              Gavalakis
              Keymaster

                You are welcome 🙂

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