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 That should fix your problem, I hope this helps! 🙂
You are watching: Not all code paths return a value

Attachments:Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
Welcome to jonathanlewisforcongress.com jonathanlewisforcongress.com
The best place to ask and answer questions about development with jonathanlewisforcongress.com.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to jonathanlewisforcongress.com jonathanlewisforcongress.com, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked jonathanlewisforcongress.com questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.

See more: Zac Efron Has A Lot Of Thoughts About Kissing The Rock And Zac Efron In Baywatch
NullReferenceException: Object reference not set to an instance of an object 0jonathanlewisforcongress.com
One script with multiple Gameobject only one Works 0jonathanlewisforcongress.com
jonathanlewisforcongress.com bug gives false error messages or doesen”t work without a Debug.Log() line present 1Answer
Serialization depth limit exceeded at “MaterialNode” error 0jonathanlewisforcongress.com
Can”t reference script of parent 2jonathanlewisforcongress.com
EnterpriseSocial Q&A
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram
Footer
Purchase Education Download jonathanlewisforcongress.com Labs Resources About jonathanlewisforcongress.com
See more: How Much Is 30 Kg In Pounds In 30 Kg, Calculate Weight
“jonathanlewisforcongress.com”, jonathanlewisforcongress.com logos, and other jonathanlewisforcongress.com trademarks are trademarks or registered trademarks of jonathanlewisforcongress.com Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.