当前位置: 首页>>代码示例>>C#>>正文


C# Camera.CopyFrom方法代码示例

本文整理汇总了C#中UnityEngine.Camera.CopyFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.CopyFrom方法的具体用法?C# Camera.CopyFrom怎么用?C# Camera.CopyFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Camera的用法示例。


在下文中一共展示了Camera.CopyFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Awake

    void Awake()
    {
        if (_map_camera_camera == null){
            //create clipping mask for map;
            _mask = 1 << 23 | 1 << 19;

            //create a new camera;
            _map_camera_camera =  new GameObject("map_camera");
            //add camera and copy attributes of original camera
            _map_camera_camera_component = _map_camera_camera.AddComponent<Camera>();
            _map_camera_camera_component.CopyFrom(camera);
            _map_camera_camera_component.depth = 2;

            _map_camera_camera_component.cullingMask = _mask;
            _map_camera_camera_component.backgroundColor = Color.black;
            _map_camera_camera_component.clearFlags = CameraClearFlags.SolidColor;

            //parent and reset it to original camera;
            _map_camera_camera.transform.rotation = transform.rotation;
            _map_camera_camera.transform.position = transform.position;
            _map_camera_camera.transform.parent = transform;

            //create a new Render Texture for the map pass and assign it to the Camera
            _map_render_texture = new RenderTexture(Screen.width,Screen.height,8,RenderTextureFormat.ARGBHalf);
            _map_render_texture.name = "map_pass";
            _map_camera_camera_component.targetTexture = _map_render_texture;

            //set mask Texture global for all shaders
        Shader.SetGlobalTexture("_map_texture", _map_render_texture);
        }
    }
开发者ID:FabianSchempp,项目名称:DUNDON,代码行数:31,代码来源:_map_camera.cs

示例2: Awake

    void Awake()
    {
        if (_normal_camera == null){
            //create clipping mask for normals;
            _normal_mask =
                    1 << 1 |
                    1 << 2 |
                    1 << 3 |
                    1 << 4 |
                    1 << 5 |
                    1 << 6 |
                    1 << 7 |
                    1 << 8 |
                    1 << 9 |
                    1 << 10 |
                    1 << 11 |
                    1 << 12 |
                    1 << 13 |
                    1 << 14 |
        //				1 << 15 |
        //				1 << 16 |
                    1 << 17 |
        //				1 << 18;
                    1 << 22;

            //create a new camera;
            _normal_camera =  new GameObject("normal_camera");

            //add camera and copy attributes of original camera
            _normal_camera_camera_component = _normal_camera.AddComponent<Camera>();
            _normal_camera_camera_component.CopyFrom(camera);
            _normal_camera_camera_component.depth = -1;
            _normal_camera_camera_component.cullingMask = _normal_mask;

            //add blur shader
            _normal_blur_component = _normal_camera.AddComponent<normal_blur>();

            //set_background to null normal
            _normal_camera_camera_component.clearFlags = CameraClearFlags.SolidColor;
            _normal_camera_camera_component.backgroundColor = new Color(0.5f,0.5f,1.0f);
            _normal_camera_camera_component.camera.depthTextureMode = DepthTextureMode.DepthNormals;

            //sets replacementshader to render normals
            _normal_camera_camera_component.SetReplacementShader(_display_normal_shader,"");

            //parent and reset it to original camera;
            _normal_camera.transform.rotation = transform.rotation;
            _normal_camera.transform.position = transform.position;
            _normal_camera.transform.parent = transform;

            //create a new Render Texture for the normal pass and assign it to the Camera
            _normal_render_texture = new RenderTexture(Screen.width,Screen.height,32,RenderTextureFormat.ARGBHalf);
            _normal_render_texture.name = "normal_pass";
            _normal_camera_camera_component.targetTexture = _normal_render_texture;

            //set normal Texture global for all shaders
            Shader.SetGlobalTexture("_objectNormalTexture", _normal_render_texture);
        }
    }
开发者ID:FabianSchempp,项目名称:DUNDON,代码行数:59,代码来源:normal_camera.cs

示例3: Awake

 void Awake()
 {
     GameObject holyObject = new GameObject("Holy Camera");
     holyObject.transform.SetParent(transform, false);
     Camera mainCam = GetComponent<Camera>();
     holyCam = holyObject.AddComponent<Camera>();
     holyCam.CopyFrom(mainCam);
     holyCam.nearClipPlane = nearClip;
 }
开发者ID:jharger,项目名称:globalgamejam2016,代码行数:9,代码来源:HolyCamera.cs

示例4: Awake

    void Awake()
    {
        //create clipping mask for masks;
        _mask =
        //				1 << 1 |
        //				1 << 2 |
        //				1 << 3 |
        //				1 << 4 |
        //				1 << 5 |
        //				1 << 6 |
        //				1 << 7 |
        //				1 << 8 |
        //				1 << 9 |
        //				1 << 10 |
        //				1 << 11 |
        //				1 << 12 |
        //				1 << 13 |
        //				1 << 14 |
        //				1 << 15 |
        //				1 << 16 |
        //				1 << 17 |
                1 << 18;

        //create a new camera;
        _mask_camera_camera =  new GameObject("mask_camera");

        //add camera and copy attributes of original camera
        _mask_camera_camera_component = _mask_camera_camera.AddComponent<Camera>();
        _mask_camera_camera_component.CopyFrom(camera);
        _mask_camera_camera_component.depth = -2;

        //		//sets replacementshader to render normals
        //		_mask_camera_camera_component.SetReplacementShader(gray_unlit_shader ,"Opaque");

        //set_background to null mask
        _mask_camera_camera_component.clearFlags = CameraClearFlags.SolidColor;
        _mask_camera_camera_component.backgroundColor = new Color(1f,1f,1f);
        _mask_camera_camera_component.cullingMask = _mask;

        //parent and reset it to original camera;
        _mask_camera_camera.transform.rotation = transform.rotation;
        _mask_camera_camera.transform.position = transform.position;
        _mask_camera_camera.transform.parent = transform;

        //set hdr rendering to on
        _mask_camera_camera_component.hdr = true;

        //create a new Render Texture for the mask pass and assign it to the Camera
        _mask_render_texture = new RenderTexture(Screen.width,Screen.height,8,RenderTextureFormat.ARGBHalf);
        _mask_render_texture.name = "mask_pass";
        _mask_camera_camera_component.targetTexture = _mask_render_texture;

        //set mask Texture global for all shaders
        Shader.SetGlobalTexture("_mask_Texture", _mask_render_texture);
    }
开发者ID:FabianSchempp,项目名称:DUNDON,代码行数:55,代码来源:_mask_camera.cs

示例5: SyncCamera

        /// <summary>
        /// Renders the excluded objects to targetTexture
        /// </summary>
        private void SyncCamera(Camera excludeCamera)
        {
            // Copy settings from primary camera.
            excludeCamera.CopyFrom(GetComponent<Camera>());

            // Change Camera Culling Mask, Clear Flags and Depth.
            excludeCamera.cullingMask = m_ExcludeLayers.value;
            excludeCamera.clearFlags = CameraClearFlags.Nothing;
            excludeCamera.depth = excludeCamera.depth + 1;

            // Set parent camera culling mask.
            GetComponent<Camera>().cullingMask = GetComponent<Camera>().cullingMask & ~m_ExcludeLayers.value;
        }
开发者ID:riscvul,项目名称:SCP_Game_Prototype,代码行数:16,代码来源:LOSLayerExcluder.cs

示例6: InitializeCamera

    void InitializeCamera()
    {
        whiteObject = new GameObject();
        cameraWhite = whiteObject.AddComponent<Camera>();
        cameraWhite.CopyFrom(cameraMain);
        cameraWhite.backgroundColor = Color.white;
        whiteObject.transform.SetParent(transform, true);

        blackObject = new GameObject();
        cameraBlack = blackObject.AddComponent<Camera>();
        cameraBlack.CopyFrom(cameraMain);
        cameraBlack.backgroundColor = Color.black;
        blackObject.transform.SetParent(transform, true);
    }
开发者ID:technicalvgda,项目名称:Adagio,代码行数:14,代码来源:CapturePNG.cs

示例7: Awake

 void Awake()
 {
     _attachedCam = GetComponent<Camera>();
     if (_renderGO == null) {
         _renderGO = new GameObject();
         _renderGO.hideFlags = HideFlags.DontSave;
         _renderGO.transform.SetParent(transform, false);
         _renderCam = _renderGO.AddComponent<Camera>();
         _renderCam.CopyFrom(_attachedCam);
         _renderCam.enabled = false;
         _renderCam.clearFlags = CameraClearFlags.Nothing;
     }
     if (_postEffectMat == null) {
         _postEffectMat = new Material(postEffectShader);
         _postEffectMat.hideFlags = HideFlags.DontSave;
     }
     weight = Mathf.Min(0f, weight);
     Shader.SetGlobalFloat("_Weight", (weightEnabled ? weight : 0f));
 }
开发者ID:nobnak,项目名称:BlendedOIT,代码行数:19,代码来源:OIT.cs

示例8: Initialize

 private void Initialize()
 {
     goCamera = new GameObject("RenderTextureCamera");
     cameraInstance = goCamera.AddComponent<Camera>();
     var cam = Camera.main;
     cameraInstance.CopyFrom(cam);
     cameraInstance.depth++;
     cameraInstance.cullingMask = CullingMask;
     cameraInstance.renderingPath = RenderingPath;
     goCamera.transform.parent = cam.transform;
     renderTexture = new RenderTexture(Mathf.RoundToInt(Screen.width * TextureScale), Mathf.RoundToInt(Screen.height * TextureScale), 16, RenderTextureFormat);
     renderTexture.DiscardContents();
     renderTexture.filterMode = FilterMode;
     cameraInstance.targetTexture = renderTexture;
     instanceCameraTransform = cameraInstance.transform;
     oldPosition = instanceCameraTransform.position;
     Shader.SetGlobalTexture("_GrabTextureMobile", renderTexture);
     isInitialized = true;
 }
开发者ID:naskew100,项目名称:Fired-Up,代码行数:19,代码来源:DistortionMobile.cs

示例9: loadSetting

        public void loadSetting(CameraSetting _camSetting)
        {
            if (rt == null)
            {
                camera = this.GetComponent<Camera>();
                Camera mainCamera = GameObject.Find("Main Camera").GetComponent<Camera>();
                camera.CopyFrom(mainCamera);

                resolutionWidth = (int)camera.pixelWidth;
                resolutionHeight = (int)camera.pixelHeight;

                rt = new RenderTexture(resolutionWidth, resolutionHeight, 24);
                camera.targetTexture = rt;
            }

            camSetting = _camSetting;
            camera.transform.position = _camSetting.position;
            Quaternion quat = new Quaternion();
            quat.eulerAngles = new Vector3(-_camSetting.pitch,-_camSetting.yaw,-_camSetting.roll);
            camera.transform.localRotation = quat;
            camera.name = _camSetting.id;
            camera.fieldOfView = _camSetting.fieldOfView;
        }
开发者ID:hybrid1969,项目名称:Polimi-OSM-City-Engine,代码行数:23,代码来源:ControllerCam.cs

示例10: OnStart

    public override void OnStart(StartState state)
    {
        if (state != StartState.Editor)
        {
            nextRenderTime = Time.time + freq;
            Camera sourceNearCam = null;
            Camera sourceFarCam  = null;
            Camera sourceSkyCam  = null;

            foreach (Camera cam in Camera.allCameras) {	if (cam.name == "Camera 00") {sourceNearCam = cam;break;}}
            foreach (Camera cam in Camera.allCameras) {	if (cam.name == "Camera 01") {sourceFarCam = cam;break;}}
            foreach (Camera cam in Camera.allCameras) {	if (cam.name == "Camera ScaledSpace") {sourceSkyCam = cam;break;}}

            var NearCameraGameObject = new GameObject ("GoAtThrottleUp Cam Camera 00");
            NearCamera = NearCameraGameObject.AddComponent<Camera> ();
            NearCamera.CopyFrom (sourceNearCam);
            NearCamera.enabled = false;
            NearCamera.fieldOfView = fovAngle;
            NearCamera.aspect = aspect;

            var FarCameraGameObject = new GameObject ("GoAtThrottleUp Cam Camera 01");
            FarCamera = FarCameraGameObject.AddComponent<Camera> ();
            FarCamera.CopyFrom (sourceFarCam);
            FarCamera.enabled = false;
            FarCamera.fieldOfView = fovAngle;
            FarCamera.aspect = aspect;

            var SkyboxCameraGameObject = new GameObject ("GoAtThrottleUp Cam Camera ScaledSpace");
            SkyboxCamera = SkyboxCameraGameObject.AddComponent<Camera> ();
            SkyboxCamera.transform.position = sourceSkyCam.transform.position;
            SkyboxCamera.CopyFrom (sourceSkyCam);
            SkyboxCamera.enabled = false;
            SkyboxCamera.fieldOfView = fovAngle;
            SkyboxCamera.aspect = aspect;

        }
    }
开发者ID:jmorganc,项目名称:GoAtThrottleUp,代码行数:37,代码来源:GoAtThrottleUpCamera.cs

示例11: Start

	// Use this for initialization
	void Start () 
	{
		if(!SystemInfo.supportsImageEffects)
		{
			enabled = false;
			return;
		}
		
		camera = GetComponent<Camera>();           
		
		//Buffers for mask checking. Not the most elegant solution, but least CPU-intensive - still pretty heavy CPU-wise due to ReadPixels (pipeline break)
		checkBuffer1 = new RenderTexture(512,512,0);
		checkBuffer2 = new RenderTexture(64,64,0);
		checkBuffer3 = new RenderTexture(8,8,0);
		
		checkTexture = new Texture2D(8,8);
		
		//Shaders for mask rendering
		redMaskShader = Shader.Find("Hidden/STS_red_mask");
		redMaskShaderRT = Shader.Find("Hidden/STS_red_mask_RT");
		greenMaskShader = Shader.Find("Hidden/STS_green_mask");
		greenMaskShaderRT = Shader.Find("Hidden/STS_green_mask_RT");
		coloredMaskShader = Shader.Find("Hidden/STS_colored_mask");
		coloredMaskShaderRT = Shader.Find("Hidden/STS_colored_mask_RT");
		
		//Shaders for sfx background rendering
		outlineShader = Shader.Find("See-Through System/Outline");
		hologramShader = Shader.Find("See-Through System/Hologram");
		alphaHologramShader = Shader.Find("See-Through System/Alpha_Hologram");
		
		//for monitoring camera render area resizes
		oldResolution = new Vector2((int)camera.pixelWidth,(int)camera.pixelHeight);
		
		//Creating cameras;
		GameObject obj = new GameObject("STS_mask_camera");
		obj.transform.parent = transform;
		objectsCamera = obj.AddComponent<Camera>();
		objectsCamera.CopyFrom(camera);
		objectsCamera.cullingMask = TriggerLayers;
		objectsCamera.backgroundColor = Color.black;
		objectsCamera.clearFlags = CameraClearFlags.Color;
		objectsCamera.depthTextureMode = DepthTextureMode.None;
		objectsTexture = new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight,24);
		obstaclesTexture = new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight,24);
		if (preserveDepthTexture)
		{
			originalZBuffer =  new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight,0);
			originalZBuffer.format = RenderTextureFormat.RFloat;
		}
		objectsCamera.targetTexture = objectsTexture;
		objectsCamera.enabled = false;
		
		if (backgroundCamera == null)
		{
			obj = new GameObject("STS_background_camera");
			obj.transform.parent = transform;
			backgroundCamera = obj.AddComponent<Camera>();
			backgroundCamera.CopyFrom(camera);
			backgroundCamera.cullingMask = backgroundCamera.cullingMask & (~ObstacleLayers.value);
			backgroundTexture = new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight,24);
			backgroundCamera.depthTextureMode = DepthTextureMode.None;
			backgroundCamera.enabled = false;
		}
		
		backgroundCamera.targetTexture = backgroundTexture;
		satMaterial.SetFloat("_power",1);
	}
开发者ID:HaoYunSun,项目名称:TEMPORAIRE,代码行数:68,代码来源:SeeThroughSystem.cs

示例12: UpdateCameraModes

        protected void UpdateCameraModes(Camera src, Camera dest)
        {
            if (!dest)
            return;

            //set portal camera to act like the current camera

            // This doesn't fully work in all Unity versions work for some reason (I haven't had a good reason to figure out why, either)
            // So we'll start with that, and then make sure things actually work.
            dest.CopyFrom(src);

            //NB: Render to the full frame, irrespective of what the source camera does:
            dest.rect = new Rect(0, 0, 1, 1);

            dest.clearFlags = src.clearFlags;
            dest.backgroundColor = src.backgroundColor;
            if (src.clearFlags == CameraClearFlags.Skybox) {
            Skybox sky = src.GetComponent<Skybox>();
            Skybox mysky = dest.GetComponent<Skybox>();
            if (!sky || !sky.material) {
                mysky.enabled = false;
            } else {
                mysky.enabled = true;
                mysky.material = sky.material;
            }
            }

            // update other values to match current camera.
            // even if we are supplying custom camera & projection matrices,
            // some of values are used elsewhere (e.g. sky box uses far plane)
            dest.farClipPlane = src.farClipPlane;
            dest.nearClipPlane = src.nearClipPlane;
            dest.orthographic = src.orthographic;
            dest.fieldOfView = src.fieldOfView;
            dest.aspect = src.aspect;
            dest.orthographicSize = src.orthographicSize;
        }
开发者ID:mmandel,项目名称:8Nights2,代码行数:37,代码来源:Portal.cs

示例13: OnStart

        public override void OnStart(StartState state)
        {
            if (state != StartState.Editor)
            {
                freq = 1.0f / (float)fps;

                hasParentAntenna = this.vessel.parts.FindAll (thepart => thepart.Modules.Contains ("GATUAntenna")).Count > 0;
                if (!hasParentAntenna) {
                    return;
                }

                nextRenderTime = Time.time + freq;
                Camera sourceNearCam = null;
                Camera sourceFarCam = null;
                Camera sourceSkyCam = null;
                Camera sourceGalaxyCam = null;

                foreach (Camera cam in Camera.allCameras) {
                    if (cam.name == "Camera 00")               { sourceNearCam = cam; }
                    else if (cam.name == "Camera 01")          { sourceFarCam = cam; }
                    else if (cam.name == "Camera ScaledSpace") { sourceSkyCam = cam; }
                    else if (cam.name == "GalaxyCamera")       { sourceGalaxyCam = cam; }
                }

                var NearCameraGameObject = new GameObject ("GATU Camera 00");
                NearCamera = NearCameraGameObject.AddComponent<Camera> ();
                NearCamera.CopyFrom (sourceNearCam);
                NearCamera.enabled = false;
                NearCamera.fieldOfView = fovAngle;
                NearCamera.aspect = aspect;

                var FarCameraGameObject = new GameObject ("GATU Camera 01");
                FarCamera = FarCameraGameObject.AddComponent<Camera> ();
                FarCamera.CopyFrom (sourceFarCam);
                FarCamera.enabled = false;
                FarCamera.fieldOfView = fovAngle;
                FarCamera.aspect = aspect;

                var SkyboxCameraGameObject = new GameObject ("GATU Camera ScaledSpace");
                SkyboxCamera = SkyboxCameraGameObject.AddComponent<Camera> ();
                SkyboxCamera.transform.position = sourceSkyCam.transform.position;
                SkyboxCamera.CopyFrom (sourceSkyCam);
                SkyboxCamera.enabled = false;
                SkyboxCamera.fieldOfView = fovAngle;
                SkyboxCamera.aspect = aspect;

                var GalaxyCameraGameObject = new GameObject ("GATU GalaxyCamera");
                GalaxyCamera = GalaxyCameraGameObject.AddComponent<Camera> ();
                GalaxyCamera.transform.position = sourceGalaxyCam.transform.position;
                GalaxyCamera.CopyFrom (sourceGalaxyCam);
                GalaxyCamera.enabled = false;
                GalaxyCamera.fieldOfView = fovAngle;
                GalaxyCamera.aspect = aspect;

            }
        }
开发者ID:pcwilcox,项目名称:GoAtThrottleUp,代码行数:56,代码来源:GoAtThrottleUpCamera.cs

示例14: OnPreRender

	void OnPreRender()
	{
		if (!UseHighPrecisionDepthMap)
			return;
		
		// Create the camera used to generate the alternate depth map
		if (m_RWSCamera == null)
		{
			GameObject go = new GameObject("Depth Normal Camera", typeof(Camera));
			go.hideFlags = HideFlags.HideAndDontSave;
			m_RWSCamera = go.GetComponent<Camera>();
			m_RWSCamera.CopyFrom(m_Camera);
			m_RWSCamera.renderingPath = RenderingPath.Forward;
			m_RWSCamera.clearFlags = CameraClearFlags.Color;
			m_RWSCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
			m_RWSCamera.enabled = false;
		}

		// Render depth & normals to a custom Float RenderTexture
		m_RWSCamera.CopyFrom(m_Camera);
		m_RWSCamera.rect = new Rect(0f, 0f, 1f, 1f);
		m_RWSCamera.renderingPath = RenderingPath.Forward;
		m_RWSCamera.clearFlags = CameraClearFlags.Color;
		m_RWSCamera.backgroundColor = new Color(1f, 1f, 1f, 1f);
		m_RWSCamera.farClipPlane = CutoffDistance;

		RenderTexture rt = RenderTexture.GetTemporary((int)m_Camera.pixelWidth, (int)m_Camera.pixelHeight, 24, m_RTFormat);
		rt.filterMode = FilterMode.Bilinear;
		m_RWSCamera.targetTexture = rt;
		m_RWSCamera.RenderWithShader(m_ShaderHighPrecisionDepth, "RenderType");
		rt.SetGlobalShaderProperty("_DepthNormalMapF32");
		m_RWSCamera.targetTexture = null;
		RenderTexture.ReleaseTemporary(rt);
	}
开发者ID:carlotes247,项目名称:GGJ_2016,代码行数:34,代码来源:SSAOPro.cs

示例15: CopyCamera

 //helper method that copies camera properties from one camera to another
 //copies from srcCamera to destCamera
 private void CopyCamera(Camera srcCamera, Camera destCamera)
 {
     //Copy the camera properties.
     destCamera.CopyFrom(srcCamera);
     destCamera.depth = 0;
     //@todo Copy other components attached to the DisplayController?
 }           
开发者ID:peroht,项目名称:OSVR-Unity-Palace-Demo,代码行数:9,代码来源:VREye.cs


注:本文中的UnityEngine.Camera.CopyFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。