TopBarView.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. /* 主界面右上方信息栏 */
  6. public class TopBarView : MonoBehaviour
  7. {
  8. [SerializeField] Text[] itemValueTexts;
  9. [SerializeField] Button[] itemPlusButtons;
  10. int[] itemValues = {-1, -1, -1};
  11. void Start()
  12. {
  13. if (CommonConfig.needToExamine) {
  14. Transform tf = transform.Find("TopBar");
  15. for (int i = 0; i < tf.childCount; i++) {
  16. if (tf.GetChild(i).name.StartsWith("Item")) {
  17. tf.GetChild(i).gameObject.SetActive(false);
  18. }
  19. }
  20. }
  21. }
  22. void Update()
  23. {
  24. if (itemValues[0] != LoginMgr.myUserInfo.diamond) {
  25. itemValues[0] = LoginMgr.myUserInfo.diamond;
  26. itemValueTexts[0].text = itemValues[0].ToString();
  27. }
  28. if (itemValues[1] != LoginMgr.myUserInfo.coin) {
  29. itemValues[1] = LoginMgr.myUserInfo.coin;
  30. itemValueTexts[1].text = itemValues[1].ToString();
  31. }
  32. if (itemValues[2] != LoginMgr.myUserInfo.integral) {
  33. itemValues[2] = LoginMgr.myUserInfo.integral;
  34. itemValueTexts[2].text = itemValues[2].ToString();
  35. }
  36. }
  37. public void GoToSetup() {
  38. AudioMgr.ins.PlayBtn();
  39. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/SetUpView1"), Vector3.zero, new Quaternion());
  40. }
  41. }