|
@@ -11,7 +11,7 @@ namespace GameLogic.Combat.CombatTool.SceneTool
|
|
|
|
|
|
private SceneMonoConfig sceneMonoConfig;
|
|
|
|
|
|
- private Map<int, GameObject> _allGameObjectPools = new Map<int, GameObject>();
|
|
|
+ private Map<int, GameObjectPool> _allGameObjectPools = new Map<int, GameObjectPool>();
|
|
|
|
|
|
public void Init(Transform root, SceneMonoConfig sceneMonoConfig)
|
|
|
{
|
|
@@ -25,11 +25,12 @@ namespace GameLogic.Combat.CombatTool.SceneTool
|
|
|
List<int> removeKey = new List<int>();
|
|
|
for (_allGameObjectPools.Begin(); _allGameObjectPools.Next();)
|
|
|
{
|
|
|
- Vector3 objetcPos = _allGameObjectPools.Value.transform.position;
|
|
|
+ Vector3 objetcPos = _allGameObjectPools.Value.own.transform.position;
|
|
|
if (Vector3.Distance(pos, objetcPos) > 300)
|
|
|
{
|
|
|
removeKey.Add(_allGameObjectPools.Key);
|
|
|
- _allGameObjectPools.Value.SetActive(false);
|
|
|
+ GObjectPool.Instance.Recycle(_allGameObjectPools.Value);
|
|
|
+ // _allGameObjectPools.Value.SetActive(false);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -61,22 +62,22 @@ namespace GameLogic.Combat.CombatTool.SceneTool
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- GameObject gameObjectPool = GetObejct();
|
|
|
+ GameObjectPool gameObjectPool = GetObejct();
|
|
|
float y = Random.Range(-2, 0);
|
|
|
- gameObjectPool.transform.position = new Vector3(currX, y, currZ);
|
|
|
+ gameObjectPool.own.transform.position = new Vector3(currX, y, currZ);
|
|
|
_allGameObjectPools.Add(key, gameObjectPool);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private GameObject GetObejct()
|
|
|
+ private GameObjectPool GetObejct()
|
|
|
{
|
|
|
int index = Random.Range(0, sceneMonoConfig.allObject.Length);
|
|
|
GameObject gameObject = sceneMonoConfig.allObject[index];
|
|
|
- GameObject go = GameObject.Instantiate(gameObject);
|
|
|
- // GameObjectPool gameObjectPool =
|
|
|
- // GObjectPool.Instance.FetchAsyncForGameObject<GameObjectPool>(gameObject, gameObject.name);
|
|
|
- return go;
|
|
|
+ // GameObject go = GameObject.Instantiate(gameObject);
|
|
|
+ GameObjectPool gameObjectPool =
|
|
|
+ GObjectPool.Instance.FetchAsyncForGameObject<GameObjectPool>(gameObject, gameObject.name);
|
|
|
+ return gameObjectPool;
|
|
|
}
|
|
|
}
|
|
|
}
|