RenderTextureControl.cs 430 B

1234567891011121314151617181920212223242526272829
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class RenderTextureControl : MonoBehaviour {
  5. Camera cam;
  6. void Awake ()
  7. {
  8. cam = GetComponent<Camera>();
  9. }
  10. IEnumerator RenderOneFrameToTexture()
  11. {
  12. yield return new WaitForEndOfFrame();
  13. cam.enabled = false;
  14. }
  15. void OnEnable()
  16. {
  17. StartCoroutine(RenderOneFrameToTexture());
  18. }
  19. void OnDisable()
  20. {
  21. cam.enabled = true;
  22. }
  23. }