void Awake() { m_agents = FindObjectsOfType <SMAAgent>(); if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); m_agents = new List <SMAAgent>(); SMAAgent[] agents = FindObjectsOfType <SMAAgent>(); foreach (SMAAgent currentAgent in agents) { m_agents.Add(currentAgent); } } else { Destroy(gameObject); } }