C
C#2mo ago
Randomator

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! :>
No description
No description
8 Replies
ero
ero2mo ago
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.
Randomator
RandomatorOP2mo ago
Wait a boolean counts as a member?
ero
ero2mo ago
A field counts as a member. The type does not matter
Randomator
RandomatorOP2mo ago
So because a boolean is a field it is therefore a member?
ero
ero2mo ago
Sure. Just how myRigidBody, flapStrength, and logic are fields and therefore members
Randomator
RandomatorOP2mo ago
ah.. 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?
ero
ero2mo ago
Member access, like I mentioned
Randomator
RandomatorOP2mo ago
Alright thank you Sr Ero :)
Want results from more Discord servers?
Add your server