I am changing hero of every player at the beginning of the game.
First I call PrecacheUnitByNameAsync on the hero name, then inside the callback I call PlayerResource:ReplaceHeroWith. This returns a proper hero pointer. Alse of I call PlayerResource:GetSelectedHeroEntity right afterwards, it returns the same pointer.
However, when I call PlayerResource:GetSelectedHeroEntity on the player outside of the callback, it returns nil. It is somehow random. Sometimes it is for 1 player, sometimes for 2, sometimes (rarely) it does not happen.
Anyone seen this? It started with the last patch. Is there some new cashing / garbage collection / optimization?