void OnApplyPersistentData() { TargetSpawner.SpawnedObjects = new List <GameObject>(); Collider2D[] colliders = TargetSpawner.GetOverlapObjects(); foreach (Collider2D collider in colliders) { string prefabName = collider.gameObject.name.Replace("(Clone)", string.Empty); if (collider.gameObject == gameObject) { continue; } if (collider.GetComponent <PixelCrushers.SpawnedObject>() != null) { if (collider.GetComponent <PixelCrushers.SpawnedObject>().key.Contains("PlayerPlaced")) { continue; } } if (TargetSpawner.SmallObjects.Find(x => x != null && string.Equals(x.name, prefabName)) != null && collider.isTrigger == false) { if (!TargetSpawner.SpawnedObjects.Contains(collider.gameObject)) { TargetSpawner.SpawnedObjects.Add(collider.gameObject); } } else if (TargetSpawner.LargeObjects.Find(x => x != null && string.Equals(x.name, prefabName)) != null && collider.isTrigger == false) { if (!TargetSpawner.SpawnedObjects.Contains(collider.gameObject)) { TargetSpawner.SpawnedObjects.Add(collider.gameObject); } } } //get objects }