public GameObject GetPooledObject()
{
for (int i = 0; i < pooledObjects.Count; i++)
{
if (!pooledObjects*.activeInHierarchy)*
{
return pooledObjects*;*
}
}
}
public GameObject GetPooledObject()
{
for (int i = 0; i < pooledObjects.Count; i++)
{
if (!pooledObjects*.activeInHierarchy)*
{
return pooledObjects*;*
}
}
}
Hi there @Surface_ketch
You are only returning a value if the conditional is met. This means that the method will be unable to return anything if the conditional is not met. To fix this, simply return a null or default value after the for loop like so:
public GameObject GetPooledObject()
{
for (int i = 0; i < pooledObjects.Count; i++) {
if (!pooledObjects *.activeInHierarchy) {*
_ return pooledObjects ;_
* }*
* }*
* return pooledObjects = null;*
* }*
That should fix your problem, I hope this helps!