本文共 820 字,大约阅读时间需要 2 分钟。
摄像机本身的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(); 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, 0, 1f, 1f); UICamera uiCam = CameraObj.AddComponent (); uiCam.eventReceiverMask = 1 << CAM_LAYER;}
转载地址:http://mrzvf.baihongyu.com/