Exemplo n.º 1
0
        public virtual T getPoolItemFromPool <T>() where T : PoolItem
        {
            PoolItem   result = null;
            GameObject go     = null;
            GameObject prefab = getMainAsset() as GameObject;

            if (prefab == null)
            {
                return(default(T));
            }
            if (isShaderFinded == false)
            {
                isShaderFinded = true;
                RenderUtils.ShaderFind(prefab);
            }
            if (pool == null)
            {
                pool = new Stack <PoolItem>();
            }

            while (pool.Count > 0)
            {
                result = pool.Pop();
                if (result != null)
                {
                    result.isNew = false;
                    go           = result.gameObject;
                    go.SetActive(true);
                    break;
                }
            }

            if (go == null)
            {
                go     = GameObject.Instantiate <GameObject>(prefab);
                result = go.AddComponent <T>();

                if (go.activeSelf == false)
                {
                    go.SetActive(true);
                }
                result.manager = this;
            }
            return((T)result);
        }
Exemplo n.º 2
0
 protected virtual void prebindComponents()
 {
     RenderUtils.SetEnabledRecursive(gameObject, _renderable);
 }