I’m trying to use RenderTexture. I create and display it this way : (I am using 2D Toolkit and I want to bind the texture to all my cameras in the scene)
using UnityEngine;
using System.Collections;
public class SceneRenderer : MonoBehaviour
{
private RenderTexture m_RenderTexture = null;
// Use this for initialization
void Start ()
{
m_RenderTexture = new RenderTexture(1280, 800, 24, RenderTextureFormat.ARGB32);
m_RenderTexture.anisoLevel = 0;
m_RenderTexture.filterMode = FilterMode.Bilinear;
m_RenderTexture.useMipMap = false;
m_RenderTexture.Create();
tk2dCamera[] cams = (tk2dCamera[])GameObject.FindObjectsOfType(typeof(tk2dCamera));
foreach (tk2dCamera cam in cams)
{
Camera c = cam.GetComponent<Camera>();
c.targetTexture = m_RenderTexture;
}
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
if (m_RenderTexture != null)
GUI.DrawTexture(new Rect(80, 0, 1440, 900), m_RenderTexture, ScaleMode.ScaleAndCrop );
}
}
It works well in Editor mode but i have a black screen when I build and run a Standalone.
Here is the output_log file :
It seems that the rentertexture is released ans destroyed just after the start of the Standalone.
Why?