- Home /
Renderer Removed When Scene Started
Hey there, so I currently am trying to set up a function for the player to change the skin of their gun model to preset ones. I have the renderer for the model set in the inspector but when I press the play button, it's removed. I can re-add it with no issues and it will work the whole play session. Does anyone know why it might be doing this?
Here is some of the code attached to the gun:
public Texture redText;
public Texture blueText;
public Renderer rend;
void Start () {
rend = GetComponent<Renderer>();
}
if (Input.GetKeyDown(KeyCode.Tab))
{
rend.material.mainTexture = redText;
}
if (Input.GetKeyDown(KeyCode.C))
{
rend.material.mainTexture = blueText;
}
Basically I'm pretty stumped on this one, it seems like it's just a glitch but who knows.
You are probably removing this component in other script, this one has nothing to do with it.
Your answer
Follow this Question
Related Questions
How to change a value in custom shader through script, C# 1 Answer
Having a problem with the second material (on the same renderer) 0 Answers
Changing two different objects renderer colour 1 Answer
How to render black borders around texture of simple 3D quad in c#? 0 Answers
How to switch the texture being used by the material of the mesh renderer 1 Answer