OptionItem.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /****************************************************************************
  2. * 2025.6 LXD
  3. ****************************************************************************/
  4. using System;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. using QFramework;
  9. namespace QFramework
  10. {
  11. public partial class OptionItem : UIElement
  12. {
  13. public bool isOn;
  14. private void Awake()
  15. {
  16. ClickBtn.onClick.AddListener(OnClickBtnClick);
  17. SetState();
  18. }
  19. public void InitData(string str)
  20. {
  21. var arr = str.Split('_');
  22. string tmpPicturePath = "Config/Ìâ¿âͼÎÄͼƬ/" + arr[1];
  23. ClickBtn.GetComponent<Image>().sprite = LoadHelper.LoadSpriteFromStreamming(tmpPicturePath);
  24. var arr1 = arr[0].Split('¡¢');
  25. Text.text = arr1[1];
  26. }
  27. protected override void OnBeforeDestroy()
  28. {
  29. }
  30. private void OnClickBtnClick()
  31. {
  32. isOn = !isOn;
  33. SetState();
  34. }
  35. private void SetState()
  36. {
  37. HighterState.gameObject.SetActive(isOn);
  38. NormalState.gameObject.SetActive(!isOn);
  39. }
  40. }
  41. }