/// <summary> /// Populates the descriptor. /// </summary> /// <returns>Populated descriptor.</returns> /// <param name="descriptor">Descriptor to be populated with the instance of the resource component.</param> private PoolableObjectDescriptor <T> PopulateDescriptor(PoolableObjectDescriptor <T> descriptor) { T newInstance = InstantiateNewComponent(); descriptor.component = newInstance; return(descriptor); }
/// <summary> /// Creates a new Descriptor and populates it's component field /// </summary> /// <returns>The populated descriptor.</returns> private PoolableObjectDescriptor <T> NewPopulatedDescriptor() { T newInstance = InstantiateNewComponent(); PoolableObjectDescriptor <T> descriptor = new PoolableObjectDescriptor <T> (newInstance); return(descriptor); }
/// <summary> /// Obtains Descriptor. You must not store returned Descriptor! /// </summary> public PoolableObjectDescriptor <T> ObtainDescriptor() { PoolableObjectDescriptor <T> descriptor = null; //if head is at zero we create an immidiatlly return created instance if (this._head < 0) { //Debug.LogWarningFormat ("POOL: No instancies available for {0}! All {1} preloaded instances in use. Instantiating new one...", this._resource.name, this.descriptorList.Count); this._head = 0; PopulateDescriptor(this._descriptorList [this._head]); } descriptor = this._descriptorList [this._head]; --this._head; return(descriptor); }