How to create private var?

(nantianliao) #1

How to create private var in Blox ?

(Richard Rae) #2

Event variables are private

(nantianliao) #3


(Leslie Young) #4

Event Variables are scoped to the Event. They are like variables declared in the function and thus temporary. Do not depend on their values being valid after the Event is done executing or starts again next time.

There is no real concept of private variables like you get on in class/object scope. Rather think of variables as to where they should be accessed from or what they relate to.

Have a look at the docs but here is a bullet point;

  • Event: temporary and invalid after event exit.
  • Blox: these are like your class properties, public class variables. They will be unique among instances of the same Blox on different objects just like instances of a class are.
  • Object: these are there for when you want to add some properties to a GameObject without having to add a BloxContainer and Blox to it.
  • Global: as the name implies. Only one set of these can exist, Can think of them as static variables in some class.