Free writing a Shader in inspector

Hello :slight_smile:

i finded this variable for change a shader in a gameObject:

var someObj : GameObject;
private var shader1 = Shader.Find("Specular");

function Start(){
   someObj.renderer.material.shader = shader1;
}

and is very usefull, but i want to re-use this script so i would like to be able to change the shader in the inspector on writing it manualy without need to change it in the script(because i tried to use “var shader1 : Shader;” and i can not put the basics shaders in…).

Does someone know if it’s possible to change manualy the shader in the inspector, in writing it for the best, and how to perform it?

that requires two steps:

  1. remove the shader variable thats current declared and declare a var shaderName : string; instead that you use for the find in 2
  2. move the shader find into start too and let it search for a free string.

I’m not sure to realy understand all… mabe with an example will be more clear :slight_smile:

after your answer, i tried this:

var someObject : GameObject;
var shader1 : String;
   
function Start(){
   someObject.renderer.material.shader = Shader.Find(shader1);
}

then in the inspector, i tried to write: Specular and “Specular”…

I have no error message, but the shader turn in a default material without color and nothing… so what do i do wrong ? :roll: