I have Start function up on the line about 500. Becouse I have much public GameObject. Is possible simplify example with other script? Mirek
Maybe yes, maybe not. Is just pure guess game, for what you have provided us.
1 Like
I need all object. Becouse it is database kit parts. I thinked something like with Vector3. In other game I had script with only Vector3 (1000 and more). Is possible script with database GameObject for GameManager?
Can you use an array of GameObjects?
For working with GameObject yes. But for inicialized I dont know. Every GameObject must write like public GameObject and insert in Inspector. It must be only in GameManager?
I don’t understand exactly what you are trying to do, something like this?
public class MyScript : MonoBehaviour
{
public GameObject[] objectDatabase = new GameObject[];
}
And have every MyScript share the objectDatabase? You could use OnValidate
public class MyScript : MonoBehaviour
{
public static List<GameObject> sharedDatabase = new List<GameObject>();
public GameObject[] objectDatabase = new GameObject[];
void OnValidate()
{
sharedDatabase.Clear();
foreach(var s in FindObjectOfType<MyScript>())
{
if(!sharedDatabase.Contains(s.gameObject))
sharedDatabase.Add(s.gameObject);
}
}
}