关键代码:
GameObject cameraObj = new GameObject();
cameraObj.transform.position = new Vector3(_mapInfo.CenterPos.x, _mapInfo.CenterPos.y + 50, _mapInfo.CenterPos.z);
Camera camera = cameraObj.AddComponent<Camera> ();
camera.transform.LookAt(_mapInfo.CenterPos);
RenderTexture rt = new RenderTexture(_mapInfo.Width, _mapInfo.Height, 0);
camera.clearFlags = CameraClearFlags.SolidColor;
camera.backgroundColor = UnityEngine.Color.black;
camera.orthographic = true;
camera.orthographicSize = _mapInfo.Height/2;
camera.aspect = (_mapInfo.Width/2)/camera.orthographicSize;
camera.cullingMask = 1<<LayerMask.NameToLayer(_mapLayerName);
camera.targetTexture = rt;
camera.Render();
RenderTexture.active = rt;
Texture2D screenShot = new Texture2D(_mapInfo.Width, _mapInfo.Height, TextureFormat.RGB24, fals