-
is there a way for a script to change the value of a variable in another script if that variable is public? |
Beta Was this translation helpful? Give feedback.
Answered by
manio143
Mar 28, 2022
Replies: 1 comment
-
A script can modify a public field/property of another script. If they are on the same entity you can use |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A script can modify a public field/property of another script. If they are on the same entity you can use
Entity.Get<OtherScriptClass>()
to obtain a reference to the other script. If they are on different entities, then you should create a field/propertypublic OtherScriptClass {get;set;}
and assign it via the editor by draggin over it an entity with the other script.