Public and Private Variables in Scripts

Functions and variables can be declared in scripts as Public and Private. A variable declared Private is visible only to the asset it is created in. So if a variable is created in a script or function, then it can only be used inside that asset, and not any others that may be called by the asset.

A variable declared Public is available to all assets after it is created. Any data passing from one function to another or from one script to another should be declared as a Public variable. However, use of public variables can create a situation where a publicly declared variable may be used in other scripts that may playback at the same time. This might cause corrupted data use or compile errors.

Variables should only be declared as Public when there is certainty that the same variable name not being used in other assets.

Public and private variables in scripts are used in the same way global and local variables are used in visual tests.