关于unity3d 4.2中显示隐藏的问题

public class denlu : MonoBehaviour {
public GameObject xy;
public bool xy1 = false ;

void OnMouseOver()
{
if(Input .GetMouseButton(0))
xy1 = true;
}
public void Awake()
{
if(xy1)
xy.activeSelf = false ;
}

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
}
下面是错误提示
Assets/script/denlu.cs(16,28): error CS0200: Property or indexer `UnityEngine.GameObject.activeSelf' cannot be assigned to (it is read only)

错误的意思是activeSelf 不能被赋值,你是想隐藏xy这个gameobject吧,试试这样写:把xy.activeSelf = false 换成xy.setactivity(false);
温馨提示:答案为网友推荐,仅供参考