- Home /
Access a static var from different named scripts?
(this is for testing purposes, and hopes to be adapted to my real game later)
I want to make multiple buttons on the GUI, (lets just say 3 buttons), When you click on the first button, the number1 script is activated the rest are deactivated, when you click on 2, 2 is activated rest deactivated, and same for 3 (the 3 scripts contain static vars for a weapons minimum and maximum damage). now i know how to do that, but i need help with this, i want my characters Attack script to be able to figure out which script is activated, grab its static var, and place it in a variable inside of a function. I already have everything setup IF i put the variables inside the function directly, i just need help to make it grab them from the other scripts
Answer by Ashkan_gc · Mar 04, 2010 at 07:34 AM
to use static variables you just need to use classname.staticvariablename = xxx but your questions is not as clear as it should be.
ok i have script A script B and script C on an empty game object, if A is activated, B and C are deactivated. if B is activated A and C are deactivated. so on so forth. I want my other script, named Attack, to be able to find out which script is activated (A B or C) and grab its static var.
Sounds like you're going to need to create a static boolean var on each script and set it to true or false when it's activated. Then your character can check to see which script is true.
Your answer
Follow this Question
Related Questions
from which script was it? 2 Answers
Static variables 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Finding the length of a string 2 Answers
variable = true from another script 2 Answers