Object Pooling. Public function to return an object?

Hey guys thanks for reading my question.
I’m creating a generic pooling object i manage to spawn,store objects. But i want to have one clean empty pool object containing the instantiated objects, and make my other Objects to request object from there.
What’s the best way to do this? I was thinking on creat a function on my pool object that search the desire object and returns it but i don’t know how to write the function to be accessible from any object without using GetComponent every time, a public/static function or extending Monobehaviour maybe?

===== EDIT ======

Thanks for the answer Boredmormon, maybe i need to explain a little more, setactive or not it’s great that’s how i had dicided to manage the objects my only issue is pulling the objects from the pools, i’ll have multiple pools difined from the inspector.

My code for the pool so far:

#pragma strict
import System.Collections.Generic;

//CREAR PILETAS DINAMICAS =START=
public class ObjectsPool extends System.Object {
	var Objeto : GameObject;
	var Cantidad : int;
	var Escalable : boolean;
	var Pileta = new List.<GameObject>();
}

var GrupoDePiletas : ObjectsPool[];

function Start () {
	for(var piletas : ObjectsPool in GrupoDePiletas){
		for(var i = 0;i < piletas.Cantidad;i++){
			var obj = Instantiate(piletas.Objeto,Vector3(0,0,0),Quaternion.identity);
			obj.SetActive(false);
			piletas.Pileta.Add(obj);
		}
	}
}
//CREAR PILETAS DINAMICAS =END=

function Update () {

}

I’ve got a blog post that offers one option over here.

The general idea is that you add another component to the pooled object (poolee?). That component contains a reference back to the object pool it came from, as well as the OnDisable method to add it back to the pool. That way you simply call SetActive(false) when you are done with the GameObject and it goes away automatically.

I would suggest against using a static function for returning to a pool. Typically you end up with more then one pool instance using the same code.

You could have all of your poolable GameObjects implement an interface or inherit from the same base class, but it gets messy quickly. In this case a wide inheritance structure is better then a deep one.

Well i decided to give up and just get reference to the pool script for now i don’t have so many spawn objects.
I leave the code for anyone how is working on pooling Objects as an alternative.

I create a list of individual pools with different GameObjects Quantities and Grow or not variables.
Just create an Object attach the script and then call LoadObject(IndexOfThePool) and use it.

//CREAR PILETAS DINAMICAS =START=
public class ObjectsPool extends System.Object {
	var Objeto : GameObject; //Prefab or object to instantiate
	var Cantidad : int; //Quantity
	var Escalable : boolean; //Will Grow?
	var Pileta = new List.<GameObject>(); //Actual list of Pooled objects
}

var GrupoDePiletas : ObjectsPool[];// Group of pools

//Init the pool with the specified quantities and objects
function Start () {
	for(var piletas : ObjectsPool in GrupoDePiletas){
		for(var i = 0;i < piletas.Cantidad;i++){
			var obj = Instantiate(piletas.Objeto,Vector3(0,0,0),Quaternion.identity);
			obj.SetActive(false);
			piletas.Pileta.Add(obj);
		}
	}
}
//CREAR PILETAS DINAMICAS =END=


//Use this function to get an object from an specific pool
//For example Pool[0] Enemies , Pool[1] Bullets , Pool[2] Clouds...
function LoadObject(PoolNumber : int) {
for(var i = 0;i < GrupoDePiletas[PoolNumber].Pileta.Count;i++){
	if(!GrupoDePiletas[PoolNumber].Pileta*.activeInHierarchy){*

_ return GrupoDePiletas[PoolNumber].Pileta*;_
_ }else if(GrupoDePiletas[PoolNumber].Pileta.activeInHierarchy && i == GrupoDePiletas[PoolNumber].Pileta.Count-1 && GrupoDePiletas[PoolNumber].Escalable){
var obj = Instantiate(GrupoDePiletas[PoolNumber].Objeto,Vector3(0,0,0),Quaternion.identity);
obj.SetActive(false);
GrupoDePiletas[PoolNumber].Pileta.Add(obj);
return obj;
}
}
return null;
}*_