- Home /
how to build & populate an array available to all scripts on all objects?
Is this possible, and how? and are their any memory or performance issues for doing it?
Answer by Jesse Anders · Dec 29, 2010 at 03:57 AM
Although it may not be the best choice software-design-wise, the most straightforward solution is probably to use a public static variable, as it will be accessible globally throughout your code (generally speaking).
Note that static variables can't be exposed directly via the inspector, so you'll most likely need to create and populate the array via code (e.g. in the Awake() or Start() function of a script).
And no, there shouldn't be any memory or performance issues to speak of (not that I can think of anyway).
Cool! What's the code for declaration? Is it public static var _my_new_array = new array[];
The syntax will (most likely) depend on the language (C#, UnityScript, or Boo).
Your answer
Follow this Question
Related Questions
Is this doable in unity 2 Answers
Access variables, objects in array in another script? 2 Answers
How do I get each GameObject to mind its own business? 1 Answer
get all scripts attached to gameobject 2 Answers
Array problem -3 Answers