unity3d中让物体显示和隐藏的方法
记录下
using UnityEngine; using System.Collections; public class test : MonoBehaviour { GameObject m_obj; // Use this for initialization void Start () { m_obj = GameObject.Find("box"); } // Update is called once per frame void Update () { } void OnGUI() { if (Input.GetKeyDown(KeyCode.W)) { // m_obj.enabled = true; m_obj.SetActive(true); } if (Input.GetKeyDown(KeyCode.A)) { m_obj.SetActive(false); // m_obj.enabled = false; } } }
原文:http://www.cnblogs.com/mengfanrong/p/5106677.html