public static bool ArrayInsert <T>(ref T[] dest, ref T[] src, int idest) { int nsrc = src.Length; int ndest0 = dest.Length; int ndest1 = ndest0 + nsrc; if (idest > ndest0) { return(false); } if (nsrc == 0) { return(true); } if (!Lib.ArrayRedim(ref dest, ndest1)) { return(false); } //shift entries to right ArrayShiftRight(ref dest, /*ileft*/ idest, /*iright*/ ndest0 - 1, /*relmove*/ nsrc); //copy src to dest for (int i = 0; i < nsrc; i++) { dest[idest + i] = src[i]; } return(true); }
//note: cant return inactive gameobjects. icbb to inv! public static GameObject[] GetGameObjects() { Transform[] trans = UnityEngine.Object.FindObjectsOfType <Transform>(); int n = trans.Length; GameObject[] r = new GameObject[n]; int i = 0; foreach (Transform t in trans) { r[i] = t.gameObject; i++; } Lib.ArrayRedim(ref r, i); return(r); }