Hello, Im trying to create a public void that I can then attach to a key or button. The public void, I want it to access the cameras clear flags function and select “dont clear”. Then with another public void to switch it back to solid background. Im not much of a c# person and Im using what the unity docs say but its just confusing…due to my weak knowledge of c# basics.
Anyway, this is what I have so far…
using UnityEngine;
using System.Collections;
public class CamClear : MonoBehaviour {
public GameObject cam;
// Use this for initialization
void Start () {
GetComponent<Camera>() = GetComponent<Camera>();
GetComponent<Camera>().clearFlags = CameraClearFlags.Nothing;
}
// Update is called once per frame
void Update () {
}
public void DontClear(){
cam.GetComponent<Camera>().clearFlags = true;
}
}