# How do I programmatically change the areaSize variable of an Area Light object in Unity?

I'm trying to change the areaSize property of an Area Light object, but it looks like it isn't exposed in the class, itself.

this.light.areaSize =
new Vector2(this.areaLightWidthSlider.Value, this.areaLightHeightSlider.Value);


This code results in the error:

error CS1061: 'UnityEngine.Light' does not contain a definition for 'areaSize' and no extension method 'areaSize' accepting a first argument of type 'UnityEngine.Light' could be found (are you missing a using directive or an assembly reference?)

The documentation says it exists, as an "editor only" property.

Is there any way to programmatically access and change this property, possibly using reflection or serialized properties?

I am using Unity 4.6, if at all relevant.

• Area lights are baked-only. You can only change certain properties from an editor script. Jan 9 '17 at 21:51

Can I access areaSize, programmatically?

Yes. That is not to say I can offer a how, but I can offer a why would you?.

You need to be asking yourself *why is such a theoretically useful variable editor-only?

TL;DR: Because changing this value in game would have no effect on your area light, at all.

Let's take a look at the area light in the Unity Manual (emphasis mine):

### Area lights

An Area Light is defined by a rectangle in space. (...) Since the lighting calculation is quite processor-intensive, area lights are not available at runtime and can only be baked into lightmaps.

- The Unity Manual: Lighting

What does this mean?

This means that area lights are baked; set up at the start, as static objects.

In reality, if you did change the values in-game, you would not see any effect on the actual light.

If you did have it change your area light, in game, it would significantly slow down your game; likely even crash lower-end computers that would otherwise run it. That is why it is baked from the start.