Direct Access

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #14857
    huhund
    Participant

      Hi,

      This is a performance question.

      The recommended way in the documentation to directly access blackboard data is GetDataValue<T>(string dataName) and SetDataValue(string dataName, System.Object value). Afaik as I know this would cause a stringa alloc as well as a look up in the list of variables. I think doing this every frame in my game code might cause a small performance overhead.

      My question is can I safely use the GetData(string dataName, Type ofType) method instead. I.e. only call GetData once in a MonoBehaviour and cache the VariableData object, then access all reads and writes through that. Is there any reason not to do this?

      Best, Hu

      #14858
      Gavalakis
      Keymaster

        Hello,

        Indeed, I recommend the GetDataValue(string) in the documentation as it is more easy to understand and use, but if you are going to call this much frequently then it is better and fine to cache the VariableData with GetData(string, Type).
        This is also what’s happening under the hood in NC for the obvious performance reasons 🙂

        Cheers!

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