using AX.MessageSystem; using System.Collections; using System.Collections.Generic; using UnityEngine; public class QuadrupleDisplay : MonoBehaviour { public GameObject itemPre; // Use this for initialization void Start () { itemPre = Resources.Load("4GTransfer/QuadDispItem") as GameObject; MessageDispatcher.AddListener("QuadDisplay", InstantiateDisplay); //MessageDispatcher.AddListener("QuadrupleMode", DeleteAllDisplay); } private void OnDestroy() { MessageDispatcher.RemoveListener("QuadDisplay", InstantiateDisplay); } void InstantiateDisplay(IMessage obj) { var info = (CloneGameObjInfo)obj.Data; GameObject item = Instantiate(itemPre, transform); item.name = "QuadDispItem-" + item.transform.GetSiblingIndex().ToString(); item.GetComponent().Set(info); } /// /// 【暂时不用】关闭四分屏模式,删除所有分屏UI /// /// void DeleteAllDisplay(IMessage obj) { var isQuad = (bool)obj.Data; if (isQuad == false) { for(int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(i).gameObject); } } } }