- Home /
Question by
RemDust · Apr 03, 2016 at 06:16 PM ·
scripting problemarrayvariables
How to check for the same variable in multiple scripts (inside an array) ?
hi guys, I've created an array of scripts, and I need my manager to check for an int in any of these scripts. I wanted to do something like
private void ToggleScript(){
foreach (var script in dissableScripts) {
if (GameManager.Instance.savedPlayerData.currentStamina< script.theIntIWanttoCheck)
script.enabled = false;
}
}
but of course I'm not able to access the variable this way... any ideas ?
Comment
Is your variable set to public? Does it appear on list when you place a dot after script?
Use GetComponent.
You would do this when storing the script references to your array. This way you get actual information.
Your answer
Follow this Question
Related Questions
Texture2D Array Appears Grainy 0 Answers
How do I access a variables created in a function with another function? 1 Answer
Object Pool only activating one prefab 1 Answer
SphereCastAll - Getting data out of "Order By"+ "ToArray" 0 Answers
How to Find all objects with Tag and List their Transforms? 4 Answers