The type or namespace name 'SharedInt' could not be found (are you missing a using directive or an assembly reference?)

Getting this error when trying to use the SharedInt or SharedFloat variables

error CS0246: The type or namespace name 'SharedFloat' could not be found (are you missing a using directive or an assembly reference?)

In this particular case, I'm writing a conditional task similar to the Deathmatch 'IsHealthLow' task referencing my own Health component.
Line 10: If I'm using the regular float type, I have no error. Only when I change it to SharedInt I get the error.

SharedInt reference error.png

I see someone else had the same issues here but no resolution. I did try adding an assembly definition to that folder to reference the BD runtime, but then that created a whole bunch of errors. I deleted it and prefer to fight one issue instead of 7 or 8
 
If the script is within an assembly definition then you will need to make sure you include the BehaviorDesignerRuntime.dll. This is where SharedFloat is defined.
 
Update: Currently, this issue is in Unity 2022.3.10 BUT my custom scripts worked well with Behavior Designer flawlessly in Unity 2020.3.48.

Test
: I copied over a custom class from 2020, which compiled, referenced BD and executed with no issues, to Unity 2022, and BAM! Unity 2022 complained. So I know it was 2022. I fiddled around with moving the class from one nested folder to another, in ascending order. Nothing worked.

Finally: I moved my class all the way up to the root ->Assets/myScript and it worked!

Somehow Unity 2022's default assembly definition just wasn't trying to couple my class in a child folder to BD runtime, hence the reason why referencing the Shared variables were returning an error.

Either way, it worked. It's just that I cannot organize my files as I'd like but I'll accept this for now.
 
Back
Top