Disable shadows

Hi guys, I would like disable shadows when a button is pressed, i did this, but for my case, don’t work. How can I disable shadows? Thank you in advance.

var buttonstyle : GUISkin ;
 
function Start () {
 
}
 
function OnGUI (){
 
GUI.skin  = buttonstyle;
if(GUI.Button(new Rect(100,200,200,70),"")){
 
renderer.castShadows = false;
 
}
 
}

If you’ve baked the lights in your scenes, then this will not work. But what you can do it fetch all the lights in your scene. Warning: This may be a heavy action and make your game lag, so I’ve put it in the Start function, which means it caches your lights before you actually start playing. (Having tested the code, so let me know if it gives you errors)

import System.Collections.Generic;

var lightDict = new Dictionary.<Light,LightShadows>();
 
function Start() {
	for (var light : Light in FindObjectsOfType(Light) as Light[]) {
		lightDict[light] = light.shadows;
	}
}
 
function OnGUI (){
   if(GUI.Button(new Rect(100,200,200,70),"")){
       for (var light in lightDict.Keys) {
       		if (light.shadows == LightShadows.None)
       			light.shadows = lightDict[light];
       		else
       			light.shadows = LightShadows.None;
       }
   }
}