If my terminology or anything is off I apologise and hope you know what I’m talking about:
No matter what I try I just cannot get this to work despite doing exactly what Im told in many tutorials
I simply want to change the material of an object to a certain material based on a variable i have set up, but I always get the error message: CS0120: An object reference is required to access non-static member.
This is one of my simpler attempts:
public Texture WarriorBD;
public Texture MageBD;
public Texture RogueBD;
private void SetBackdrop(int jobSelection){
if (jobSelection == 0) {
Renderer.material.SetTexture("CCBackdrop", WarriorBD);
}else if(jobSelection == 1) {
Renderer.material.SetTexture("CCBackdrop", MageBD);
}else if(jobSelection == 2) {
Renderer.material.SetTexture("CCBackdrop", RogueBD);
}
}
I then call ‘SetBackdrop’ in another script, which has worked with methods with the same structure as this.
The variable ‘jobSelection’ isnt an issue as it works in these other methods.
“CCBackdrop” is the name of the object I wish to change the material for.
The public textures sometimes pop up in the inspector panel and I can assign textures to them, but sometimes they don’t turn up even when the script is identically written (but I don’t think it is related to this problem)
Please tell me what I’m doing wrong and/or how I might do want I’m trying to do.