Something confused about the use of dictionary in C#
I was designing a project pool dict for managing pools with singleton. The pool created function as below
public void CreatePool(string poolID, GameObject prefab, int size, GameObject parent)
{
pools.Add(poolID, new List<GameObject>());
for (int i = 0; i < size; ++i)
{
pools[poolID].Add(prefab);
}
}
But when I try to take object from the dict I can't find the pool in the dict, it is disappeared. I test in the create function, the pool is created, the result of Debug.Log(pools.Count)
is 1
. But in other functions, it come to 0
.
what's wrong with this? I am a beginner, thanks for everyone helping me.
Your answer
Follow this Question
Related Questions
Gravity problem 1 Answer
Move a separate object forward on collision between particle system and another object 0 Answers
Instantiate a script into an instantiated prefab 3 Answers
How can I check if a object in the hierarchy have been destroyed using EditorWindow type script ? 1 Answer
Can someone please help me find out what wrong with my code. 0 Answers