using ShadowStudio.Model; using ShadowStudio.UI; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using XRTool.WorldUI; public class ItemFileView : MonoBehaviour { private XRIcon xRIcon; private Text nameText; private Toggle toggle; public ArtContainer artContainer; public void Init(Texture2D texture2, ArtContainer artContainer, bool isone = false) { if (!xRIcon) { toggle = transform.GetComponent(); toggle.onValueChanged.AddListener(OnChooseChange); FileListDlg.ChooseFileAction += OnClick; ToggleGroup toggleGroup = transform.GetComponentInParent(); toggle.group = toggleGroup; xRIcon = transform.GetComponentInChildren(); nameText = transform.GetComponentInChildren(); } xRIcon.icon= texture2; xRIcon.AutoSetSprite(); GoodsInfo info = artContainer.GetGoodsInfo(); nameText.text = info.goods_name; this.artContainer = artContainer; if (isone) { Invoke("SetInitTrue", 1f); } } private void SetInitTrue() { this.toggle.isOn = true; } private void OnChooseChange(bool isOn) { if (isOn) { artContainer.SetSelect(); FileListDlg.artContainer = artContainer; if (!ArtEditorContainer.Instance) { ArtInfoMgr.Instance.LoadModelEditBtn(); ArtEditorContainer.Instance.SetTarget(artContainer, false); } if (ArtMoreEditor.Instance) { ArtMoreEditor.Instance.SetTarget(artContainer, false); } } else { artContainer.UnSetSelect(); FileListDlg.artContainer = null; } ArtInfoMgr.ContainerSelect?.Invoke(this.artContainer, isOn); } public void OnClick(ArtContainer artContainer,bool select) { if (this.artContainer == artContainer) { this.toggle.isOn = select; if (select) { FileListDlg.artContainer = artContainer; } else { FileListDlg.artContainer = null; } } } private void OnDestroy() { FileListDlg.ChooseFileAction -= OnClick; } }