Project
Beginner Gameplay Scripting
Enabling and Disabling Components
Tutorial
Beginner
5 Mins
Unity Technologies
Overview
You have completed 0% of this Tutorial.
1.
Enabling and Disabling Components
Summary
How to enable and disable components via script during runtime.
Language
English
Recommended Unity Versions
4
1.
Enabling and Disabling Components
using UnityEngine; using System.Collections; public class EnableComponents : MonoBehaviour { private Light myLight; void Start () { myLight = GetComponent<Light>(); } void Update () { if(Input.GetKeyUp(KeyCode.Space)) { myLight.enabled = !myLight.enabled; } } }

Woohoo! You nailed this tutorial.
Continue rocking your Beginner Gameplay Scripting project.
Next Step:
Activating GameObjects
Tutorial
Beginner
5 Mins
Unity Technologies