- Home /
Materials losing their texture after copying another material. (Possibly a bug)
Hi, i have a problem on my project. The first time i open the project my "ground" material loses it's texture, i always solve it by changing it's color on the inspector to something else and then changing it back, however i find it quite annoying to do every time and i don't really know what is the cause of it. I have a script that makes said material to copy other materials so it has different colors depending on the level.
using System.Collections;
using UnityEngine;
public class GroundMaterialController : MonoBehaviour
{
public Material materialToChange;
public Material area1Material;
public Material area2Material;
public Material area3Material;
public Material area4Material;
private void Start()
{
SetLevelMaterial();
}
private void SetLevelMaterial()
{
// CHECKS FOR GAMECONTROLLER INSTANCE
if (GameController.instance != null)
{
if(GameController.instance.GetLevelNumber() != 0)
{
// SETS AREA 1 MATERIAL
if (GameController.instance.GetLevelNumber() <= 5)
{
materialToChange.CopyPropertiesFromMaterial(area1Material);
}
// SETS AREA 2 MATERIAL
else if (GameController.instance.GetLevelNumber() <= 12)
{
materialToChange.CopyPropertiesFromMaterial(area2Material);
}
// SETS AREA 3 MATERIAL
else if (GameController.instance.GetLevelNumber() <= 20)
{
materialToChange.CopyPropertiesFromMaterial(area3Material);
}
// SETS AREA 4 MATERIAL
else
{
materialToChange.CopyPropertiesFromMaterial(area4Material);
}
}
}
}
private void OnApplicationQuit()
{
materialToChange.CopyPropertiesFromMaterial(area1Material);
}
}
All other materials are identical except for the emissive color. I'm using Unity 2019.4.29f1 (but i remember this ocurring on previous versions aswell).
Answer by GeroNL · Aug 29, 2021 at 11:38 AM
hello, Are use Universal Render Pipeline (URP)?, if yes try to do this:
Go to edit-> render pipeline -> universal render pipeline -> upgrade proect ....
Hope it help
Your answer
![](https://koobas.hobune.stream/wayback/20220613042242im_/https://answers.unity.com/themes/thub/images/avi.jpg)