using AX.MessageSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class QuadDispItemCtrl : MonoBehaviour { public Text markNum; public RawImage rawImg; public RenderTexture texture; public CloneGameObjInfo info; private void Awake() { markNum = transform.Find("mark/Text").GetComponent(); rawImg = GetComponent(); texture = new RenderTexture(378, 250, 24); rawImg.texture = texture; } private void OnEnable() { markNum.text = (transform.GetSiblingIndex() + 1).ToString(); } public void Set(CloneGameObjInfo info) { this.info = info; QuadCamsManager.Instance.InstantiateCamera(info, texture); MessageDispatcher.AddListener("CancelQuadDisplay", DeleteDisplay); } void DeleteDisplay(IMessage obj) { var deleInfo = (CloneGameObjInfo)obj.Data; if (deleInfo.gameObjID == info.gameObjID) { Destroy(gameObject); } else { if (gameObject.activeInHierarchy==true) { StartCoroutine(UpdateNum()); } } } void OnDestroy() { MessageDispatcher.RemoveListener("CancelQuadDisplay", DeleteDisplay); } /// /// 更新四分屏序号 /// /// IEnumerator UpdateNum() { yield return new WaitForEndOfFrame(); markNum.text = (transform.GetSiblingIndex() + 1).ToString(); } }