using ShadowStudio.Model; using ShadowStudio.UI; using System; using System.Collections; using System.Collections.Generic; using System.Threading; using UnityEngine; using UnityEngine.UI; using XRTool.Util; public class ItemSenceView : MonoBehaviour { public Button sceneBtn; public Button deleteBtn; public GameObject checkImage; public Text nameText; private int senceId; private void Start() { sceneBtn.onClick.AddListener(OnClickChange); deleteBtn.onClick.AddListener(OnClickDelete); //ArtInfoMgr.Instance.ContainerCreate += OnContainerChange; //ArtInfoMgr.Instance.ContainerDel += OnContainerChange; } private void OnClickChange() { if (checkImage.activeSelf) { return; } WSHandler.Room.ChangeScene(this.senceId); } public void OnClickDelete() { WSHandler.Room.DeleteScene(this.senceId); } public void Init(int senceId, string sceneName, SceneConfig currentScene, bool isShow = true) { nameText.text = sceneName; ShowViewMgr.RemoteSenceAction += RemoveSence; ShowViewMgr.ChooseSenceAction += ChooseSence; this.senceId = senceId; ChooseSence(currentScene); if (isShow) { deleteBtn.gameObject.SetActive(true); } else { deleteBtn.gameObject.SetActive(false); } } private void ChooseSence(SceneConfig currentScene) { if (this.senceId == currentScene.Id) { nameText.text = currentScene.SceneName; FileListDlg.ChooseSceneName?.Invoke(nameText.text); if (checkImage) { checkImage.SetActive(true); } } else { if (checkImage) { checkImage.SetActive(false); } } } private void RemoveSence(List remainscene) { for (int i = 0; i < remainscene.Count; i++) { if (senceId == remainscene[i].Id) { Destroy(this.gameObject); } } } private void OnDestroy() { //ArtInfoMgr.Instance.ContainerCreate -= OnContainerChange; //ArtInfoMgr.Instance.ContainerDel -= OnContainerChange; ShowViewMgr.RemoteSenceAction -= RemoveSence; ShowViewMgr.ChooseSenceAction -= ChooseSence; } //private void OnContainerChange(ArtContainer obj) //{ // int count = 0; // if (GameNode.Instance.PageGoodsIdCount.ContainsKey(this.senceId)) // { // count = GameNode.Instance.PageGoodsIdCount[this.senceId]; // } // int num = this.transform.GetSiblingIndex() + 1; // nameText.text = sceneNamePre + num + "(" + count + ")"; //} }