using UnityEngine; using System.Collections; using AX.MessageSystem; public class test : MonoBehaviour { // Use this for initialization void Start () { MessageDispatcher.AddListener("OPEN", Execute, "CUBE"); MessageDispatcher.AddListener("CLOSE", Close, "CUBE"); this.gameObject.SetActive(false); } void OnDestroy() { MessageDispatcher.RemoveListener("OPEN", Execute, "CUBE"); MessageDispatcher.RemoveListener("CLOSE", Close, "CUBE"); } // Update is called once per frame void Update () { } void Execute(IMessage message) { if ((string)message.Data == this.gameObject.name) { this.gameObject.SetActive(true); } } void Close(IMessage message) { if ((string)message.Data == this.gameObject.name) { this.gameObject.SetActive(false); } } }