function OnMouseEnter ()
{
renderer.material.mainTexture = "Assest/Materials/Lightning Mat.mat";
}
function OnMouseExit ()
{
renderer.material.color = Color.white;
}
What i’m trying to achieve is that when i mouse over and object it uses my material to produce an effect from the object itself but when i mouse over i get this error.
InvalidCastException: Cannot cast from source type to destination type.
I’m a little confused as to what it means, any help :)?
Your doing some weird stuff. firstly the name of the resource you are wanting to load implies a material which you are setting in to a texture. Secondly the reason you are getting the cast error message is that you are trying to assign a STRING in to a TEXTURE.
To load an asset from your resource folder use resource.load
Thanks for the replies, yeah i was doing stuff weird as i was attempting to try theories of how i could write the script but failed hard it seems i’ve been working with scripting for a little while but still suck and have a lot to learn
Thanks again for the replies i think i should be able to get something working now