{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/unity-camera-screen/",
  "atlas": "https://www.pystone.net/?node=unity-camera-screen#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/unity-camera-screen.md",
  "context": "https://www.pystone.net/notes/unity-camera-screen.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:unity-camera-screen",
  "slug": "unity-camera-screen",
  "title": "Camera & Screen",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "Camera & Screen 创建时间：2020/7/21 14:55",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "515c863b9dfcfe58bfa57b6d91d8dfe0afcd73a157eb5321d74665dd0966b43d",
  "assets": [
    {
      "reference": "assets/20180524230527942.jpg",
      "url": "/media/15f807375b039c5c6eba.png",
      "mediaType": "image/png",
      "contentHash": "15f807375b039c5c6ebaea7f77727324bea37ca9f93e06dee4e3254fbdab4442",
      "byteLength": 93107,
      "width": 775,
      "height": 475
    },
    {
      "reference": "assets/20180524232513244.jpg",
      "url": "/media/d5d6b362090312b5e995.png",
      "mediaType": "image/png",
      "contentHash": "d5d6b362090312b5e995085d28e494e00018d06b504bfc479736cc3d07ca1a05",
      "byteLength": 53410,
      "width": 579,
      "height": 204
    },
    {
      "reference": "assets/20180524230615918.jpg",
      "url": "/media/fa8b784c6c12caa9aad9.png",
      "mediaType": "image/png",
      "contentHash": "fa8b784c6c12caa9aad93e346521ab5e797546bf74abffa45bd4fe481325be0d",
      "byteLength": 57273,
      "width": 760,
      "height": 414
    },
    {
      "reference": "assets/20180524231957314.jpg",
      "url": "/media/a3380c1b11fa0752d973.png",
      "mediaType": "image/png",
      "contentHash": "a3380c1b11fa0752d973bb7cdc49f5108d3ad8a1883942066f9a33ee398537a5",
      "byteLength": 61290,
      "width": 623,
      "height": 262
    }
  ],
  "headings": [
    {
      "depth": 1,
      "text": "Camera & Screen",
      "anchor": "camera-screen",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#camera-screen"
    },
    {
      "depth": 2,
      "text": "Camera & Screen",
      "anchor": "camera-screen-1",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#camera-screen-1"
    },
    {
      "depth": 2,
      "text": "Screen",
      "anchor": "screen",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#screen"
    },
    {
      "depth": 2,
      "text": "Camera",
      "anchor": "camera",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#camera"
    },
    {
      "depth": 3,
      "text": "View Frustum(视锥体)相关参数图解",
      "anchor": "view-frustum视锥体相关参数图解",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#view-frustum%E8%A7%86%E9%94%A5%E4%BD%93%E7%9B%B8%E5%85%B3%E5%8F%82%E6%95%B0%E5%9B%BE%E8%A7%A3"
    },
    {
      "depth": 4,
      "text": "透视相机(Perspective)",
      "anchor": "透视相机perspective",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E9%80%8F%E8%A7%86%E7%9B%B8%E6%9C%BAperspective"
    },
    {
      "depth": 4,
      "text": "正交相机(Orthographic)",
      "anchor": "正交相机orthographic",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E6%AD%A3%E4%BA%A4%E7%9B%B8%E6%9C%BAorthographic"
    },
    {
      "depth": 3,
      "text": "属性（Inspector可见）",
      "anchor": "属性inspector可见",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E5%B1%9E%E6%80%A7inspector%E5%8F%AF%E8%A7%81"
    },
    {
      "depth": 4,
      "text": "Clear Flags",
      "anchor": "clear-flags",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#clear-flags"
    },
    {
      "depth": 4,
      "text": "Background:背景色",
      "anchor": "background背景色",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#background%E8%83%8C%E6%99%AF%E8%89%B2"
    },
    {
      "depth": 4,
      "text": "Culling Mask",
      "anchor": "culling-mask",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#culling-mask"
    },
    {
      "depth": 4,
      "text": "Projection",
      "anchor": "projection",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#projection"
    },
    {
      "depth": 4,
      "text": "Clipping Planes",
      "anchor": "clipping-planes",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#clipping-planes"
    },
    {
      "depth": 4,
      "text": "ViewportRect",
      "anchor": "viewportrect",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#viewportrect"
    },
    {
      "depth": 4,
      "text": "Depth",
      "anchor": "depth",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#depth"
    },
    {
      "depth": 4,
      "text": "Rendering Path",
      "anchor": "rendering-path",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#rendering-path"
    },
    {
      "depth": 4,
      "text": "Target Texture",
      "anchor": "target-texture",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#target-texture"
    },
    {
      "depth": 4,
      "text": "Occlusion Culling（遮挡剔除）",
      "anchor": "occlusion-culling遮挡剔除",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#occlusion-culling%E9%81%AE%E6%8C%A1%E5%89%94%E9%99%A4"
    },
    {
      "depth": 4,
      "text": "其他",
      "anchor": "其他",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E5%85%B6%E4%BB%96"
    },
    {
      "depth": 3,
      "text": "属性（Inspector不可见）",
      "anchor": "属性inspector不可见",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E5%B1%9E%E6%80%A7inspector%E4%B8%8D%E5%8F%AF%E8%A7%81"
    },
    {
      "depth": 4,
      "text": "aspect ：Camera视口的宽高比（可获取，可设置）",
      "anchor": "aspect-camera视口的宽高比可获取可设置",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#aspect-camera%E8%A7%86%E5%8F%A3%E7%9A%84%E5%AE%BD%E9%AB%98%E6%AF%94%E5%8F%AF%E8%8E%B7%E5%8F%96%E5%8F%AF%E8%AE%BE%E7%BD%AE"
    },
    {
      "depth": 4,
      "text": "pixelRect",
      "anchor": "pixelrect",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#pixelrect"
    },
    {
      "depth": 3,
      "text": "实用案例",
      "anchor": "实用案例",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E5%AE%9E%E7%94%A8%E6%A1%88%E4%BE%8B"
    },
    {
      "depth": 4,
      "text": "cameraToWorldMatrix : 变换矩阵",
      "anchor": "cameratoworldmatrix-变换矩阵",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#cameratoworldmatrix-%E5%8F%98%E6%8D%A2%E7%9F%A9%E9%98%B5"
    },
    {
      "depth": 4,
      "text": "CullingMask设置",
      "anchor": "cullingmask设置",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#cullingmask%E8%AE%BE%E7%BD%AE"
    },
    {
      "depth": 4,
      "text": "eventMask属性（待研究）",
      "anchor": "eventmask属性待研究",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#eventmask%E5%B1%9E%E6%80%A7%E5%BE%85%E7%A0%94%E7%A9%B6"
    },
    {
      "depth": 4,
      "text": "LayerCullDistances:层消隐的距离",
      "anchor": "layerculldistances层消隐的距离",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#layerculldistances%E5%B1%82%E6%B6%88%E9%9A%90%E7%9A%84%E8%B7%9D%E7%A6%BB"
    },
    {
      "depth": 4,
      "text": "layerCullSpherical:基于球面距离剔除",
      "anchor": "layercullspherical基于球面距离剔除",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#layercullspherical%E5%9F%BA%E4%BA%8E%E7%90%83%E9%9D%A2%E8%B7%9D%E7%A6%BB%E5%89%94%E9%99%A4"
    },
    {
      "depth": 4,
      "text": "Shader相关",
      "anchor": "shader相关",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#shader%E7%9B%B8%E5%85%B3"
    },
    {
      "depth": 4,
      "text": "更多",
      "anchor": "更多",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E6%9B%B4%E5%A4%9A"
    },
    {
      "depth": 2,
      "text": "编辑器模式下修改屏幕分辨率",
      "anchor": "编辑器模式下修改屏幕分辨率",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E7%BC%96%E8%BE%91%E5%99%A8%E6%A8%A1%E5%BC%8F%E4%B8%8B%E4%BF%AE%E6%94%B9%E5%B1%8F%E5%B9%95%E5%88%86%E8%BE%A8%E7%8E%87"
    },
    {
      "depth": 2,
      "text": "屏幕比例与摄像机设置",
      "anchor": "屏幕比例与摄像机设置",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E5%B1%8F%E5%B9%95%E6%AF%94%E4%BE%8B%E4%B8%8E%E6%91%84%E5%83%8F%E6%9C%BA%E8%AE%BE%E7%BD%AE"
    },
    {
      "depth": 3,
      "text": "宽高比（aspect）",
      "anchor": "宽高比aspect",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E5%AE%BD%E9%AB%98%E6%AF%94aspect"
    },
    {
      "depth": 3,
      "text": "可见区域形状",
      "anchor": "可见区域形状",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#%E5%8F%AF%E8%A7%81%E5%8C%BA%E5%9F%9F%E5%BD%A2%E7%8A%B6"
    },
    {
      "depth": 4,
      "text": "Perspective",
      "anchor": "perspective",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#perspective"
    },
    {
      "depth": 4,
      "text": "Orthographic",
      "anchor": "orthographic",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#orthographic"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/unity-camera-screen/#ref"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "Unity中的“Camera & Screen”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#unity"
    }
  ],
  "contentMarkdown": "# Camera & Screen\n> 创建时间：2020/7/21 14:55\n\n## Camera & Screen\n\n  * Camera & Screen\n    * Screen\n    * Camera\n      * View Frustum(视锥体)相关参数图解\n        * 透视相机(Perspective)\n        * 正交相机(Orthographic)\n      * 属性（Inspector可见）\n        * Clear Flags\n        * Background:背景色\n        * Culling Mask\n        * Projection\n        * Clipping Planes\n        * ViewportRect\n        * Depth\n        * Rendering Path\n        * Target Texture\n        * Occlusion Culling（遮挡剔除）\n        * 其他\n      * 属性（Inspector不可见）\n        * aspect ：Camera视口的宽高比（可获取，可设置）\n        * pixelRect\n      * 实用案例\n        * cameraToWorldMatrix : 变换矩阵\n        * CullingMask设置\n        * eventMask属性（待研究）\n        * LayerCullDistances:层消隐的距离\n        * layerCullSpherical:基于球面距离剔除\n        * Shader相关\n        * 更多\n    * 编辑器模式下修改屏幕分辨率\n    * 屏幕比例与摄像机设置\n      * 宽高比（aspect）\n      * 可见区域形状\n        * Perspective\n        * Orthographic\n    * Ref\n\n## Screen\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n## Camera\n\n### View Frustum(视锥体)相关参数图解\n\n#### 透视相机(Perspective)\n\n![Alt text](assets/20180524230527942.jpg)\n\n![Alt text](assets/20180524232513244.jpg)\n\nnearClipPalneHeight(近截平面的高)=2*Near*tan(FOV/2)\nfarClipPlaneHeight(远截平面)=2*Far*tan(FOV/2)\nAspect(摄像机的纵横比)=nearClipPlaneWidth/nearClipPalneHeight=farClipPlaneWidth/farClipPlaneHeight\n\n#### 正交相机(Orthographic)\n\n![Alt text](assets/20180524230615918.jpg)\n\n![Alt text](assets/20180524231957314.jpg)\n\nnearClipPlaneHeight=2*Size\nfarClipPlaneHeight=nearClipPlaneHeight\nAspect=nearClipPlaneHeight/farClipPlaneWidth=nearClipPlaneHeight/nearClipPalneWidth\n\n### 属性（Inspector可见）\n\n#### Clear Flags\n\n清除标识：确定了屏幕哪些部分将被清除，方便多个摄像机画不同的游戏元素\n\nSkybox ：\n天空盒：这是默认设置。屏幕上的任何空的部分将显示当前相机的天空盒。\n如果当前的相机没有设置天空盒，它会默认在渲染设置（Render Settings ）选择天空盒\nSolid Color ：\n纯色，屏幕上的空白部分将显示当前摄像机的背景色\nDepth Only ：\n深度相机，只渲染采集到的画面\n如果你想绘制一个玩家的枪，又不让它内部环境被裁剪，你会设置深度为0的相机绘制环境，\n和另一个深度为1的相机单独绘制武器。武器相机的清除标志（Clear Flags ）应设置 为depth only。\nDon’t Clear ：\n不清除，此模式不清除颜色或深度缓存。每帧的渲染画面叠加在上一帧画面之上。\n\n#### Background:背景色\n\n#### Culling Mask\n\nCulling Mask:包含或省略要由相机呈现的对象层。在检查器中将图层分配给您的对象。\nNothing:什么层都不剔除\nEverything:什么层都剔除\nDefault:默认层剔除\nTransparentFX:隐形层,系统不会渲染贴图和模型\nIgnore Raycast:射线层剔除\nWater:水层剔除\nUI：UI层剔除\n\n原理：\n清除标记至少与渲染管线的两个步骤有关：深度测试和颜色混合。屏幕上每一个像素都至少有两个信息， **颜色信息** 和 **深度信息** ，当新的一帧的像素信息在屏幕呈现之前，先会将 **上一帧的缓存信息清除** 某些部分（或者不清除任何信息），然后和 **剩下的信息做深度测试和颜色混合得到最终结果** （还有其他步骤，这里只讨论着两个），把结果放在帧缓存区并显示在屏幕上。\n\n深入理解见：<https://blog.csdn.net/mingyi2106/article/details/81606959>\n\n#### Projection\n\n切换相机的功能来模拟透视。\n\nPerspective(透视): 相机将完整地呈现透视物体。拍摄角度为0-180°（最高）\n透视模式下，有远小近大的效果。呈现3D效果\n**Field of View** : 设置为“透视”时，“相机”的视口大小。\n\nOrthographic(正交): 相机将统一渲染对象，没有视角。注：正交模式下不支持延迟渲染。正向渲染总是被使用。\n物体在视口的代销只与正交视口的大小有关，与摄像机到物体的距离无关，主要呈现2D效果。\n**Size** :设置为“正交”时，“相机”的视口大小。\n\northographic :摄像机投影模式。若值为true,正交模式，反之投影模式。\n\n#### Clipping Planes\n\n剪切平面，从相机到开始和停止渲染的距离。\nNear ：相对于相机的最近点将出现绘图。\nFar ：相对于相机的最远点将出现绘图。\n\n#### ViewportRect\n\n视口矩形 四个值指示屏幕上的相机视图将被绘制的位置。在视口坐标中测量（值为0-1）。\n\n#### Depth\n\n相机的位置按照画图顺序。具有较大值的相机将被绘制在具有较小值的相机之上。\n\n#### Rendering Path\n\n渲染路径 ：定义什么绘制方法被用于相机的选项\nUse Graphics Settings 使用玩家设置：在玩家设置（Player Settings.）相机使用哪个渲染路径。\nForward 用正向光照渲染：所有对象每材质渲染只渲染一次,快速渲染。基于着色器的渲染路径。支持逐像素计算光照（包括法线贴图和灯光Cookies）和来自一个平行光的实时阴影。\nDeferred 延迟照明：所有物体将在无光照的环境渲染一次，然后在渲染队列尾部将物体的光照一起渲染出来。支持实时阴影，计算消耗大，对硬件要求高，不支持移动设备，仅专业版可用。\nLegacy Vertex Lit :使用顶点光照。最低消耗的渲染路径，不支持实时阴影，适用于移动及老式设备。\nLegacy Deferred : 旧的延迟光照\n\n#### Target Texture\n\n目标纹理:渲染纹理 （Render Texture）包含相机视图输出。这会使相机渲染在屏幕上的能力被禁止。可用于实现画中画或者画面特效。\n\n#### Occlusion Culling（遮挡剔除）\n\n是否剔除物体背向摄像机的部分\n\n#### 其他\n\n  * Allow HDR:高动态光照渲染，启动相机高动态范围渲染功能。让场景更真实。\n\n  * Allow MSAA: 这台相机应该使用MSAA渲染目标吗？如果当前质量设置MSAA级别支持，将只使用MSAA。\n\n  * Allow Dynamic Resolution：动态分辨率缩放。\n如果相机使用动态分辨率渲染，则为true，否则为false。即使此属性为true，动态分辨率也只能在当前图形设备支持的情况下使用。\n\n  * Target Display:设置此摄像机的目标显示。\n此设置使摄像机呈现在指定的显示中。显示器（例如监视器）支持的最大数目是8.\n\n### 属性（Inspector不可见）\n\n#### aspect ：Camera视口的宽高比（可获取，可设置）\n\n获取或者设置Camera视口的宽高比例值。例如：camera.aspect =2.0f,则视口的宽度、高度 = 2.0f，当硬件显示器屏幕的宽度与高度比例不为2.0f时,视图的显示将会发生变形。aspect只处理摄像机camera可以看到的视图的宽高比例，而硬件显示屏的作用只是把摄像机camera看到的内容显示出来，当硬件显示屏的宽高比例与aspect的比例值不同时，视图将发生变形。\n\n#### pixelRect\n\n设置Camera被渲染到屏幕中的坐标位置。以实际像素大小来设置显示视口的位置。如下图：A为原始平面大小，B为变换后的视口大小，则X0的值为视口右移的像素大小，Y0的值为视口上移的像素大小，w为Camera.pixelWidth,h的值为Camera.pixelHeight。这里要注意：Screen.width和Screen.height为模拟硬件屏幕的宽高值，不随Camera.pixelWidth和Camera.pixelHeight的改变而改变。\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n### 实用案例\n\n#### cameraToWorldMatrix : 变换矩阵\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n#### CullingMask设置\n\nCullingMask 按层渲染，此属性用于按层（GameObject.layer）有选择性地渲染场景中的物体。通过cullingMask可以使得当前摄像机有选择性地渲染场景中的部分物体，默认cullingMask =-1即渲染场景中的任何物体，cullingMask = 0时不渲染场景中的任何物体。若只渲染2,3,4，可以使用cullingMask = （1<<2）+ (1<<3)+(1<<4)来进行。\n\n#### eventMask属性（待研究）\n\n按层响应事件，选择哪个层（layer）的物体可以响应鼠标事件\n\n必须满足两个条件：\n\n  1. 物体在摄像机的视野范围内。\n\n  2. 在2的layer次方的值与eventMask进行运算（&）后结果仍为2的layer次方的值，如：defalult ,layer值为0，2的0次方=1，如果1与eventMask进行与运算后扔为1，则此物体响应鼠标事件。由于EventMask为奇数时，与1的与运算结果都为1，所以若物体层为defalut并且eventMask为奇数时物体会响应鼠标事件。\n\n如果想要多个不同层的物体响应鼠标事件，则需要把所有层的2的layer次方值相加，再与eventMask做与运算。例如，2个物体，layer值分贝为1,3，当event与9进行与运算后结果仍为9，则这两个物体都会响应鼠标事件。\n\n此属性有一个特殊情况，但固体layer选择IgnoreRaycast(其为系统内置，值为2)时，无论EventMask值为多少，物体都无法响应鼠标事件。\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n#### LayerCullDistances:层消隐的距离\n\n摄像机可以通过基于层（GameObject.layer）的方式来设置不同层物体的消隐距离，但这个距离必须小于或者等于摄像机的farClipPlane才有效。\n\n#### layerCullSpherical:基于球面距离剔除\n\n基于球面距离的剔除方式。属性默认为false，即不使用球面剔除，表示只要有一点没有超出物体所在层的远视口平面，物体就是可见的。当设置此属性为True时，只要物体的世界坐标点Position与摄像机的距离大于所在层的剔除距离，物体就不可见。\n\n#### Shader相关\n\n  * RenderWithShader:使用其他shader渲染\n使用指定shader来代替当前物体的shader渲染一帧。当replacementTag为空时会替换视口中所有物体的shader\n\n  * SetReplacementShader 使用指定的shader来替换物体当前的shader,被替换后每一帧都会替换shader来渲染物体,与上面的方法刚好不同。\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n#### 更多\n\n见：<https://www.jianshu.com/p/547ef7f4a313>\n\n## 编辑器模式下修改屏幕分辨率\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n## 屏幕比例与摄像机设置\n\n### 宽高比（aspect）\n\nScreen.witdh和Screen.heigh表示模拟硬件设备的宽高值，不受camera等相关组件在软件层面的代码影响。\nUnity在Screen界面可以设置Screen的比例和像素，但是没有提供相应的接口用代码设置屏幕比例，因为硬件的屏幕就是不可设置的。\n\n**aspect** ：获取和设置屏幕的 **宽高比** 。\n\nViewport Rect：视口框。指的是在Screen上，显示图像的方框。X、Y为偏移值，W、H为实际视口宽/高与Screen宽/高的比例值。\n\naspect默认和screen的宽高比保持一致，摄像机渲染的图像填满screen。\n当Viewport Rect宽高比发生变化时，aspect与之保持一致。\n即默认情况下，aspect是由屏幕的宽高比以及Viewport Rect一起决定的。\n\n当在脚本中手动更改aspect的值时，aspect的值即为手动设置的值，相机的宽高比也就是人手动设置的。\n\n此时，Viewport宽高比不变，相机会把自己的视口当中的图像渲染到Viewport当中，由于宽高比不一致会导致变形。\n\n### 可见区域形状\n\n#### Perspective\n\n透视视图下，可见区域是一个四棱台。\nAspect决定了宽高比，即棱台上下底、截面的宽高比。\nField of View：相机视野角度，由FOV Axis确定的轴向上的角度值(degree)\n\n> 宽高比决定了，改变Field of View，视口截面的形状会成比例缩放。从角度的层面来看，棱台的侧棱与高之间的夹角随FoV的变大而变大，直观来看，就是视角的放大与缩小。\n>  （调整Screen或Viewport或aspect，只能改变相机视口的宽度，不能改变高度，就是因为Field of View把高度值定死了）\n>  Clipping Planes：剪裁面片，指的是可视区域棱台的上下底面 距离camera坐标点的位置（近截面和远截面）\n\n以上所有参数，共同决定了camera可见范围的形状以及它与屏幕渲染的图像的关系。\n\n> **aspect值在代码中设置过一次，就会固定。如果没有设置过，就默认与Screen宽高比一致。**\n\n#### Orthographic\n\n较容易理解。size参数相当于Perspective模式下的FoV。\n\n摄像机高度 = 摄像机orthographicSize * 2\n摄像机实际宽度 = 摄像机高度 * 屏幕宽高比\n摄像机实际宽度 = 摄像机orthographicSize * 2 * 屏幕宽高比\n\n## Ref\n\n<https://www.cnblogs.com/unity-carry/p/9512662.html>\n<https://www.jianshu.com/p/547ef7f4a313>\n<https://www.jianshu.com/p/95cb4621206e>\n"
}
