What is this "Function" called???
I am programming in unity and well.. I needed to call a bool from another script...
The goal: To detect if the boolean named "birdIsAlive" in "BIRBSCRIPT" is true and if so to enable the ESC key for pausing.
The issue is solved, but I can't seem to understand why this works.
"EscapeKeyMechanism" references the "BIRBSCRIPT" via a gameobject with the script attached.
BUT in the "EscapeKeyMechanism" I don't understand why the "if(BirdLife.birdIsAlive)" is able to detect as dot operators can't see booleans.. right..? Or is that not a dot operator..?
Help to understand is appreciated.. I'm super new to C# so... ye thanks! :>
8 Replies
Considering
birdIsAlive
is a public member on BIRBSCRIPT
, any code that has a non-null reference to the script will also be able to access it.
There is no "dot operator", what you're doing is a completely normal member access. The type of the member matters not.Wait a boolean counts as a member?
A field counts as a member. The type does not matter
So because a boolean is a field it is therefore a member?
Sure. Just how
myRigidBody
, flapStrength
, and logic
are fields and therefore membersah.. I see! so what do you call this operation then? Like if I were to google it, what would I have to type to learn more about this type of access from one script to another?
Member access, like I mentioned
Alright thank you Sr Ero :)