A Gameobject sprite, a Texture2D which is written into utilizing “Texture2D.ReadPixels” works/is seen within the Editor/Play Mode however just isn’t/is invisible when constructed.
The Texture2D is written to with the RT at timed intervals, and when the sport is first constructed, earlier than the interval the place RT is written to by the sport, the RT appears to work, however as quickly because it’s written to by the script, it disappears.
What’s odd is, I’ve tried changing the Sprite with an Picture and as a substitute of utilizing the Texture2D utilizing a fabric with the RenderTexture itself, however that’s invisible when constructed as nicely.
The truth that the Texture2D sprite seems earlier than being written to would make me assume it isn’t an incapacity to render, however an error with the Texture2D being written to, however that does not clarify why the RenderTexture itself would not seem when used as an Picture.
Total, I am simply actually confused and do not know what is going on on or what to do.
A part of the code the place the RT is written into the Texture2D:
public Texture2D CameraFeed;
[...]
IEnumerator RefreshCamera(float RefreshRate)
{
yield return new WaitForSeconds(RefreshRate);
yield return new WaitForEndOfFrame();
CameraFeed.Reinitialize(1, 1);
CameraFeed.SetPixel(1,1, Colour.black);
CameraFeed.Reinitialize(510, 492);
if(SelectedCamera == DiningRoom && CameraPowers.DiningRoomPower > 0)
{
RenderTexture.energetic = DiningRoomRT;
CameraFeed.ReadPixels(new Rect(0, 0, DiningRoomRT.width, DiningRoomRT.top), 0, 0);
CameraFeed.Apply();
}
[...]
//Terminal
TerminalLinesVisible = 0;
TerminalTimer = 0;
//
StartCoroutine(RefreshCamera(RefreshRate));
}