1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. public class L11 : MonoBehaviour
    5. {
    6. public GameObject myobject;
    7. void Start()
    8. {
    9. //检查游戏对象是激活还是禁用
    10. Debug.Log("Active Sefl:" + myobject.activeSelf);
    11. Debug.Log("Active in Hierarchy" + myobject.activeInHierarchy);
    12. }
    13. // Update is called once per frame
    14. void Update()
    15. {
    16. if(Input.GetKeyUp(KeyCode.Space))
    17. {
    18. //游戏中脚本开关切换
    19. gameObject.SetActive(false);
    20. }
    21. }
    22. }