Help with shared variables

Mulciber

New member
Need help with proper way to declare shared variables,reference them, and get values.

I started by following the documentation, but it appears to be using outdated code? Just looking to setup a simple Int for starters, which i use as a list index for gamepieces.

1. I created a shared Int under BD variables tab "BDInt"

2. In script: "Public SharedInt" doesnt seem to exist anymore. "public SharedVariable" is an option, but doesnt seem to work with ".Value" so i was unable to reference/assign. However "public SharedVariable<int>" seems to be the correct new syntax and this works except....

3. Going back into Unity>BD, going into my task, and then going to the inspector tab to assign it, I always get 3 errors (this only happens on entering the inspector tab). This tab seems to error out and never populates any public variables so i am unable to assign "BDInt" to the script int. See attached errors.

Not sure if this is a bug, or more likely I am not doing something correctly. I have updated Unity to 2018.3.0f2, and I believe i have the most up to date version of BD.

BDerror.PNG
 
2. In script: "Public SharedInt" doesnt seem to exist anymore. "public SharedVariable" is an option, but doesnt seem to work with ".Value" so i was unable to reference/assign. However "public SharedVariable<int>" seems to be the correct new syntax and this works except....
The SharedInt definition does still exist - make sure you are including the BehaviorDesigner.Runtime namespace. If you do a search for "SharedInt" you should also be able to find a good amount of tasks that use this variable type for an example.

The docs should also still be correct - the framework for the Shared Variable system hasn't really changed much since the beginning.
 
Thanks Justin, I thought it was strange that no one else seemed to have these issues and based on what you said i figured out the issue.

I use another asset that requires a certain filestructure in unity to build properly. So BD folder was 'Assets > BD' and scripts were located 'Assets > Plugins > Scripts'. Moving BD under the plugin folder gets everything working correctly.

As it was before I was only able to reference some things and not others, so SharedVariable<int> was accepted but SharedInt was not.

I am not sure if this is a bug, maybe just a Hierarchy limitation? but it may be worth mentioning in documentation for others - thanks!
 
Top