Answers for "How to set a component active unity"

C#
7

disable a component unity

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;
        }
    }
}
Posted by: Guest on June-10-2020

Code answers related to "How to set a component active unity"

C# Answers by Framework

Browse Popular Code Answers by Language