123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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<SceneConfig> 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 + ")";
- //}
- }
|