UnityでFlashのBitmapDataっぽい使い方
RenderTextureをアタッチしたカメラにこんな感じでスクリプトをつけてあげると、AS3のBitmapDataっぽい挙動になる。ぺたぺた描画内容を貼りたいときはDraw()を呼んで、初期化したいときはClear()を呼ぶ。もしかして、、これはすごく便利ではなかろうか・・・!!!!
using UnityEngine; using System.Collections; public class BitmapController : MonoBehaviour { private Camera camera; private RenderTexture rTexture; // Use this for initialization void Start () { camera = gameObject.GetComponent<Camera>(); camera.clearFlags = CameraClearFlags.Nothing; camera.enabled = false; rTexture = camera.targetTexture; Clear (); } public void Draw(){ camera.enabled = true; camera.Render (); camera.enabled = false; } public void Clear(){ RenderTexture.active = rTexture; GL.Clear (false, true, Color.clear); RenderTexture.active = null; } }












