using System.Collections; using System.Collections.Generic; using UnityEngine; using AX.MessageSystem; using UnityEngine.UI; public class lineLengthShow : MonoBehaviour { // Use this for initialization void Start () { MessageDispatcher.AddListener("SHOW_LINELENGTH", open); MessageDispatcher.AddListener("CLOSE_LINELENGTH", Close); gameObject.SetActive(false); } // Update is called once per frame void Update () { } void open(IMessage message) { GameObject line = (GameObject)message.Data; float lineLength = line.transform.parent.GetComponent().lineLength; gameObject.SetActive(true); gameObject.transform.Find("Text").GetComponent().text = lineLength.ToString("0.0")+"米"; } void Close(IMessage message) { gameObject.SetActive(false); } void OnDestroy() { MessageDispatcher.RemoveListener("SHOW_LINELENGTH", open); MessageDispatcher.RemoveListener("CLOSE_LINELENGTH", Close); } }