- Home /
Set texture / EnableKeyword not working in build
Hello. I have a script that changes a gameobject's normal map when it's damaged, and it works perfectly fine in the editor. However, when i build the project, it just doesnt work at all. It doesnt show any errors too, as i have a script that logs them in the build. Here are the important parts of the script:
private void Start()
{
gameObject.GetComponent<Renderer>().material.EnableKeyword("_NORMALMAP");
}
private void OnCollisionEnter(Collision col)
{
if(hp < maxhp * .66f && !crack1)
{
crack1 = true;
gameObject.GetComponent<Renderer>().material.SetTexture("_BumpMap", Resources.Load("Crash1Map") as Texture);
print("Crack1 procceeded, the texture is: " + Resources.Load("Crash1Map").name);
}
if (hp < maxhp * .33f && !crack2)
{
crack2 = true;
gameObject.GetComponent<Renderer>().material.SetTexture("_BumpMap", Resources.Load("Crash2Map") as Texture);
print("Crack2 procceeded, the texture is: " + Resources.Load("Crash1Map").name);
}
}
Comment
Answer by Al_Goyle · Jan 19, 2021 at 02:53 PM
Hi, did you find any solution to that. I have the same problem with setting material's texture working in editor but not on windows and linux builds...