2
\$\begingroup\$

In the editor in Assets right click Create > Render Texture Then changed the Render Texture name to: SecurityCameraTexture

Dimension 2D size 480 x 256

Render Texture

Then created a new material Assets right click Create > Material Then changed the material name to: SecurityFootage

Then changed the material shader from Standard to Mobile/Diffuse

Then dragged the render texture(SecurityCameraTexture) to the top right image place of the SecurityFootage(material)

Material

Next I have a tv object in the scene. In the tv screen I dragged the new material:

Tv

The SecurityCamera. On the SecurityCamera I attached the script that rotate the camera from side to side:

Security Camera

And the script:

using UnityEngine;
using System.Collections;

public class scr_camera : MonoBehaviour {

    public float rotate_amount;


    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        transform.rotation = Quaternion.Euler(transform.eulerAngles.x, (Mathf.Sin(Time.realtimeSinceStartup) * rotate_amount) + transform.eulerAngles.y, transform.eulerAngles.z);
    }
}

Last step I did was to drag the render texture(SecurityCameraTexture) to the camera Target Texture.

Security Camera

When running the game and watching the tv I don't see the camera preview in the tv. It should the show the camera preview the camera moving from side to side and what the camera is showing.

The camera preview was working fine before I started working with the render texture. But it's not showing the preview in the tv.

\$\endgroup\$
2
\$\begingroup\$

Some suggestions:

  1. Set your Material As Unlit/Texture
  2. Change your target display on your Camera component
  3. For testing purposes, create a looped animation of your camera moving.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.