- Home /
SetTexture on Quad black (but only on one camera)
I'm applying a texture at runtime to the material on a quad:
private bool positionInitialized = false;
public Texture2D mColourWheelTexture; // the texture
public GameObject colourWheel; // the quad
void initPosition(){
colourWheel.renderer.material.mainTexture = mColourWheelTexture;
positionInitialized =true;
}
// Game logic
void Update () {
if(!positionInitialized){
initPosition();
}
}
Reason for doing it this way is because I do some modifications to the texture during Start(); (though even when I don't, I still have the same problem). The quad is attached to my "Player" prefab, of which there are 4 instances (since it's 4 player split/screen game):
As you can see, the bottom right camera, the texture is just coming out black. If I set the scene with only 3 player (prefabs), then the bottom left would be black. Two, and the top right appears black. Just one player/camera and that comes out black. I.e. it's always the last camera where this happens.
You can't really see it here because the players are all bunched up, but the texture looks just fine in scene view:
It's not the shader either, as I've tried just about every pre-set shader that unity comes with, and it's always the same.
Interestingly, camera preview also shows up the same issue. You can see the camera settings I'm using below, but aside from changing the rect and removing the audiolistener, and moving them around, they should be the same as the default settings (note, I changed the texture for the last screenshot, and it still comes up the same, so appears to be nothing related to the texture itself?):
Edit: I sidestepped the issue by creating a 5th camera/player with a camera.rect off screen, but I'd still prefer to know why this is happening / fix the problem properly
Your answer
Follow this Question
Related Questions
How to make an objects texture what a camera is seeing 2 Answers
2D Sprite Texture Animation - SetTexture or SetTextureOffset 1 Answer
Texture/Material Quality, FOV, Unknown Issue 0 Answers
Problem using multiple materials 0 Answers
Help with Texture following Camera!/How to create an effect like this in Unity 3d? 1 Answer