FreshRSS

Normální zobrazení

Jsou dostupné nové články, klikněte pro obnovení stránky.
PředevčíremHlavní kanál
  • ✇Recent Questions - Game Development Stack Exchange
  • RenderTexture doesn’t work in buildKonxovar
    A Gameobject sprite, a Texture2D which is written into using "Texture2D.ReadPixels" works/is visible in the Editor/Play Mode but is not/is invisible when built. The Texture2D is written to with the RT at timed intervals, and when the game is first built, before the interval where RT is written to by the game, the RT seems to work, but as soon as it's written to by the script, it disappears. What's odd is, I've tried replacing the Sprite with an Image and instead of using the Texture2D using a ma
     

RenderTexture doesn’t work in build

A Gameobject sprite, a Texture2D which is written into using "Texture2D.ReadPixels" works/is visible in the Editor/Play Mode but is not/is invisible when built.

The Texture2D is written to with the RT at timed intervals, and when the game is first built, before the interval where RT is written to by the game, the RT seems to work, but as soon as it's written to by the script, it disappears.

What's odd is, I've tried replacing the Sprite with an Image and instead of using the Texture2D using a material with the RenderTexture itself, but that is invisible when built as well.

The fact that the Texture2D sprite appears before being written to would make me think it's not an inability to render, but an error with the Texture2D being written to, but that doesn't explain why the RenderTexture itself doesn't appear when used as an Image.

Overall, I'm just really confused and don't know what's going on or what to do.

Part of the code where 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, Color.black);
    CameraFeed.Reinitialize(510, 492);

    if(SelectedCamera == DiningRoom && CameraPowers.DiningRoomPower > 0)
    {
        RenderTexture.active = DiningRoomRT;
        CameraFeed.ReadPixels(new Rect(0, 0, DiningRoomRT.width, DiningRoomRT.height), 0, 0);
        CameraFeed.Apply();
    }
    [...]
    //Terminal
    
    TerminalLinesVisible = 0;
    TerminalTimer = 0;
    
    //
    
    StartCoroutine(RefreshCamera(RefreshRate));
    
    
}
❌
❌