- Home /
Question by
BlacksmithBros · Oct 15, 2019 at 05:22 PM ·
texturematerialrendertexturetagdetection
[SOLVED] Dynamic texture setting
So the scenario is on in which I am attempting to get a prefab object to dynamically apply a texture to its material based on whichever tag I apply to it. In the code attached is the current code I have. I also have zero doubt I am butchering this code some how but I am receiving no error messages and am at my wit's end.
[SerializeField]
Texture[] _spaceTexture;
Renderer rend;
void SpaceStatModifiers()
{
rend = GetComponent<Renderer>();
//if stat modifier is HPup
//increase current Player Base HP Stat
if (gameObject.tag == "HPup")
{
rend.material.SetTexture("_MainTex", _spaceTexture[0]);
}
...
Any advice on what I'm goofing on?
Comment
I'm an idiot. I didn't apply the command to the void Start()