Exemplo n.º 1
0
    private void UpdateChunkFromPool()
    {
        if (!gameObject.activeInHierarchy)
        {
            Debug.LogError("CAN'T DO THIS IN FOLDER!");
            return;
        }

        Transform _pooled = transform.Find(POOLED_NAME);

        if (!_pooled)
        {
            Debug.LogError("THERE IS NO 'POOLED' GAMEOBJECT IN THE CHUNK");
            return;
        }

        foreach (Transform _objectToPool in _pooled.FirstLayerChildren())
        {
            ObjectPool.ObjectPoolEntry _objectPoolEntry =
                ObjectPool.Instance.Entries.Find(x => x.Prefab.name == _objectToPool.name);

            if (_objectPoolEntry == null)
            {
                Debug.LogError("GAMEOBJECT " + _objectToPool.name + " DOES NOT EXIST IN THE POOL!", _objectToPool);
                continue;
            }

            GameObject _instantiatedGameObject = Instantiate(_objectPoolEntry.Prefab, _objectToPool);
            _instantiatedGameObject.transform.parent = _pooled;
            _instantiatedGameObject.transform.name   = _objectPoolEntry.Prefab.name;

            _instantiatedGameObject.transform.position   = _objectToPool.position;
            _instantiatedGameObject.transform.rotation   = _objectToPool.rotation;
            _instantiatedGameObject.transform.localScale = _objectToPool.localScale;

            Undo.DestroyObjectImmediate(_objectToPool.gameObject);
        }
        EditorUtility.SetDirty(this);
    }
Exemplo n.º 2
0
 public void Initialize(ObjectPool.ObjectPoolEntry objectPoolEntry)
 {
     this.objectPoolEntry = objectPoolEntry;
 }
Exemplo n.º 3
0
 // Use this for initialization
 void Awake()
 {
     objectPool = GameObject.Find("Object Pool").GetComponent<ObjectPool>();
     objectPoolEntry = objectPool.GetPoolEntryForPrefab(PrefabToCreate);
 }