欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

程序员文章站 2022-04-08 21:49:33
《UnityAPI.Camera摄像机》版本作者参与者完成日期备注UnityAPI_Camera_V01_1.0严立钻2020.05.15......

《UnityAPI.Camera摄像机》

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

版本

作者

参与者

完成日期

备注

UnityAPI_Camera_V01_1.0

严立钻

 

2020.05.15

 

 

 

 

 

 

 

#《UnityAPI.Camera摄像机》发布说明:

++++“UnityAPI.Camera摄像机是对UnityAPICamera类的剖析和拓展

立钻哥哥:Unity是一个入门快、提高难的游戏引擎,想要提升能力,至少需要越过3道坎:API+Shader+综合能力

++1、API的积累:API的合理利用不仅可以减轻自己的编码负担,而且往往可以提高程序的运行效率;这也是钻哥开始“Unity API”独立打造分类的初衷

++2、Shader编程:想要做出一款精品游戏往往需要有高效的Shader的支持;Unity提供了一套改良的“Shader Lab”系统,优化了繁杂的“Open GL”编程

++3、综合能力(技术+业务+管理):一款产品的制作除了功能编程外,往往会涉及很多其他领域,例如产品架构、UI交互设计、模型制作等,作为主要的编程人员,对其他相关领域的了解程序往往会影响到产品制作直至最后的产品体验

++++立钻哥哥一直在推动【VR云游戏=Unity+SteamVR+云技术+5G+AI,这个只是一个引子,抛砖引玉让大家对整个知识体系有一个明确的落地方向,宝宝们可以根据自己的兴趣方向进行拓展:比如Unity这里是指一种“3D游戏引擎”,也可拓展至“UE4Cocos2dx”等游戏引擎;SteamVR是一种跨硬件解决方案,也可拓展至“VRTK”等第三方插件;“云技术+5G”是一种跨平台解决方案的核心技术,同样可拓展至其他平台解决方案;AI也是一种先进技术的举例,也可以拓展至任何一种前沿技术

 

 

@@提示:有些博客可能只是开了头,如果感兴趣的同学,可以“点赞”或“评论区留言”,只要关注的同学多了,那就会继续完善哟!(“++==”,表示没有写完的,如果关注度不高就不完善了;“++ok++”,表示此篇博客已经完成,是阶段性完整的!)

 

$$$$博客溯源:

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

++++VR云游戏=Unity+SteamVR+云技术+5G+AI;(说明:AI人工智能不是我们的主要研究技术,只是了解一下,领略一下有风的感觉!但是,VR是我们的研究重点

++++【Unity开发基础】分类:https://blog.csdn.net/vrunsoftyanlz/category_7309057.html

++++【Linux系统编程】分类:https://blog.csdn.net/vrunsoftyanlz/category_9694767.html

++++【C++C铸就生存利器】分类:https://blog.csdn.net/vrunsoftyanlz/category_9325802.html

++++【人工智能AI2026】分类:https://blog.csdn.net/vrunsoftyanlz/category_9212024.html

++++【立钻哥哥CSDN空间】:https://blog.csdn.net/VRunSoftYanlz/

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

 

 

 

 

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

#Camera摄像机

#Camera摄像机

#Camera摄像机

++A1、Description描述

++B2、Variables变量

++C3、Public Function共有函数

++D4、Message消息

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

 

 

 

#A1、Description描述

#A1、Description描述

++A1、Description描述

++++立钻哥哥:Camera(摄像机)是一个设备,玩家通过它看世界

++++[namespace]:UnityEngine

++++[Inherits from]:Behaviour

++++屏幕空间点(Screen Space Point)用像素定义,屏幕的左下为(0,0);右上是(PixelWidth, pixelHeight)Z的位置是以世界单位衡量的到相机的距离

++++视口空间点(Viewport Space Point)是规范的并相对于相机的;相机的左下为(0,0),右上是(1,1)Z的位置是以世界为单位衡量的到相机的距离

++++世界空间点(World Space Point)是以全局坐标定义的(例如:Transform.position

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++[Unity快速入门]:https://blog.csdn.net/VRunSoftYanlz/article/details/105776475

++++[UnityAPI目录]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533906

++++[Application应用]:https://blog.csdn.net/VRunSoftYanlz/article/details/106086327

++++[Object对象]:https://blog.csdn.net/VRunSoftYanlz/article/details/106202194

++++[GameObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106223815

++++[MonoBehaviour]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533256

++++[Component组件]:https://blog.csdn.net/VRunSoftYanlz/article/details/106367004

++++[Camera摄像机]:https://blog.csdn.net/VRunSoftYanlz/article/details/106148837

++++[Shader着色器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106321040

++++[Material材质]:https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++[Physics物理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106268062

++++[RaycastHit]:https://blog.csdn.net/VRunSoftYanlz/article/details/106292370

++++[ParticleSystem]:https://blog.csdn.net/VRunSoftYanlz/article/details/106341995

++++[WWW万维网]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412890

++++[LineRenerer]:https://blog.csdn.net/VRunSoftYanlz/article/details/106306388

++++[WheelCollider]:https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++[MovieTexture]:https://blog.csdn.net/VRunSoftYanlz/article/details/106434063

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

 

 

 

 

 

 

#B2、Static Variables静态变量

#B2、Static Variables静态变量

++B2、Static Variables静态变量

++++B2.1、allCameras

++++B2.2、allCamerasCount

++++B2.3、current

++++B2.4、main

++++B2.5、YanlzAPI.Camera.StaticVariables

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

++B2.1、allCameras

++B2.1、allCameras

++B2.1、allCameras

++++立钻哥哥:所有摄像机

static Camera[] allCameras;

++++返回场景中所有启用的相机

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public int camCount = Camera.allCameras.Length;

 

    void MyTestFunc(){

        Debug.Log(立钻哥哥:Weve got:  + camCount +  cameras!);

    }

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++B2.2、allCamerasCount

++B2.2、allCamerasCount

++B2.2、allCamerasCount

++++立钻哥哥:所有摄像机数量

static int allCamerasCount;

++++当前场景中摄像机数量

++++返回Camera.allCameras数组的长度即场景中所有摄像机的数量

 

 

 

 

 

++B2.3、current

++B2.3、current

++B2.3、current

++++立钻哥哥:当前摄像机

static Camera current;

++++当前用于渲染的摄像机,只用于低级的渲染控制(只读)

++++多数时候会使用Camera.main,只有在执行以下事件的时候使用这个函数:MonoBehaviour.OnRenderImage, MonoBehaviour.OnPreRender, MonoBehaviour.OnPostRender

 

 

 

 

 

++B2.4、main

++B2.4、main

++B2.4、main

++++立钻哥哥:主摄像机

static Camera main;

++++第一个启用的被标记为“MainCamera”的摄像机(只读)

++++如果场景中没有摄像机返回null

 

 

 

 

 

 

 

#C3、Variables变量

#C3、Variables变量

++C3、Variables变量

++++C3.1、actualRenderingPath

++++C3.2、aspect

++++C3.3、backgroundColor

++++C3.4、cameraToWorldMatrix

++++C3.5、clearFlags

++++C3.6、cullingMask

++++C3.7、depth

++++C3.8、depthTextureMode

++++C3.9、eventMask

++++C3.10、farClipPlane

++++C3.11、fieldOfView

++++C3.12、hdr

++++C3.13、layerCullDistances

++++C3.14、layerCullSpherical

++++C3.15、nearClipPlane

++++C3.16、orthographic

++++C3.17、orthographicSize

++++C3.18、pixelHeight

++++C3.19、pixelRect

++++C3.20、pixelWidth

++++C3.21、projectionMatrix

++++C3.22、rect

++++C3.23、renderingPath

++++C3.24、stereoConvergence

++++C3.25、stereoEnabled

++++C3.26、stereoSeparation

++++C3.27、targetTexture

++++C3.28、transparencySortMode

++++C3.29、useOcclusionCulling

++++C3.30、velocity

++++C3.31、worldToCameraMatrix

++++C3.32、YanlzAPI.Camera.Variables

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

++C3.1、actualRenderingPath

++C3.1、actualRenderingPath

++C3.1、actualRenderingPath

++++立钻哥哥:实际渲染路径

RenderingPath actualRenderingPath;

++++实际使用的渲染路径(只读

 

 

 

 

 

++C3.2、aspect

++C3.2、aspect

++C3.2、aspect

++++立钻哥哥:长宽比

float aspect;

++++长宽比(宽度除以高度)

++++默认的长宽比是从屏幕的长宽比计算得到的,即使摄像机没有被渲染到全屏;如果修改了摄像机的aspect比,这个值会一直保持到调用camera.ResetAspect(),这将重置长宽比为屏幕的长宽比

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        if(camera.aspect > 1.0F){

            Debug.Log(立钻哥哥:Screen is more wide than tall!);

        }else{

            Debug.Log(立钻哥哥:Screen is more tall than wide!);

        }

    }    //立钻哥哥:void MyTestFunc(){}

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.3、backgroundColor

++C3.3、backgroundColor

++C3.3、backgroundColor

++++立钻哥哥:背景颜色

Color backgroundColor;

++++屏幕将被清理为这个颜色

++++只在clearFlags被设置为CameraClearFlags.SolidColor(或者设置为CameraClearFlags.Skybox但是没有设置天空盒)

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Color color1 = Color.red;

    public Color color2 = Color.blue;

    public float duration = 3.0F;

 

    void Update(){

        float t = Mathf.PingPong(Time.time, duration) / duration;

        camera.backgroundColor = Color.Lerp(color1, color2, t);

    }

 

    void MyTestFunc(){

        camera.clearFlags = CameraClearFlags.SolidColor;

    }

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.4、cameraToWorldMatrix

++C3.4、cameraToWorldMatrix

++C3.4、cameraToWorldMatrix

++++立钻哥哥:摄像机转世界矩阵

Matrix4x4 cameraToWorldMatrix;

++++从摄像机空间到世界空间的变换矩阵(只读

++++使用这个来计算摄像机空间中的一个点在世界坐标中的什么位置上

++++注意:摄像机空间与OpenGL的约定:摄像机的前面为Z轴负方向;这不同于Unity的约定,向前为Z轴正向

++++[Matrix4x4矩阵]:https://blog.csdn.net/VRunSoftYanlz/article/details/106504027

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public float distance = -1.0F;

 

    void OnDrawGizmosSelected(){

        Matrix4x4 m = camera.cameraToWorldMatrix;

        Vector3 p = m.MultiplyPoint(new Vector3(0, 0, distance));

        Gizmos.color = Color.yellow;

        Gizmos.DrawSphere(p, 0.2F);

    }    //立钻哥哥:void OnDrawGizmosSelected(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.5、clearFlags

++C3.5、clearFlags

++C3.5、clearFlags

++++立钻哥哥:清除标识(可理解为背景填充)

CameraClearFlags clearFlags;

++++摄像机如何清除背景

++++CameraClearFlags.SolidColor(用单色填充背景),CameraClearFlags.Depth(背景透明),CameraClearFlags.Nothing(覆盖)

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.clearFlags = CameraClearFlags.SolidColor;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.6、cullingMask

++C3.6、cullingMask

++C3.6、cullingMask

++++立钻哥哥:消隐遮罩

int cullingMask;

++++这个用来选择性的渲染部分场景

++++如果GameObjectlayerMask与相机的cullingMask进行cullingMask操作后为0,那么这个游戏物体对于该摄像机是不可见的

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public void Awake(){

        camera.cullingMask = 1 << 0;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.7、depth

++C3.7、depth

++C3.7、depth

++++立钻哥哥:深度

float depth;

++++摄像机在渲染顺序上的深度

++++具有较低深度的摄像机将在较高深度的摄像机之前渲染

++++如果有多个摄像机并且其中一些不需要覆盖整个屏幕,可以使用这个来控制摄像机的绘制次序

++++经验总结:场景中的摄像机都会被渲染,由深度0开始依次递增渲染,且摄像机视口画面会依次叠加覆盖,运行后看到的是最后一个摄像机的渲染图

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.depth = Camera.man.depth + 1;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.8、depthTextureMode

++C3.8、depthTextureMode

++C3.8、depthTextureMode

++++立钻哥哥:深度纹理模式

DepthTextureMode depthTextureMode;

++++摄像机生成怎样的一个深度纹理

++++摄像机可以建立一个屏幕空间深度纹理;这个主要用于图像后台处理效果;注意:生成纹理导致性能的花费

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public void Awake(){

        camera.depthTextureMode = DepthTextureMode.DepthNormals;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.9、eventMask

++C3.9、eventMask

++C3.9、eventMask

++++立钻哥哥:事件遮挡

int eventMask;

++++遮挡相机的触发事件图层

++++正如cullingMask确定摄像机是否能够看到游戏对象,事件遮挡决定游戏物体是否能够接受鼠标事件;只有摄像机可见的对象,并且该对象遮挡层与摄像机的eventMask重叠,能够接受onMouseXXX事件;如果不使用OnMouseXXX事件,建议将此遮挡设置为零将会提高性能

 

 

 

 

 

++C3.10、farClipPlane

++C3.10、farClipPlane

++C3.10、farClipPlane

++++立钻哥哥:远裁剪平面

float farClipPlane;

++++远裁剪面的距离

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.farClipPlane = 100.0F;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.11、fieldOfView

++C3.11、fieldOfView

++C3.11、fieldOfView

++++立钻哥哥:视野

float fieldOfView;

++++摄像机的视野,以度为单位

++++这是垂直视野:水平FOV取决于视口的高度比,当摄像机是正交时fieldOfView被忽略

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public void Awake(){

        camera.fieldOfView = 60;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

//立钻哥哥:使用主相机的例子

using UnityEngine;

using System.Collections;

 

public class YanlzMinCamera : MonoBehaviour{

    void MyTestFunc(){

        Camera.main.filedOfView = 80;

    }

}    //立钻哥哥:public class YanlzMainCamera{}

 

 

 

 

 

++C3.12、hdr

++C3.12、hdr

++C3.12、hdr

++++立钻哥哥:高动态范围

bool hdr;

++++高动态范围渲染

++++摄像机应该使用高动态范围渲染吗

 

 

 

 

 

++C3.13、layerCullDistances

++C3.13、layerCullDistances

++C3.11、fieldOfView

++++立钻哥哥:视野

float fieldOfView;

++++摄像机的视野,以度为单位

++++这是垂直视野:水平FOV取决于视口的高度比,当摄像机是正交时fieldOfView被忽略

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public void Awake(){

        camera.fieldOfView = 60;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

//立钻哥哥:使用主相机的例子

using UnityEngine;

using System.Collections;

 

public class YanlzMinCamera : MonoBehaviour{

    void MyTestFunc(){

        Camera.main.filedOfView = 80;

    }

}    //立钻哥哥:public class YanlzMainCamera{}

 

 

 

 

 

++C3.12、hdr

++C3.12、hdr

++C3.12、hdr

++++立钻哥哥:高动态范围

bool hdr;

++++高动态范围渲染

++++摄像机应该使用高动态范围渲染吗

 

 

 

 

 

++C3.13、layerCullDistances

++C3.13、layerCullDistances

++C3.13、layerCullDistances

++++立钻哥哥:层消隐距离

float[] layerCullDistances;

++++每层的消隐距离

++++通常摄像机跳过渲染对象是远于farClipPlane,可以使用layerCullDistances设置某些层使用较小消隐距离,如果把它们放到合适的层级,这对于早期剔除一些小的物体对象是非常有用的

++++当分配layerCullDistances,需要指定的float数组有32个值;0值的消隐距离是使用远剪裁屏幕距离

++++默认情况下,每层的消隐将会使用一个平面与摄像机对齐;改变这个领域可设置摄像机上的layercullspherical

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void Start(){

        float[] distances = new float[32];

        distances[10] = 15;

        camera.layerCullDistances = distances;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.14、layerCullSpherical

++C3.14、layerCullSpherical

++C3.14、layerCullSpherical

++++立钻哥哥:球面层消隐

bool layerCullSpherical;

++++摄像机如何执行每层的消隐

++++通常这种类型的消隐是通过移动摄像机的远平面接近眼睛执行;通过将该值设置为true,基于球面距离消隐;好处是:在原地旋转不影响可见对象

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.layerCullSpherical = true;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.15、nearClipPlane

++C3.15、nearClipPlane

++C3.15、nearClipPlane

++++立钻哥哥:近裁剪平面

float nearClipPlane;

++++近裁剪面的距离

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.nearClipPlane = 0.1F;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.16、orthographic

++C3.16、orthographic

++C3.16、orthographic

++++立钻哥哥:正交

bool orthographic;

++++摄像机是正交的(true),是透视的(false)?

++++如果为true,摄像机的视野由orthographicSize定义;如果为flase,摄像机的视野由fieldOfView定义

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.orthographic = true;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

//立钻哥哥:主摄像机应用

using UnityEngine;

using System.Collections;

 

public class YanlzMainCamera : MonoBehaviour{

    void MyTestFunc(){

        Camera.main.orthographic = true;

    }

}    //立钻哥哥:public class YanlzMainCamera{}

 

 

 

 

 

++C3.17、orthographicSize

++C3.17、orthographicSize

++C3.17、orthographicSize

++++立钻哥哥:正交大小

float orthographicSize;

++++正交大小

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.orthographic = true;

        camera.orthographicSize = 5;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

//立钻哥哥:主摄像机

using UnityEngine;

using System.Collections;

 

public class YanlzMainCamera : MonoBehaviour{

    void MyTestFunc(){

        Camera.main.orthographic = true;

        Camera.main.orthographicSize = 5;

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.18、pixelHeight

++C3.18、pixelHeight

++C3.18、pixelHeight

++++立钻哥哥:摄像机高度

float pixelHeight;

++++摄像机有多高,以像素单位(只读

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        Debug.Log(立钻哥哥:Camera is  + camera.pixelHeight +  pixels high!);

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.19、pixelRect

++C3.19、pixelRect

++C3.19、pixelRect

++++立钻哥哥:像素矩形

Rect pixelRect;

++++摄像机被渲染到屏幕像素中的位置

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void Update(){

        Rect r = camera.pixelRect;

        Debug.Log(立钻哥哥:Camera display from  + r.xMin +  to  + r.xMax +  pixel.);

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.20、pixelWidth

++C3.20、pixelWidth

++C3.20、pixelWidth

++++立钻哥哥:摄像机宽度

float pixelWidth;

++++摄像机有多宽,以像素单位(只读

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        Debug.Log(立钻哥哥:Camera is  + camera.pixelWidth +  pixels wide.);

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.21、projectionMatrix

++C3.21、projectionMatrix

++C3.21、projectionMatrix

++++立钻哥哥:投影矩阵

Matrix4x4 projectionMatrix;

++++设置自定义的投影矩阵

++++如果改变这个矩阵,摄像机的渲染不再基于它的fieldOfView更新,直到调用ResetProjectionMatrix

++++只有当真正需要一个非标准的投影时,才使用自定义投影;这个属性被Unity的水渲染使用来设置一个[oblique projection]矩阵;使用自定义投影需要了解变换和投影矩阵

++++[Matrix4x4矩阵]:https://blog.csdn.net/VRunSoftYanlz/article/details/106504027

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Matrix4x4 originalProjection;

 

    void Update(){

        Matrix4x4 p = originalProjection;

        p.m01 += Mathf.Sin(Time.time * 1.2F) * 0.1F;

        p.m10 += Mathf.Sin(Time.time * 1.5F) * 0.1F;

        camera.projectionMatrix = p;

    }    //立钻哥哥:void Update(){}

 

    void MyTestFunc(){

        originalProjection = camera.projectionMatrix;

    }

 

}    //立钻哥哥:public class YanlzCamera{}

 

using UnityEngine;

using System.Collections;

 

[ExecuteInEditMode]

public class YanlzCamera : MonoBehaviour{

    public float left = -0.2F;

    public float right = 0.2F;

    public float top = 0.2F;

    public float bottom = -0.2F;

 

    void LeteUpdate(){

        Camera cam = camera;

        Matrix4x4 m = MyPerspectiveOffCenter(left, right, bottom, top, cam.nearClipPlane, cam.farClipPlane);

        cam.projectionMatrix = m;

    }

 

    static Matrix4x4 MyPerspectiveOffCenter(float left, float right, float bottom, float top, float near, float far){

        float x = 2.0F * near / (right - left);

        float y = 2.0F * near / (top - bottom);

        float a = (right + left) / (right - left);

        float b = (top + bottom) / (top - bottom);

        float c = -(far + near) / (far - near);

        float d = -(2.0F * far * near) / (far - near);

        float e = -1.0F;

 

        Matrix4x4 m = new Matrix4x4();

        m[0, 0] = x;

        m[0, 1] = 0;

        m[0, 2] = a;

        m[0, 3] = 0;

        m[1, 0] = 0;

        m[1, 1] = y;

        m[1, 2] = b;

        m[1, 3] = 0;

        m[2, 0] = 0;

        m[2, 1] = 0;

        m[2, 2] = c;

        m[2, 3] = d;

        m[3, 0] = 0;

        m[3, 1] = 0;

        m[3, 2] = e;

        m[3, 3] = 0;

 

        return m;

    }    //立钻哥哥:static Matrix4x4 MyPerspectiveOffCenter(){}

    

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.22、rect

++C3.22、rect

++C3.22、rect

++++立钻哥哥:矩形

Rect rect;

++++相继被渲染到屏幕规范化坐标中的位置

++++Rect的范围总是0(左/下)到1(右/上)

//立钻哥哥:Change the width of the viewport each time space key is pressed

function Update(){

    if(Input.GetButtonDown(Jump)){

        //choose the margin randomly

        var margin = RandomRange(0.0, 0.3);

 

        //setup the rectangle

        camera.rect = Rect(margin, 0, 1, -margin * 2, 1);

    }

}    //立钻哥哥:function Update(){}

 

 

 

 

 

++C3.23、renderingPath

++C3.23、renderingPath

++C3.23、renderingPath

++++立钻哥哥:渲染路径

RenderingPath renderingPath;

++++渲染路径

 

 

 

 

 

++C3.24、stereoConvergence

++C3.24、stereoConvergence

++C3.24、stereoConvergence

++++立钻哥哥:立体聚焦

float stereoConvergence;

++++虚拟视点相交点间距

 

 

 

 

 

++C3.25、stereoEnabled

++C3.25、stereoEnabled

++C3.25、stereoEnabled

++++立钻哥哥:开启立体

bool stereoEnabled;

++++立体渲染

++++该摄像机的渲染是否是从虚拟视点作为一个立体输出的摄像机

 

 

 

 

 

++C3.26、stereoSeparation

++C3.26、stereoSeparation

++C3.26、stereoSeparation

++++立钻哥哥:立体分离

float stereoSeparation;

++++虚拟眼间距离

 

 

 

 

 

++C3.27、targetTexture

++C3.27、targetTexture

++C3.27、targetTexture

++++立钻哥哥:目标纹理

RenderTexture targetTexture;

++++描述渲染纹理(仅Unity专业版)

++++在Unity专业版,可以创建一个渲染纹理应用给摄像机,然后摄像机视图渲染到RenderTexture,可以保存为PNG或使用它作为一个雷达,或简单显示场景缩略图在GUI

 

 

 

 

 

++C3.28、transparencySortMode

++C3.28、transparencySortMode

++C3.28、transparencySortMode

++++立钻哥哥:透明物体排序模式

TransparencySortMode transparencySortMode;

++++透明物体的排序模式

++++默认情况下,透明摄像机排序对象是基于从摄像机的位置到对象中心的距离;和正交摄像机排序是基于沿视线方向的距离

++++如果使用透视摄像机制作2D游戏,会使用TransparencySortMode.Orthographic排序模式以便对象是基于相机的视线排序

 

 

 

 

 

++C3.29、useOcclusionCulling

++C3.29、useOcclusionCulling

++C3.29、useOcclusionCulling

++++立钻哥哥:使用遮挡剔除

bool useOcclusionCulling;

++++无论是否在渲染过程中摄像机都会使用遮挡剔除

 

 

 

 

 

++C3.30、velocity

++C3.30、velocity

++C3.30、velocity

++++立钻哥哥:速度

Vector3 velocity;

++++获取世界空间中摄像机的速度(只读

++++该摄像机是自上一帧以秒为单位的运动

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void Update(){

        Debug.Log(立钻哥哥:Camera moving at  + camera.velocity.magnitude +  m/s.);

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++C3.31、worldToCameraMatrix

++C3.31、worldToCameraMatrix

++C3.31、worldToCameraMatrix

++++立钻哥哥:世界转摄像机矩阵

Matrix4x4 worldToCameraMatrix;

++++从世界到摄像机空间的变换矩阵

++++用这个计算物体的摄像机空间位置或提供自定义的位置,这个位置不是基于变换的

++++注意:摄像机空间和OpenGL的约定相匹配,摄像机的前面为Z轴负方向,这不同于Unity的约定,向前为Z轴正向

++++如果改变这个矩阵,摄像机的渲染不再基于它的Transform更新,直到调用ResetWorldToCameraMatrix

++++[Matrix4x4矩阵]:https://blog.csdn.net/VRunSoftYanlz/article/details/106504027

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Vector3 offset = new Vector3(0, 1, 0);

 

    void LateUpdate(){

        Vector3 camOffset = new Vector3(-offset.x, -offset.y, offset.z);

        Matrix4x4 m = Matrix4x4.TRS(camOffset, Quaternion.identity, new Vector3(1, 1, -1));

 

        camera.worldToCameraMatrix = m * transform.worldToLocalMatrix;

    }    //立钻哥哥:void LateUpdate(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

 

 

#D4、Functions函数

#D4、Functions函数

++D4、Function函数

++++D4.1、CalculateObliqueMatrix

++++D4.2、CopyFrom

++++D4.3、Render

++++D4.4、RenderToCubemap

++++D4.5、RenderWithShader

++++D4.6、ResetAspect

++++D4.7、ResetProjectionMatrix

++++D4.8、RestReplacementShader

++++D4.9、RestWorldToCameraMatrix

++++D4.10、ScreenPointToRay

++++D4.11、ScreenToViewportPoint

++++D4.12、ScreenToWorldPoint

++++D4.13、SetReplacementShader

++++D4.14、setTargetBuffers

++++D4.15、ViewportPointToRay

++++D4.16、ViewPortToScreenPoint

++++D4.17、ViewportToWorldPoint

++++D4.18、WorldToScreenPoint

++++D4.19、WorldToViewportPoint

++++D4.20、YanlzAPI.Camera.Functions

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

++D4.1、CalculateObliqueMatrix

++D4.1、CalculateObliqueMatrix

++D4.1、CalculateObliqueMatrix

++++立钻哥哥:计算倾斜矩阵

Matrix4x4 CalculateObliqueMatrix(Vector4 clipPlane);

++++[clipPlane]:Vector4描述剪切平面

++++计算并返回倾斜接近水平的投影矩阵

++++给定一个剪辑平面向量,该函数返回摄像机的投影矩阵,投影矩阵的这个剪辑平面设置为它的*面

++++[Matrix4x4矩阵]:https://blog.csdn.net/VRunSoftYanlz/article/details/106504027

 

 

 

 

 

++D4.2、CopyFrom

++D4.2、CopyFrom

++D4.2、CopyFrom

++++立钻哥哥:复制到

void CopyFrom(Camera other);

++++使这个摄像机的设置与其他摄像机相同

++++这将从其他摄像机拷贝所有的摄像机变量(视野、清除标识、消隐遮罩),这也将设置摄像机的变换与其他摄像机相同,摄像机的层也与其他摄像机相同

++++在做自定义渲染效果的时候,这可以用来设置一台具有与其他摄像机设置完全相同的摄像机,例如在使用RenderWithShader

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.CopyFrom(Camera.main);

    }

}     //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.3、Render

++D4.3、Render

++D4.3、Render

++++立钻哥哥:渲染

void Render();

++++手动渲染摄像机

++++这个将渲染摄像机,这将使用摄像机的清除标记,目标纹理和所有其他设置

++++摄像机将发送OnPreCullOnPreCullOnPreRender等到任何附加的脚本上,并渲染任何最后的图像滤镜

++++这个用来精确地控制渲染次序,为了使用这个特性,创建一个摄像机并禁用它,然后在它上面调用Render

++++从一个正在渲染的摄像机调用Render函数是不允许的,如果需要可以先创建一个相匹配摄像机的副本

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

 

    Texture2D MyRTImage(Camera cam){

        RenderTexture currentRT = RenderTexture.active;

        RenderTexture.active = cam.targetTexture;

 

        cam.Render();

 

        Texture2D image = new Texture2D(cam.targetTexture.width, cam.targetTexture.height);

        image.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0);

        image.Apply();

 

        RenderTexture.active = currentRT;

 

        return image;

    }    //立钻哥哥:Texture2D MyRTImage(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.4、RenderToCubemap

++D4.4、RenderToCubemap

++D4.4、RenderToCubemap

++++立钻哥哥:渲染到立方图

bool RenderToCubemap(Cubemap cubemap, int faceMask = 63);

bool RenderToCubemap(RenderTexture cubemap, int faceMask = 63);

++++从这个摄像机渲染到一个立方贴图

++++这是非常有用的,可以在编辑器中烘焙场景的静态立方贴图

++++摄像机的位置,清除标志和裁剪面距离将被使用来渲染到立方贴图表面,FaceMask是一比特域,表示那个立方贴图面应该被渲染,每个位对应于一个面;比特数是Cubemapface枚举的整型值;默认的所有六个立方贴图都被渲染(默认值63的低6位是打开的)

++++如果渲染失败这个函数将返回false,某些显卡不支持这个函数

++++注意:这是一个Unity专业版属性

 

 

 

 

 

++D4.5、RenderWithShader

++D4.5、RenderWithShader

++D4.5、RenderWithShader

++++立钻哥哥:Shader渲染

void RenderWithShader(Shader shader, string replacementTag);

++++用Shader替代渲染摄像机

++++这个将渲染摄像机,这将使用摄像机的清除标记,目标设置为其他所有设置

++++这个摄像机不会发送OnPreCullOnPreRenderOnPostRender到附加的脚本,图像滤镜也不会被渲染

++++这个可用于特效,例如整个场景屏幕空间缓冲,热效率等等;为了使用这个特性,创建一个摄像机并禁用它,然后在它上面调用RenderWithShader

++++对一个正在渲染的摄像机调用Render函数是不允许的;如果想这么做可以拷贝一个匹配的副本摄像机

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Shader heatVisionShader;

 

    void MyTestFunc(){

        camera.RenderWithShader(heatVisionShader, YanlzShaderVisibleWithHeat);

    }

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.6、ResetAspect

++D4.6、ResetAspect

++D4.6、ResetAspect

++++立钻哥哥:重设长宽比

void ResetAspect();

++++恢复长宽比为屏幕的长宽比

++++调用这个结束aspect设置的效果

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.ResetAspect();

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.7、ResetProjectionMatrix

++D4.7、ResetProjectionMatrix

++D4.7、ResetProjectionMatrix

++++立钻哥哥:重设投影矩阵

void ResetProjectionMatrix();

++++让投影反映正常的摄像机参数

++++调用将结束projectionMatrix设置的效果

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void MyTestFunc(){

        camera.ResetProjectionMatrix();

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.8、RestReplacementShader

++D4.8、RestReplacementShader

++D4.8、RestReplacementShader

++++立钻哥哥:重设替换Shader

void ResetReplacementShader();

++++从摄像机上移除Shader替换

++++调用将结束SetReplacementShader设置的效果

 

 

 

 

 

++D4.9、RestWorldToCameraMatrix

++D4.9、RestWorldToCameraMatrix

++D4.9、RestWorldToCameraMatrix

++++立钻哥哥:重设世界转摄像机矩阵

void ResetWorldToCameraMatrix();

++++在场景中让渲染位置反射摄像机的位置

++++调用将结束worldToCameraMatrix设置的效果

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    camera.ResetWorldToCameraMatrix();

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.10、ScreenPointToRay

++D4.10、ScreenPointToRay

++D4.10、ScreenPointToRay

++++立钻哥哥:屏幕位置转射线

Ray ScreenPointToRay(Vector3 position);

++++返回一条射线从摄像机通过一个屏幕点

++++产生的射线是在世界空间中,从相机的近裁剪面开始并穿过屏幕position(x,y)像素坐标(position.z被忽略)

++++屏幕空间以像素定义;屏幕的左下为(0,0);右上是(pixelWidth, pixelHeight);

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void Update(){

        Ray ray = camera.ScreenPointToRay(new Vector3(200, 200, 0));

        Debug.Log(ray.orgin, ray.direction * 10, Color.yellow);

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.11、ScreenToViewportPoint

++D4.11、ScreenToViewportPoint

++D4.11、ScreenToViewportPoint

++++立钻哥哥:屏幕转视窗位置

Vector3 ScreenToViewportPoint(Vector3 position);

++++从屏幕空间到视窗空间的变换位置

++++屏幕空间以像素定义;屏幕的左下为(0,0);右上是(pixelWidth, pixelHeight)Z的位置是以世界单位衡量的到摄像机的距离

++++视口空间是规范化的并相对于摄像机;摄像机的左下为(0,0);右上是(1,1)Z的位置是以世界单位衡量的到摄像机的距离

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    void Update(){

        transform.position = Camera.main.ScreenToViewportPoint(Input.mousePosition);

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.12、ScreenToWorldPoint

++D4.12、ScreenToWorldPoint

++D4.12、ScreenToWorldPoint

++++立钻哥哥:屏幕转世界位置

Vector3 ScreenToWorldPoint(Vector3 position);

++++从屏幕空间到世界空间的变化位置

++++屏幕空间以像素定义;屏幕的左下为(0,0);右上是(pixelWidth, pixelHeight)Z的位置是以世界单位衡量的到摄像机的距离

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

 

    void OnDrawGizmosSelected(){

        Vector3 p = camera.ScreenToWorldPoint(new Vector3(100, 100, camera.nearClipPlane));

        Gizmos.color = Color.yellow;

        Gizmos.DrawSphere(p, 0.1F);

    }    //立钻哥哥:void OnDrawGizmosSelected(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.13、SetReplacementShader

++D4.13、SetReplacementShader

++D4.13、SetReplacementShader

++++立钻哥哥:设置替换着色器

void SetReplacementShader(Shader shader, string replacementTag);

++++使摄像机渲染用着色器替换

++++调用这个函数之后,摄像机将使用替换的Shader来渲染它的视图;调用ResetReplacementShader来重置回普通的渲染

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Shader heatVisionShader;

 

    void MyTestFunc(){

        camera.SetReplacementShader(heatVisionShader, YanlzShaderVisibleWithHeat);

    }

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.14、setTargetBuffers

++D4.14、setTargetBuffers

++D4.14、setTargetBuffers

++++立钻哥哥:设置目标缓冲区域

void SetTargetBuffers(RenderBuffer colorBuffer, RenderBuffer depthBuffer);

void SetTargetBuffers(RenderBuffer[] colorBuffer, RenderBuffer depthBufffer);

++++[colorBuffer]:渲染缓存的颜色信息将被渲染

++++[depthBuffer]:渲染缓存的深度信息将被渲染

++++设置摄像机渲染到一个或多个RenderTextures所选择的缓冲区

 

 

 

 

 

++D4.15、ViewportPointToRay

++D4.15、ViewportPointToRay

++D4.15、ViewportPointToRay

++++立钻哥哥:视窗位置转射线

Ray ViewportPointToRay(Vector3 position);

++++返回从摄像机出发穿过视点的一个射线

++++产生的射线是在世界空间中,从摄像机的近裁剪面开始并穿过视口POSITION(x,y)坐标(position.z被忽略)

++++视窗坐标被规范化,并相对于摄像机;摄像机的左下为(0,0);右上是(1,1)

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

 

    void Update(){

        Ray ray = camera.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));

        RaycastHit hit;

 

        if(Physics.Raycast(ray, out hit)){

            Debug.Log(立钻哥哥:Im looking at  + hit.transform.name);

        }else{

            Debug.Log(立钻哥哥:Im looking at nothing.);

        }

    }    //立钻哥哥:void Update(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.16、ViewPortToScreenPoint

++D4.16、ViewPortToScreenPoint

++D4.16、ViewPortToScreenPoint

++++立钻哥哥:视窗转屏幕位置

Vector3 ViewportToScreenPoint(Vector3 position);

++++从视口空间到屏幕空间的变换位置

++++视口空间是规范化的并相对于摄像机;摄像机的左下为(0,0),右上是(1.1)Z的位置是以世界单位衡量的到摄像机的距离

++++屏幕空间以像素定义;屏幕的左下为(0,0);右上是(pixelWidth, pixelHeight)Z的位置是以世界单位衡量的到摄像机的距离

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Texture2D bottomPanel;

 

    void MyTestVPToScreenPt(){

        Vector3 origin = Camera.main.ViewportToScreenPoint(new Vector3(0.25F, 0.1F, 0));

        Vector3 extent = Camera.main.ViewportToSceenPoint(new Vector3(0.5F, 0.2F, 0));

 

        GUI.DrawTexture(new Rect(origin.x, origin.y, extent.x, extent.y), bottomPanel);

    }    //立钻哥哥:void MyTestVPToScreenPt(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.17、ViewportToWorldPoint

++D4.17、ViewportToWorldPoint

++D4.17、ViewportToWorldPoint

++++立钻哥哥:视窗转世界位置

Vector3 ViewportToWorldPoint(Vector3 position);

++++从视窗空间到世界空间的变换位置

++++视窗空间是归一化的并相对于摄像机的,摄像机的左下为(0,0);右上是(1,1)Z的位置是以世界单位衡量的到摄像机的距离

++++请注意:它是变换一个x-y屏幕位置到一个3D空间的x-y-z位置

++++这个函数带有在屏幕坐标的x-y组件向量,并且z组件是在从摄像机产生的平面的距离

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    

    void OnDrawGizmosSelected(){

        Vector3 p = camera.ViewportToWorldPoint(new Vector3(1, 1, camera.nearClipPlane));

        Gizmos.color = Color.yellow;

        Gizmos.DrawSphere(p, 0.1F);

    }    //立钻哥哥:void OnDrawGizmosSelected(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.18、WorldToScreenPoint

++D4.18、WorldToScreenPoint

++D4.18、WorldToScreenPoint

++++立钻哥哥:世界转屏幕位置

Vector3 WorldToScreenPoint(Vector3 position);

++++从世界空间到屏幕空间变换位置

++++屏幕空间以像素定义,屏幕左下为(0,0),右上是(pixelWidth, pixelHeight)Z的位置是以世界单位衡量的到相机的距离

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Transform target;

 

    void Update(){

        Vector3 screenPos = camera.WorldToScreenPoint(target.position);

        Debug.Log(立钻哥哥:target is  + screenPos.x +  pixels from the left.);

    }    //立钻哥哥:void Update(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++D4.19、WorldToViewportPoint

++D4.19、WorldToViewportPoint

++D4.19、WorldToViewportPoint

++++立钻哥哥:世界转视窗位置

Vector3 WorldToViewportPoint(Vector3 position);

++++从世界空间到视窗空间的变换位置

++++视窗空间是归一化的并相对于摄像机的;摄像机的左下为(0,0);右上是(1,1)Z的位置是以世界单位衡量的到摄像机的距离

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Transform target;

 

    void Update(){

        Vector3 viewPos = camera.WorldToViewportPoint(target, position);

 

        if(viewPos.x > 0.5F){

            Debug.Log(立钻哥哥:target is on the right side!);

        }else{

            Debug.Log(立钻哥哥:target is on the left side!);

        }

    }    //立钻哥哥:void Update(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

 

 

#E5、Staic Functions函数

#E5、Static Functions函数

++E5、Static Functions函数

++++E5.1、GetAllCameras

++++E5.2、YanlzAPI.Camera.StaticFunctions

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

++E5.1、GetAllCameras

++E5.1、GetAllCameras

++E5.1、GetAllCameras

++++立钻哥哥:获取所有摄像机

static int GetAllCameras(Camera[] cameras);

++++[cameras]:用当前场景中的摄像机填补摄像机的数组

++++用当前场景中的摄像机填补摄像机的数组,而不需要分配一个新的数组

++++数组的大小必须大于allCamerasCount的值

++++当数组的大小大于了allCamerasCount的值,只有第一个元素到allCamerasCount值将会被填入数组

++++当数组的大小小于了allCamerasCount的值,将抛出参数异常

++++当数组传递的参数是空,此次调用将会抛出未将对象引用到实例

++++返回值将会显示多少摄像机放入了这个数组

 

 

 

 

 

 

 

#F6、Message消息

#F6、Message消息

++F6、Message消息

++++F6.1、OnPostRender

++++F6.2、OnPreCull

++++F6.3、OnRenderImage

++++F6.4、OnRenderObject

++++F6.5、OnWillRenderObject

++++F6.6、YanlzAPI.Camera.Message

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

++F6.1、OnPostRender

++F6.1、OnPostRender

++F6.1、OnPostRender

++++立钻哥哥:渲染之后

Camera.OnPostRender();

++++OnPostRender函数在摄像机渲染场景之后调用

++++这个消息被发送到所有附加在摄像机的脚本

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    private bool revertFogState = false;

 

    void OnPreRender(){

        revertFogState = RenderSettings.fog;

        RenderSettings.fog = enabled;

    }    //立钻哥哥:void OnPreRender(){}

 

    void OnPostRender(){

        RenderSettings.fog = revertFogState;

    }    //立钻哥哥:void OnPostRender(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++F6.2、OnPreCull

++F6.2、OnPreCull

++F6.2、OnPreCull

++++立钻哥哥:消隐之前

Camera.OnPreCull();

++++OnPreCell在摄像机开始裁剪场景之前调用

++++裁剪决定哪个物体对于摄像机来说是可见的;OnPreCell仅仅在这个过程之间被调用,这个消息被发送到所有附加在摄像机上的脚本

++++如果想改变摄像机的视觉参数(例如:fieldOfView或者仅仅是变换),就在这里做这个,场景物体的可见性将基于摄像机的参数在OnPreCell之后确定

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    

    void OnPreCell(){

        camera.ResetWorldToCameraMatrix();

        camera.ResetProjectionMatrix();

        camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(new Vector3(1, -1, 1));

    }    //立钻哥哥:void OnPreCell(){}

 

    void OnPreRender(){

        GL.SetRevertBackfacing(true);

    }    //立钻哥哥:void OnPreRender(){}

 

    void OnPostRender(){

        GL.SetRevertBackfacing(false);

    }    //立钻哥哥:void OnPostRender(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++F6.3、OnRenderImage

++F6.3、OnRenderImage

++F6.3、OnRenderImage

++++立钻哥哥:在渲染图像之后

Camera.OnRenderImage(RenderTexture source, RenderTexture destination);

++++OnRenderImage在所有渲染完成后被调用,来渲染图片的后期处理效果(仅限UnityPro

++++这允许使用基于Shader的过滤器来处理最后的图片,进入的图片时Source渲染纹理,结果是Destination渲染纹理;当有多个图片过滤器附加在摄像机上时,它们序列化的处理图片,将第一个过滤器的目标作为下一个过滤器的源

++++这个消息被发送到所有附加在摄像机上的脚本

using UnityEngine;

using System.Collections

 

public class YanlzCamera : MonoBehaviour{

    public Material mat;

 

    void OnRenderImage(RenderTexture src, RenderTexture dest){

        Graphics.Blit(src, dest, mat);

    }    //立钻哥哥:void OnRenderImage(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++F6.4、OnRenderObject

++F6.4、OnRenderObject

++F6.4、OnRenderObject

++++立钻哥哥:在渲染物体之后

Camera.OnRenderObject();

++++OnRenderObject被用来渲染自己的物体,使用或者其他函数

++++该函数被用来渲染自己的物体,使用Graphics.DrawMeshNow或者其他函数;这个函数类似于OnPostRender,除了OnRenderObject在任意物体有一个脚本带有这个函数被调用,不论是否它附加到摄像机或没有

using UnityEngine;

using System.Collections;

 

public class YanlzCamera : MonoBehaviour{

    public Mesh mainMesh;

    public Mesh miniMapMesh;

 

    void OnRenderObject(){

        if(Camera.current.name == MiniMapcam){

            Graphics.DrawMeshNow(miniMapMesh, transform.position, transform.rotation);

        }else{

            Graphics.DrawMeshNow(mainMesh, transform.position, transform.rotation);

        }

    }    //立钻哥哥:void OnRenderObject(){}

 

}    //立钻哥哥:public class YanlzCamera{}

 

 

 

 

 

++F6.5、OnWillRenderObject

++F6.5、OnWillRenderObject

++F6.5、OnWillRenderObject

++++立钻哥哥:在渲染物体之前

Camera.OnWillRenderObject();

++++如果物体可见,每个摄像机都会调用OnWillRenderObject;

++++如果对象是被视为可见的从当前摄像机消隐过程后,这个函数被调用;该方法是很有用的,如果需要为每一个摄像机准备步骤渲染对象;一个例子是:渲染反射到一个渲染图片,这个反射将会不同于每个摄像机的视窗,且需要被渲染在原来的对象之前;如果对象被一个给定的摄像机剔除,该对象将被跳过反射

++++注意:Camera.current将被设置为要渲染这个物体的相机

 

 

 

 

 

 

 

 

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

++G7、立钻哥哥对Camera类的拓展

++G7、立钻哥哥对Camera类的拓展

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++[Unity快速入门]:https://blog.csdn.net/VRunSoftYanlz/article/details/105776475

++++[UnityAPI目录]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533906

++++[Application应用]:https://blog.csdn.net/VRunSoftYanlz/article/details/106086327

++++[Object对象]:https://blog.csdn.net/VRunSoftYanlz/article/details/106202194

++++[GameObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106223815

++++[MonoBehaviour]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533256

++++[Component组件]:https://blog.csdn.net/VRunSoftYanlz/article/details/106367004

++++[Camera摄像机]:https://blog.csdn.net/VRunSoftYanlz/article/details/106148837

++++[Shader着色器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106321040

++++[Material材质]:https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++[Physics物理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106268062

++++[RaycastHit]:https://blog.csdn.net/VRunSoftYanlz/article/details/106292370

++++[ParticleSystem]:https://blog.csdn.net/VRunSoftYanlz/article/details/106341995

++++[WWW万维网]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412890

++++[LineRenerer]:https://blog.csdn.net/VRunSoftYanlz/article/details/106306388

++++[WheelCollider]:https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++[MovieTexture]:https://blog.csdn.net/VRunSoftYanlz/article/details/106434063

++++[Matrix4x4矩阵]:https://blog.csdn.net/VRunSoftYanlz/article/details/106504027

++++[Renerer渲染器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106481994

++++[AudioSource]:https://blog.csdn.net/VRunSoftYanlz/article/details/106462679

++++[AudioClip]:https://blog.csdn.net/VRunSoftYanlz/article/details/106448955

++++[Texture纹理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106448589

++++[AssetBundle]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412190

++++[ScriptableObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106392769

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

 

 

 

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

@@提示:有些博客可能只是开了头,如果感兴趣的同学,可以“点赞”或“评论区留言”,只要关注的同学多了,那就会继续完善哟!(“++==”,表示没有写完的,如果关注度不高就不完善了;“++ok++”,表示此篇博客已经完成,是阶段性完整的!)

 

 

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

++++VR云游戏=Unity+SteamVR+云技术+5G+AI;(说明:AI人工智能不是我们的主要研究技术,只是了解一下,领略一下有风的感觉!但是,VR是我们的研究重点

++++【Unity开发基础】分类:https://blog.csdn.net/vrunsoftyanlz/category_7309057.html

++++【Linux系统编程】分类:https://blog.csdn.net/vrunsoftyanlz/category_9694767.html

++++【C++C铸就生存利器】分类:https://blog.csdn.net/vrunsoftyanlz/category_9325802.html

++++【人工智能AI2026】分类:https://blog.csdn.net/vrunsoftyanlz/category_9212024.html

++++【立钻哥哥CSDN空间】:https://blog.csdn.net/VRunSoftYanlz/

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

 

 

 

 

 

【XR游戏开发QQ群:784477094

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

++立钻哥哥推荐的拓展学习链接(Link_Url)

立钻哥哥推荐的拓展学习链接(Link_Url)

++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz/

++++虚拟现实VR资讯: https://blog.csdn.net/VRunSoftYanlz/article/details/89165846

++++HTC_VIVE开发基础https://blog.csdn.net/VRunSoftYanlz/article/details/81989970

++++Oculus杂谈https://blog.csdn.net/VRunSoftYanlz/article/details/82469850

++++Oculus安装使用https://blog.csdn.net/VRunSoftYanlz/article/details/82718982

++++Unity+SteamVR=>VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/88809370

++++Unity减少VR晕眩症https://blog.csdn.net/VRunSoftYanlz/article/details/89115518

++++SteamVR简介https://blog.csdn.net/VRunSoftYanlz/article/details/86484254

++++SteamVR脚本功能分析https://blog.csdn.net/VRunSoftYanlz/article/details/86531480

++++SteamVR2.0开发指南https://blog.csdn.net/VRunSoftYanlz/article/details/86618187

++++SteamVR2.2.0开发指南https://blog.csdn.net/VRunSoftYanlz/article/details/88784527

++++SteamVR2.2.0快速入门https://blog.csdn.net/VRunSoftYanlz/article/details/88833579

++++SteamVR2.2.0交互系统https://blog.csdn.net/VRunSoftYanlz/article/details/89199778

++++SteamVR2.2.0传送机制https://blog.csdn.net/VRunSoftYanlz/article/details/89390866

++++SteamVR2.2.0教程(一)https://blog.csdn.net/VRunSoftYanlz/article/details/89324067

++++SteamVR2.2.0教程(二)https://blog.csdn.net/VRunSoftYanlz/article/details/89894097

++++SteamVR_Skeleton_Poserhttps://blog.csdn.net/VRunSoftYanlz/article/details/89931725

++++SteamVR实战之PMCorehttps://blog.csdn.net/VRunSoftYanlz/article/details/89463658

++++SteamVR/Extrashttps://blog.csdn.net/VRunSoftYanlz/article/details/86584108

++++SteamVR/Inputhttps://blog.csdn.net/VRunSoftYanlz/article/details/86601950

++++OpenXR简介https://blog.csdn.net/VRunSoftYanlz/article/details/85726365

++++VRTK杂谈https://blog.csdn.net/VRunSoftYanlz/article/details/82562993

++++VRTK快速入门(杂谈)https://blog.csdn.net/VRunSoftYanlz/article/details/82955267

++++VRTK官方示例(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82955410

++++VRTK代码结构(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82780085

++++VRTK(SceneResources)https://blog.csdn.net/VRunSoftYanlz/article/details/82795400

++++VRTK_ControllerEventshttps://blog.csdn.net/VRunSoftYanlz/article/details/83099512

++++VRTK_InteractTouchhttps://blog.csdn.net/VRunSoftYanlz/article/details/83120220

++++虚拟现实行业应用https://blog.csdn.net/VRunSoftYanlz/article/details/88360157

++++Steam平台上的VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/88960085

++++Steam平台热销VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/89007741

++++VR实验:以太网帧的构成https://blog.csdn.net/VRunSoftYanlz/article/details/82598140

++++实验四:存储器扩展实验https://blog.csdn.net/VRunSoftYanlz/article/details/87834434

++++FrameVR示例V0913https://blog.csdn.net/VRunSoftYanlz/article/details/82808498

++++FrameVR示例V1003https://blog.csdn.net/VRunSoftYanlz/article/details/83066516

++++SwitchMachineV1022https://blog.csdn.net/VRunSoftYanlz/article/details/83280886

++++PlaySceneManagerV1022https://blog.csdn.net/VRunSoftYanlz/article/details/83280886

++++Unity5.x用户手册https://blog.csdn.net/VRunSoftYanlz/article/details/81712741

++++Unity面试题ABChttps://blog.csdn.net/vrunsoftyanlz/article/details/78630687

++++Unity面试题Dhttps://blog.csdn.net/VRunSoftYanlz/article/details/78630838

++++Unity面试题Ehttps://blog.csdn.net/vrunsoftyanlz/article/details/78630913

++++Unity面试题Fhttps://blog.csdn.net/VRunSoftYanlz/article/details/78630945

++++Cocos2dx面试题https://blog.csdn.net/VRunSoftYanlz/article/details/78630967

++++禅道[zentao]https://blog.csdn.net/VRunSoftYanlz/article/details/83964057

++++Lua快速入门篇(Xlua拓展):https://blog.csdn.net/VRunSoftYanlz/article/details/81173818

++++Lua快速入门篇(XLua教程):https://blog.csdn.net/VRunSoftYanlz/article/details/81141502

++++Lua快速入门篇(基础概述)https://blog.csdn.net/VRunSoftYanlz/article/details/81041359

++++框架知识点https://blog.csdn.net/VRunSoftYanlz/article/details/80862879

++++游戏框架(UI框架夯实篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80781140

++++游戏框架(初探篇)https://blog.csdn.net/VRunSoftYanlz/article/details/80630325

++++.Net框架设计https://blog.csdn.net/VRunSoftYanlz/article/details/87401225

++++从零开始学架构https://blog.csdn.net/VRunSoftYanlz/article/details/88095895

++++设计模式简单整理https://blog.csdn.net/vrunsoftyanlz/article/details/79839641

++++专题:设计模式(精华篇)https://blog.csdn.net/VRunSoftYanlz/article/details/81322678

++++U3D小项目参考https://blog.csdn.net/vrunsoftyanlz/article/details/80141811

++++Unity小游戏算法分析https://blog.csdn.net/VRunSoftYanlz/article/details/87908365

++++Unity案例(Vehicle)https://blog.csdn.net/VRunSoftYanlz/article/details/82355876

++++UML类图https://blog.csdn.net/vrunsoftyanlz/article/details/80289461

++++PowerDesigner简介https://blog.csdn.net/VRunSoftYanlz/article/details/86500084

++++Unity知识点0001https://blog.csdn.net/vrunsoftyanlz/article/details/80302012

++++Unity知识点0008https://blog.csdn.net/VRunSoftYanlz/article/details/81153606

++++U3D_Shader编程(第一篇:快速入门篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80372071

++++U3D_Shader编程(第二篇:基础夯实篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80372628

++++Unity引擎基础https://blog.csdn.net/vrunsoftyanlz/article/details/78881685

++++Unity面向组件开发https://blog.csdn.net/vrunsoftyanlz/article/details/78881752

++++Unity物理系统https://blog.csdn.net/vrunsoftyanlz/article/details/78881879

++++Unity2D平台开发https://blog.csdn.net/vrunsoftyanlz/article/details/78882034

++++UGUI基础https://blog.csdn.net/vrunsoftyanlz/article/details/78884693

++++UGUI进阶https://blog.csdn.net/vrunsoftyanlz/article/details/78884882

++++UGUI综合https://blog.csdn.net/vrunsoftyanlz/article/details/78885013

++++Unity动画系统基础https://blog.csdn.net/vrunsoftyanlz/article/details/78886068

++++Unity动画系统进阶https://blog.csdn.net/vrunsoftyanlz/article/details/78886198

++++Navigation导航系统https://blog.csdn.net/vrunsoftyanlz/article/details/78886281

++++Unity特效渲染https://blog.csdn.net/vrunsoftyanlz/article/details/78886403

++++Unity数据存储https://blog.csdn.net/vrunsoftyanlz/article/details/79251273

++++Unity中Sqlite数据库https://blog.csdn.net/vrunsoftyanlz/article/details/79254162

++++WWW类和协程https://blog.csdn.net/vrunsoftyanlz/article/details/79254559

++++Unity网络https://blog.csdn.net/vrunsoftyanlz/article/details/79254902

++++Unity资源加密https://blog.csdn.net/VRunSoftYanlz/article/details/87644514

++++PhotonServer简介https://blog.csdn.net/VRunSoftYanlz/article/details/86652770

++++编写Photon游戏服务器https://blog.csdn.net/VRunSoftYanlz/article/details/86682935

++++C#事件https://blog.csdn.net/vrunsoftyanlz/article/details/78631267

++++C#委托https://blog.csdn.net/vrunsoftyanlz/article/details/78631183

++++C#集合https://blog.csdn.net/vrunsoftyanlz/article/details/78631175

++++C#泛型https://blog.csdn.net/vrunsoftyanlz/article/details/78631141

++++C#接口https://blog.csdn.net/vrunsoftyanlz/article/details/78631122

++++C#静态类https://blog.csdn.net/vrunsoftyanlz/article/details/78630979

++++C#中System.String类https://blog.csdn.net/vrunsoftyanlz/article/details/78630945

++++C#数据类型https://blog.csdn.net/vrunsoftyanlz/article/details/78630913

++++Unity3D默认的快捷键https://blog.csdn.net/vrunsoftyanlz/article/details/78630838

++++游戏相关缩写https://blog.csdn.net/vrunsoftyanlz/article/details/78630687

++++UnityAPI.Rigidbody刚体https://blog.csdn.net/VRunSoftYanlz/article/details/81784053

++++UnityAPI.Material材质https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++UnityAPI.Android安卓https://blog.csdn.net/VRunSoftYanlz/article/details/81843193

++++UnityAPI.AndroidJNI安卓JNIhttps://blog.csdn.net/VRunSoftYanlz/article/details/81879345

++++UnityAPI.Transform变换https://blog.csdn.net/VRunSoftYanlz/article/details/81916293

++++UnityAPI.WheelCollider轮碰撞器https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++UnityAPI.Resources资源https://blog.csdn.net/VRunSoftYanlz/article/details/83155518

++++JSON数据结构https://blog.csdn.net/VRunSoftYanlz/article/details/82026644

++++CocosStudio快速入门https://blog.csdn.net/VRunSoftYanlz/article/details/82356839

++++Unity企业内训(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82634668

++++Unity企业内训(第1讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82634733

++++Unity企业内训(第2讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82861180

++++Unity企业内训(第3讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82927699

++++Unity企业内训(第4讲)https://blog.csdn.net/VRunSoftYanlz/article/details/83479776

++++Unity企业内训(第5讲)https://blog.csdn.net/VRunSoftYanlz/article/details/83963811

++++Unity企业内训(第6讲)https://blog.csdn.net/VRunSoftYanlz/article/details/84207696

++++钻哥带您了解产品原型https://blog.csdn.net/VRunSoftYanlz/article/details/87303828

++++插件<Obi Rope>https://blog.csdn.net/VRunSoftYanlz/article/details/83963905

++++计算机组成原理(教材篇)https://blog.csdn.net/VRunSoftYanlz/article/details/82719129

++++5G接入:云计算和雾计算https://blog.csdn.net/VRunSoftYanlz/article/details/88372718

++++云计算通俗讲义https://blog.csdn.net/VRunSoftYanlz/article/details/88652803

++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz

--_--VRunSoft:lovezuanzuan--_--

《UnityAPI.Camera摄像机》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+allCameras+cullingMask+OnPreCull+立钻哥哥++OK+)

本文地址:https://blog.csdn.net/VRunSoftYanlz/article/details/106148837