# Adjust scene lighting with a button

> Change the scene’s light color or intensity when the user clicks a button.

Use this example to understand how to change the scene’s light color or intensity when the user clicks a button.

1. **Create a button in your UI Canvas**

   1. Select **UI Canvas** in the **Hierarchy** panel.
   2. Right-click the **UI Canvas** and select **UI** > **Button** to create a new button.

2. **Create a New Logic script**

   1. In the **Project** panel, select the **My Logic** folder.
   2. Select **Add** (**+**).
   3. Select **Script**. Unity Studio creates a new Logic script in the folder.
   4. Enter a name for your script and press **Enter**.

3. **Add the script to a GameObject**

   1. Select or create a GameObject from the **Hierarchy** panel.
   2. From the **Inspector** panel, select **Add Component**.
   3. Choose your Logic script from the list.

4. **Set up the logic in the Logic Editor**

   1. In the **Project** panel, double-click the Logic script to open the **Logic Editor**.
   2. Drag a **When** event listener into the **Logic Editor**.
   3. Add a **Clicked On** event inside the **When** node.
   4. Create a new variable for the button and set its type to **Object**.
   5. Drag the button variable into the **Clicked On** socket.
   6. Drag a **Set variable value** node into the **When** node.
   7. Create a new variable for the light and set its type to **Light**.
   8. Expand the light variable and select the **Color** property.
   9. Drag the **Color** property into the **Set variable value** node.
   10. Click on the color code in the **Set variable value** node to open the color wheel and choose your desired light color.


   **Example Logic script to change the light color on button click.:**
   ![Example Logic script to change the light color on button click.](/api/media?file=/unity-studio/media/images/logic-examples/set-light-value-button.png)

   11. Close the **Logic Editor**.

5. **Connect your Button and Light references**

   1. In the **Hierarchy** panel, select the GameObject with the attached Logic script.
   2. Drag your button from the **Hierarchy** panel into the **Button** variable reference in your script component.
   3. Drag your Light object from the **Hierarchy** panel into the **Light** variable reference in your script component.

Press Play to test your scene. When you click the button, the light color (or intensity) changes based on your specified logic.

> **Tip:**
>
> Use the same approach to change the light intensity. Expand the Light variable and select the Intensity property, then set its value.
> Combine both color and intensity changes in the same Logic script to create unique lighting effects or atmospheres in your scene.

## Additional resources

* [Introduction to Logic](/unity-studio/develop/logic/logic-intro.md)
* [The Logic Editor interface](/unity-studio/develop/logic/logic-interface.md)
* [Create a Logic script](/unity-studio/develop/logic/create-logic.md)
* [Methods and variables](/unity-studio/develop/logic/methods-variables.md)
* [Nodes](/unity-studio/develop/logic/nodes.md)
* [Logic examples](/unity-studio/develop/logic/examples.md)
