|
|
@@ -8,9 +8,22 @@ public class TopBarView : MonoBehaviour
|
|
|
[SerializeField] Text[] itemValueTexts;
|
|
|
[SerializeField] Button[] itemPlusButtons;
|
|
|
int[] itemValues = {-1, -1, -1};
|
|
|
+
|
|
|
+ public static TopBarView ins;
|
|
|
+
|
|
|
+ public void Awake()
|
|
|
+ {
|
|
|
+ ins = this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OnDestroy()
|
|
|
+ {
|
|
|
+ if (ins == this) ins = null;
|
|
|
+ }
|
|
|
|
|
|
void Start()
|
|
|
{
|
|
|
+ CheckNeedShowWhenInit();
|
|
|
if (CommonConfig.needToExamine) {
|
|
|
Transform tf = transform.Find("TopBar");
|
|
|
for (int i = 0; i < tf.childCount; i++) {
|
|
|
@@ -27,25 +40,74 @@ public class TopBarView : MonoBehaviour
|
|
|
itemValues[0] = LoginMgr.myUserInfo.diamond;
|
|
|
itemValueTexts[0].text = itemValues[0].ToString();
|
|
|
}
|
|
|
- if (itemValues[1] != LoginMgr.myUserInfo.coin) {
|
|
|
- itemValues[1] = LoginMgr.myUserInfo.coin;
|
|
|
- itemValueTexts[1].text = itemValues[1].ToString();
|
|
|
+ // if (itemValues[1] != LoginMgr.myUserInfo.coin) {
|
|
|
+ // itemValues[1] = LoginMgr.myUserInfo.coin;
|
|
|
+ // itemValueTexts[1].text = itemValues[1].ToString();
|
|
|
+ // }
|
|
|
+ // if (itemValues[2] != LoginMgr.myUserInfo.integral) {
|
|
|
+ // itemValues[2] = LoginMgr.myUserInfo.integral;
|
|
|
+ // itemValueTexts[2].text = itemValues[2].ToString();
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ static HashSet<MonoBehaviour> _needShowItLockers = new HashSet<MonoBehaviour>();
|
|
|
+ public static void NeedShowIt(MonoBehaviour locker) {
|
|
|
+ _needShowItLockers.Add(locker);
|
|
|
+ #if UNITY_EDITOR
|
|
|
+ Debug.LogWarning("NeedShowIt, NowCount=" + _needShowItLockers.Count);
|
|
|
+ #endif
|
|
|
+ try {
|
|
|
+ ins.ResetCanvasSortOrder();
|
|
|
+ if (!ins.gameObject.activeSelf) ins.gameObject.SetActive(true);
|
|
|
}
|
|
|
- if (itemValues[2] != LoginMgr.myUserInfo.integral) {
|
|
|
- itemValues[2] = LoginMgr.myUserInfo.integral;
|
|
|
- itemValueTexts[2].text = itemValues[2].ToString();
|
|
|
+ catch (System.Exception) {}
|
|
|
+ }
|
|
|
+ public static void DontNeedShowIt(MonoBehaviour locker) {
|
|
|
+ _needShowItLockers.Remove(locker);
|
|
|
+ #if UNITY_EDITOR
|
|
|
+ Debug.LogWarning("DontNeedShowIt, NowCount=" + _needShowItLockers.Count);
|
|
|
+ #endif
|
|
|
+ try {
|
|
|
+ ins.ResetCanvasSortOrder();
|
|
|
+ if (ins.gameObject.activeSelf && _needShowItLockers.Count == 0) ins.gameObject.SetActive(false);
|
|
|
+ }
|
|
|
+ catch (System.Exception) {}
|
|
|
+ }
|
|
|
+ public void CheckNeedShowWhenInit() {
|
|
|
+ if (_needShowItLockers.Count > 0) {
|
|
|
+ ins.ResetCanvasSortOrder();
|
|
|
+ ins.gameObject.SetActive(true);
|
|
|
+ } else {
|
|
|
+ ins.gameObject.SetActive(false);
|
|
|
}
|
|
|
}
|
|
|
+ void ResetCanvasSortOrder()
|
|
|
+ {
|
|
|
+ int maxOrder = 0;
|
|
|
+ foreach (var item in _needShowItLockers) {
|
|
|
+ int sortOrder = item.GetComponent<Canvas>().sortingOrder;
|
|
|
+ if (sortOrder > maxOrder) maxOrder = sortOrder;
|
|
|
+ }
|
|
|
+ GetComponent<Canvas>().sortingOrder = maxOrder + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public void GoToSetup() {
|
|
|
AudioMgr.ins.PlayBtn();
|
|
|
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/SetUpView1"), Vector3.zero, new Quaternion());
|
|
|
+ GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/SetUpView1"), Vector3.zero, new Quaternion());
|
|
|
+ JC.Unity.UI.CanvasUtils.PlusSortOrder(gameObject, o, 1);
|
|
|
}
|
|
|
|
|
|
public void GoToShop()
|
|
|
{
|
|
|
AudioMgr.ins.PlayBtn();
|
|
|
if (ShopView.ins) return;
|
|
|
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/ShopView"));
|
|
|
+ GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/ShopView"));
|
|
|
+ JC.Unity.UI.CanvasUtils.PlusSortOrder(gameObject, o, 1);
|
|
|
}
|
|
|
}
|