1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. public class L10 : MonoBehaviour
    5. {
    6. // Start is called before the first frame update
    7. private Light myLight;
    8. void Start()
    9. {
    10. myLight = GetComponent <Light>();
    11. }
    12. // Update is called once per frame
    13. void Update()
    14. {
    15. if(Input.GetKeyUp(KeyCode.Space))
    16. {
    17. //游戏中脚本开关切换
    18. myLight.enabled = false;
    19. myLight.enabled = !myLight.enabled;
    20. }
    21. }
    22. }