//Fills the array of textures with the selected objects in the hierarchy view //adds to the end all the objects. public void FillArrayWithSelectedObjects(GameObject[] arr) { //dont include already optimized objects List <GameObject> filteredArray = new List <GameObject>(); for (int i = 0; i < arr.Length; i++) { if (!arr[i].name.Contains(Constants.OptimizedObjIdentifier)) { filteredArray.Add(arr[i]); } else { Debug.LogWarning("Skipping " + arr[i].name + " game object as is already optimized."); } } bool filledTexture = false; for (int i = 0; i < filteredArray.Count; i++) { filledTexture = false; for (int j = 0; j < ObjSorter.GetObjs().Count; j++) { for (int k = 0; k < ObjSorter.GetObjs()[j].Count; k++) { if (ObjSorter.GetObjs()[j][k] == null) { if (!ObjectRepeated(filteredArray[i])) { ObjSorter.GetObjs()[j][k] = new OptimizableObject(filteredArray[i]); filledTexture = true; break; } else { Debug.LogWarning("Game Object " + filteredArray[i].name + " is already in the list."); } } } if (filledTexture) { break; } } //if we didnt find an empty spot in the array, lets just add it to the texture list. if (!filledTexture) { if (!ObjectRepeated(filteredArray[i])) { ObjSorter.AddObject(filteredArray[i]); //adds also null internally to increase space for textures filledTexture = true; objectsSize++; } else { Debug.LogWarning("Game Object " + filteredArray[i].name + " is already in the list."); } } } }