public void GetAllObjectsWithScript() { ScriptName[] list = FindObjectsOfType(typeof(ScriptName)) as ScriptName[]; foreach(ScriptName obj in list) { // Do whatever } }