勋章计数
parent
b66f627517
commit
38debd7b37
|
|
@ -1351,7 +1351,7 @@ RectTransform:
|
|||
m_Father: {fileID: 6872071980744986877}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
|
|
@ -2249,6 +2249,7 @@ MonoBehaviour:
|
|||
isSort: 1
|
||||
isAutoSetDrag: 1
|
||||
isShowArrow: 0
|
||||
trailingPadding: 0
|
||||
lines: 1
|
||||
squareSpacing: 0
|
||||
cell: {fileID: 8859953332383084117}
|
||||
|
|
@ -3345,6 +3346,7 @@ MonoBehaviour:
|
|||
isSort: 1
|
||||
isAutoSetDrag: 1
|
||||
isShowArrow: 0
|
||||
trailingPadding: 160
|
||||
lines: 1
|
||||
squareSpacing: 0
|
||||
cell: {fileID: 1962319954615305022}
|
||||
|
|
@ -6524,7 +6526,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8792011141720542272
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4961159477550127955}
|
||||
- component: {fileID: 8935346454032911982}
|
||||
- component: {fileID: 8410927491655402576}
|
||||
m_Layer: 5
|
||||
m_Name: UI_MoralePatchInfo_count
|
||||
m_TagString: Untagged
|
||||
|
|
@ -170,3 +172,30 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 221.6602, y: 88.3109}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &8935346454032911982
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3946920614596666726}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 59d530257961d9149b8fce668217019b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
medalId: 0
|
||||
numText: {fileID: 0}
|
||||
medalCount: 0
|
||||
--- !u!225 &8410927491655402576
|
||||
CanvasGroup:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3946920614596666726}
|
||||
m_Enabled: 1
|
||||
m_Alpha: 1
|
||||
m_Interactable: 0
|
||||
m_BlocksRaycasts: 0
|
||||
m_IgnoreParentGroups: 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIMedalCountNode : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private uint medalItemId;
|
||||
[SerializeField]
|
||||
private TMP_Text numText;
|
||||
[SerializeField]
|
||||
private uint medalItemCount;
|
||||
[SerializeField]
|
||||
private CanvasGroup canvasGroup;
|
||||
|
||||
private bool isShow=false;
|
||||
private Func<uint,uint> GetMedalCountFunc;
|
||||
|
||||
private void EnsureUIReferences()
|
||||
{
|
||||
if (numText == null)
|
||||
numText = GetComponentInChildren<TMP_Text>(true);
|
||||
if (canvasGroup == null)
|
||||
canvasGroup = GetComponentInChildren<CanvasGroup>(true);
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
EnsureUIReferences();
|
||||
if (canvasGroup != null)
|
||||
canvasGroup.alpha = 0;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
EventManager.Instance.Register<uint>(EventManager.EventName.ItemChange,Refresh);
|
||||
}
|
||||
|
||||
private void Refresh(uint id)
|
||||
{
|
||||
if(id!=medalItemId||!isShow) return;
|
||||
|
||||
EnsureUIReferences();
|
||||
medalItemCount = GetMedalCountFunc?.Invoke(medalItemId) ?? 0;
|
||||
if (canvasGroup != null)
|
||||
canvasGroup.alpha = medalItemCount > 0 ? 1 : 0;
|
||||
if (numText != null)
|
||||
numText.text = medalItemCount.ToString();
|
||||
}
|
||||
|
||||
public void SetNode(uint id,Func<uint,uint> getMedalCountFunc,int repeat=0)
|
||||
{
|
||||
if (repeat == 0)
|
||||
{
|
||||
EnsureUIReferences();
|
||||
if (canvasGroup != null)
|
||||
canvasGroup.alpha = 0;
|
||||
isShow = false;
|
||||
return;
|
||||
}
|
||||
|
||||
isShow = true;
|
||||
medalItemId = id;
|
||||
GetMedalCountFunc = getMedalCountFunc;
|
||||
medalItemCount = GetMedalCountFunc?.Invoke(medalItemId) ?? 0;
|
||||
|
||||
gameObject.SetActive(true);
|
||||
EnsureUIReferences();
|
||||
Refresh(medalItemId);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EventManager.Instance.Unregister<uint>(EventManager.EventName.ItemChange,Refresh);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
EventManager.Instance.Unregister<uint>(EventManager.EventName.ItemChange,Refresh);
|
||||
GetMedalCountFunc = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59d530257961d9149b8fce668217019b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit b9e1d3c27c1fb35387b1dd91abc2ae69e6557c83
|
||||
Subproject commit f1aad27aa90141be76130cf265e18fb6729c051e
|
||||
Loading…
Reference in New Issue