1

I have a material with its shader set to Skybox/Cubemap and I have cubemap1 assigned to the slot. Now I want to replace cubemap1 with cubemap2 and I found a script for this, but i can't seem to get it working.

any thoughts?

#pragma strict
var cubemap2 : Cubemap; //Change texture for cubemap
var shaderCubemap : Material; //Shader with cubemapslot

function Start () {
        shaderCubemap.SetTexture("_Cube",cubemap2);
}

1 Answer 1

2
shaderCubemap.SetTexture("_Tex",cubemap2);

When you are not sure about a texture name in a shader, set it to debug in the top right corner of the inspector. It will display the shader and all its parameters with the naming actually used in it.

1
  • It works! Also great tip, I didn't know about the debug function in the inspector. thank you!
    – Gerald_LD
    Dec 3, 2015 at 9:46

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.