IEnumerator CreatRole(GameVector2[] _roleGrid) { Dictionary <string, GameObject> pre_roleModle = new Dictionary <string, GameObject> (); List <BattleUserInfo> list_battleUser = BattleData.Instance.list_battleUser; for (int i = 0; i < list_battleUser.Count; i++) { yield return(new WaitForEndOfFrame()); BattleUserInfo _info = list_battleUser [i]; GameObject _base = Instantiate(pre_roleBase, roleParent); GameObject _ui = Instantiate(pre_roleUI, _base.transform); // string _modleStr = string.Format("BattleScene/Role/RoleModel{0}",_info.roleID); string _modleStr = "BattleScene/Role/RoleModel"; if (!pre_roleModle.ContainsKey(_modleStr)) { pre_roleModle [_modleStr] = Resources.Load <GameObject> (_modleStr); } GameObject _modle = Instantiate(pre_roleModle [_modleStr]); GameVector2 _grid = _roleGrid [_info.battleID - 1]; GameVector2 _pos = BattleData.Instance.GetMapGridCenterPosition(_grid.x, _grid.y); RoleBase _roleCon = _base.GetComponent <RoleBase> (); _roleCon.InitData(_ui, _modle, _info.battleID, _pos); dic_role [_info.battleID] = _roleCon; } initFinish = true; }