Updating Texture2D with Rift
Hi, I am trying to take advantage of C#'s built in graphics and drawing to create dynamic textures for a HUD. This works just fine with the normal camera. However, when I try to use it with the Oculus, the textures don't update. This is the class file that I am using:
public class UpdateRender : MonoBehaviour {
[SerializeField] private Texture2D m_LevelPi;
[SerializeField] private Texture2D m_DepartmentPi;
private Image m_LevelPiImg;
private Image m_DepartmentPiImg;
public bool m_Update;
// Use this for initialization
void Start () {
m_LevelPiImg = new Bitmap (256, 256);
m_DepartmentPiImg = new Bitmap (256, 256);
m_Update = true;
using (var g = System.Drawing.Graphics.FromImage (m_LevelPiImg)) {
g.FillRectangle (new SolidBrush (System.Drawing.Color.Black), new System.Drawing.Rectangle (96, 96, 64, 64));
}
}
// Update is called once per frame
void Update () {
if (m_Update) {
MemoryStream ms;
// Load Levels
ms = new MemoryStream();
m_LevelPiImg.Save(ms, ImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
m_LevelPi.LoadImage(ms.ToArray());
ms.Close();
// Load Departments
ms = new MemoryStream();
m_DepartmentPiImg.Save(ms, ImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
m_DepartmentPi.LoadImage(ms.ToArray());
ms.Close();
ms = null;
m_Update = false;
}
}
public Image GetDepartmentPi() {
m_Update = true;
return m_DepartmentPiImg;
}
public Image GetLevelPi() {
m_Update = true;
return m_LevelPiImg;
}
}
