This fixes an invalid cast exception when texture is null

Setvalue(texture=null) throws an invalid cast exception when it should not.