- Home /
[Solved] False "variable not assigned" error
I've been looking for any solve for this, but i didn't find anything.
My problem is that i defined material variable in my day/night cycle script, assigned skybox with shader to it, and try to change "_Blend" value of my shader to something other. It's changing as well, but console is spamming with error "The variable SkyboxMaterial of 'DayCycle' has not been assigned." every frame.
Code:
var SkyboxMaterial : Material;
var SkyboxBlend : float = 0.0;
function Update(){
SkyboxMaterial.SetFloat("_Blend", SkyboxBlend);
SkyboxBlend = 0.5;
}
Any help?
does the skybox material show up in the parameters section of DayCycle? are there any snippets of code that could change the value of Skybox$$anonymous$$aterial?
It shows up, and there isn't any code which could change it.
Answer by Bunny83 · Nov 26, 2013 at 11:51 AM
The only reason i see here (It's working and shows such and error) is that you have your script attached to at least two gameobjects. One with the material reference and one without. Type the name of your script "DayCycle" in the search box above the hierarchy window now you should see at least two objects. All objects that show up have this script attached.
Answer by Iraasta · Nov 25, 2013 at 03:25 PM
You need to attach a Material in editor to it or make
SkyboxMaterial = new Material();
in code
"The type 'UnityEngine.$$anonymous$$aterial' does not have a visible constructor that matches the argument list '()'."
I think it's just a bug, 'cause everything is working, but console is spam$$anonymous$$g with error.
Answer by applejuices · Nov 25, 2013 at 03:20 PM
From what I see...
"SkyboxBlend = 0.5"
Should have a...
";" on it. so maybe.. "SkyboxBlend = 0.5;"
SOrry if that didn't help. But that's how I fix this error in myscripts
It's my bad adding this answer, in my code there is a semicolon at the end.