首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在实例化相机上应用渲染纹理(作为目标纹理)?

如何在实例化相机上应用渲染纹理(作为目标纹理)?
EN

Stack Overflow用户
提问于 2017-04-20 22:54:11
回答 1查看 4.6K关注 0票数 1

我有一个相机预制件,我实例化了4次在不同的位置,我想添加渲染纹理(作为目标纹理),以便我可以采取相同的纹理,并应用在一个平面上监测在其中一个场景。请问一下是否不清楚。我试图做一个监视监测,但不知道如何做,我被困在这一点。请事先给出例子谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-21 01:46:18

我认为统一手册很好地解释了https://docs.unity3d.com/Manual/class-RenderTexture.html

具体来说,这里有一个可能的实现:

在RenderTextures中创建一些AssetFolder,而不是将它们链接到相机脚本以使它们呈现。将此文件添加到您的纺织品评标相机。

代码语言:javascript
复制
using System.Collections;
using UnityEngine;

public class Camera2Texture : MonoBehaviour {

public RenderTexture[] renderTextures;
private Camera cam;

private void Awake()
{
    cam = GetComponent<Camera>();
}

private void Start()
{
    StartCoroutine(RenderTexturesCoroutine());
}

IEnumerator RenderTexturesCoroutine()
{
    for (int i = 0; i < renderTextures.Length; i++)
    {
        // just move the camera a little bit and focus the center of the scene
        this.transform.position += Vector3.left * 2 * i;
        cam.transform.LookAt(Vector3.zero);

        cam.targetTexture = renderTextures[i];
        yield return new WaitForSeconds(1f);
        cam.Render();
    }

    cam.targetTexture = null;
    this.gameObject.SetActive(false);
}
}

我启动了一个协同线,它每秒钟移动一小段时间,从数组中插入下一个RenderTexture并渲染图像。最后我关掉了摄像机。这是将所有4个RenderTextures放在Quads上的结果:结果

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43531196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档