摄像机本身的depth越大,则它所渲染的东西越靠顶
public GameObject CameraObj;
public const int CAM_DEPTH = 2;
public const int CAM_LAYER = 5;
public void CreateCamere()
{
CameraObj = new GameObject("myCamera");
Camera cam = CameraObj.AddComponent<Camera>();
cam.transform.localPosition = Vector3.zero;
cam.transform.localScale = Vector3.one * 0.002777778f;
cam.depth = CAM_DEPTH;
cam.cullingMask = 1 << CAM_LAYER;
cam.gameObject.layer = CAM_LAYER;
cam.clearFlags = CameraClearFlags.Depth;
cam.orthographic = true; //投射方式:orthographic正交//
cam.orthographicSize = 1; //投射区域大小//
cam.nearClipPlane = -2.7f; //前距离//
cam.farClipPlane = 2.92f; //后距离//
cam.rect = new Rect(0,1f,1f);
UICamera uiCam = CameraObj.AddComponent<UICamera>();
uiCam.eventReceiverMask = 1 << CAM_LAYER;
}
原文地址:https://linxinfa.blog.csdn.net
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。