Пример #1
0
 /// <summary>
 /// 오브젝트가 생성됨.
 /// </summary>
 public T Created <T>(PoolingObjectType pEPoolingObjectType, string p_name)
     where T : PooledObjectComponent
 {
     gameObject.SetActive(true);
     PoolingInfo = new PoolingInfo(pEPoolingObjectType, p_name);
     OnCreated();
     return(GetCachedComponent <T>());
 }
Пример #2
0
 /// <summary>
 /// 오브젝트가 생성됨.
 /// </summary>
 public T Created <T>(Transform parents, PoolingObjectType pEPoolingObjectType, string p_name)
     where T : PooledObjectComponent
 {
     transform.SetParent(parents);
     gameObject.SetActive(true);
     PoolingInfo = new PoolingInfo(pEPoolingObjectType, p_name);
     OnCreated();
     return(GetCachedComponent <T>());
 }
        /// <summary>
        /// 오브젝트를 파괴하지 않고 풀링함.
        /// 풀링된 오브젝트는 하위에 위치 시킴.
        /// </summary>
        public void RegistPooledObject(PoolingInfo poolingInfo, PooledObjectComponent pooledObjectComponent)
        {
            switch (poolingInfo.PoolingObjectType)
            {
            case PoolingObjectType.View:
            {
                if (_pooledPageViewDict.ContainsKey(poolingInfo.PrefixName) == false)
                {
                    _pooledPageViewDict.Add(poolingInfo.PrefixName, pooledObjectComponent);
                }

                break;
            }

            case PoolingObjectType.Prefab:
            {
                if (_pooledPrefabDict.ContainsKey(poolingInfo.PrefixName) == false)
                {
                    _pooledPrefabDict.Add(poolingInfo.PrefixName, new Queue <PooledObjectComponent>());
                }

                _pooledPrefabDict[poolingInfo.PrefixName].Enqueue(pooledObjectComponent);
                break;
            }

            default:
                break;
            }

            if (_pooledObjTransformDict.ContainsKey(poolingInfo.PoolingObjectType) == false)
            {
                var gameObj      = new GameObject();
                var objTransform = gameObj.transform;
                objTransform.name = poolingInfo.PoolingObjectType.ToString();
                objTransform.SetParent(_objectPoolingComponent.transform);
                objTransform.SetInstantiateTransform();

                _pooledObjTransformDict.Add(poolingInfo.PoolingObjectType, objTransform);
            }

            pooledObjectComponent.transform.SetParent(_pooledObjTransformDict[poolingInfo.PoolingObjectType]);
            pooledObjectComponent.gameObject.SetActive(false);
        }