using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using DG.Tweening; using System; using TMPro; public class StepSecondary : UIController { [SerializeField] Image im; [SerializeField] Image BG; [SerializeField] Button Btn; [SerializeField] StepThreePanel panel; [SerializeField] StepThreePanel panel2; [SerializeField] Transform trans; [SerializeField] TextMeshProUGUI textMeshProUGUI; [SerializeField] Image ImBG; public bool isok = false; private void Start() { trans = GameObject.Find("Canvas").transform; Btn.onClick.AddListener(() => { if (panel2!=null) { panel2.gameObject.SetActive(true); panel2.isok = isok; } else { panel2 = Instantiate(panel,trans); //panel2.isok = isok; } }); } private void Update() { if (panel2) { if (panel2.isok) { isok = panel2.isok; } } } public new void show() { isok = false; panel2.isok = false; } public void init(string Str,string SpritePath,bool isok = true) { //Debug.Log($"{Str},,,,{SpritePath}"); try { if (!string.IsNullOrEmpty(Str) && !string.IsNullOrEmpty(SpritePath)) { textMeshProUGUI.text = Str; UIManager.ins.LoadImageAsync(SpritePath, ImBG, isok); } } catch (Exception ex) { Debug.Log(ex.Message); throw; } } public override void hide(Image mainBody, Image BG, Action ac = null) { mainBody.transform.DOScale(new Vector3(0, 0, 0), 0.01f); BG.gameObject.SetActive(false); ac?.Invoke(); } private void OnEnable() { base.show(im, BG); } private void OnDisable() { this.hide(im, BG); } }