UI HUGE UPDATE

This commit is contained in:
FloatGaming
2026-06-25 11:48:56 +08:00
parent bd2a06f4c7
commit b2a1e307a4
1806 changed files with 359863 additions and 20822 deletions
@@ -15,19 +15,25 @@ MonoBehaviour:
rarityColors:
- rarity: 0
color: {r: 1, g: 1, b: 1, a: 1}
- rarity: 0
color: {r: 0.73, g: 0.73, b: 0.73, a: 1}
backgroundSprite: {fileID: 21300000, guid: c1d3013bdbb080f4f8806bc4d6c58db2, type: 3}
- rarity: 1
color: {r: 0.45, g: 0.82, b: 0.47, a: 1}
color: {r: 0.73, g: 0.73, b: 0.73, a: 1}
backgroundSprite: {fileID: 21300000, guid: 0edbf3fabc7d78e43b1c48516f08667a, type: 3}
- rarity: 2
color: {r: 0.39, g: 0.63, b: 1, a: 1}
color: {r: 0.45, g: 0.82, b: 0.47, a: 1}
backgroundSprite: {fileID: 21300000, guid: d878370cc5eb0cb409882bb8e6fd7537, type: 3}
- rarity: 3
color: {r: 0.72, g: 0.49, b: 0.96, a: 1}
color: {r: 0.39, g: 0.63, b: 1, a: 1}
backgroundSprite: {fileID: 21300000, guid: 3ce075becece84045b16ac2fe217f415, type: 3}
- rarity: 4
color: {r: 1, g: 0.67, b: 0.29, a: 1}
color: {r: 0.72, g: 0.49, b: 0.96, a: 1}
backgroundSprite: {fileID: 21300000, guid: 0eab00cf603f6694c89603352de122e6, type: 3}
- rarity: 5
color: {r: 1, g: 0.84, b: 0.3, a: 1}
color: {r: 1, g: 0.67, b: 0.29, a: 1}
backgroundSprite: {fileID: 21300000, guid: 5ce43da28e0e4464a8a3bd79cfdd18de, type: 3}
- rarity: 6
color: {r: 1, g: 0.24056602, b: 0.24056602, a: 1}
color: {r: 1, g: 0.84, b: 0.3, a: 1}
backgroundSprite: {fileID: 21300000, guid: 01f1bbba4db2f5042b08ca58ec475d34, type: 3}
- rarity: 7
color: {r: 1, g: 0.5424528, b: 0.64350605, a: 1}
color: {r: 1, g: 0.24056602, b: 0.24056602, a: 1}
backgroundSprite: {fileID: 21300000, guid: 3c5a917f2e9787643a2bfc1c8f394784, type: 3}
@@ -9,6 +9,7 @@ public class ItemRarityColorConfigSO : ScriptableObject
{
public ItemRarity rarity = ItemRarity.None;
public Color color = Color.white;
public Sprite backgroundSprite;
}
public List<RarityColorEntry> rarityColors = new List<RarityColorEntry>();
@@ -27,6 +28,20 @@ public class ItemRarityColorConfigSO : ScriptableObject
return fallback;
}
public Sprite GetBackgroundSprite(ItemRarity rarity, Sprite fallback = null)
{
for (int i = 0; i < rarityColors.Count; i++)
{
RarityColorEntry entry = rarityColors[i];
if (entry != null && entry.rarity == rarity)
{
return entry.backgroundSprite != null ? entry.backgroundSprite : fallback;
}
}
return fallback;
}
private void OnValidate()
{
EnsureAllEntries();
+208
View File
@@ -0,0 +1,208 @@
using UnityEngine;
public enum ItemUsageTag
{
Auto = 0,
CharacterCultivation = 1,
CharacterBreakthrough = 2,
EquipmentUpgrade = 3,
EquipmentIllusion = 4,
EquipmentTransfer = 5,
FinalDream = 6,
EquipmentAcquisition = 7,
CharacterUnlock = 8,
SongUnlock = 9,
CharacterClue = 10,
StoryClue = 11,
PreciousItem = 12,
EquipmentMaterial = 13,
Consumable = 14,
Other = 15
}
public static class ItemUsageTagUtility
{
public static string ResolveDisplayName(storeItemSO item)
{
if (item == null)
{
return string.Empty;
}
if (item.itemUsageTag != ItemUsageTag.Auto)
{
return GetDisplayName(item.itemUsageTag);
}
if (item.associatedExpBottle != null)
{
return ResolveDisplayName(item.associatedExpBottle);
}
if (item.associatedGrowthMaterial != null)
{
return ResolveDisplayName(item.associatedGrowthMaterial);
}
if (item.associatedEquipmentConsumable != null)
{
return ResolveDisplayName(item.associatedEquipmentConsumable);
}
if (item.associatedSelectableEquipmentRewardSource != null)
{
return GetDisplayName(ItemUsageTag.EquipmentAcquisition);
}
switch (item.itemType)
{
case storeItemSO.ItemType.character:
return GetDisplayName(ItemUsageTag.CharacterUnlock);
case storeItemSO.ItemType.song:
return GetDisplayName(ItemUsageTag.SongUnlock);
case storeItemSO.ItemType.storyPassage:
return item.associatedStoryPassage != null
? ResolveDisplayName(item.associatedStoryPassage)
: GetDisplayName(ItemUsageTag.StoryClue);
case storeItemSO.ItemType.consumable:
return GetDisplayName(ItemUsageTag.Consumable);
default:
return GetDisplayName(ItemUsageTag.Other);
}
}
public static string ResolveDisplayName(expBottlesSO definition)
{
if (definition == null)
{
return GetDisplayName(ItemUsageTag.CharacterCultivation);
}
if (definition.usageTag != ItemUsageTag.Auto)
{
return GetDisplayName(definition.usageTag);
}
if (!string.IsNullOrWhiteSpace(definition.expBottleUsage))
{
return definition.expBottleUsage.Trim();
}
return GetDisplayName(ItemUsageTag.CharacterCultivation);
}
public static string ResolveDisplayName(growthMaterialSO definition)
{
if (definition == null)
{
return GetDisplayName(ItemUsageTag.CharacterBreakthrough);
}
if (definition.usageTag != ItemUsageTag.Auto)
{
return GetDisplayName(definition.usageTag);
}
if (!string.IsNullOrWhiteSpace(definition.growthMaterialUsage))
{
return definition.growthMaterialUsage.Trim();
}
return GetDisplayName(ItemUsageTag.CharacterBreakthrough);
}
public static string ResolveDisplayName(equipmentConsumableSO definition)
{
if (definition == null)
{
return GetDisplayName(ItemUsageTag.EquipmentMaterial);
}
if (definition.usageTag != ItemUsageTag.Auto)
{
return GetDisplayName(definition.usageTag);
}
if (!string.IsNullOrWhiteSpace(definition.consumableUsage))
{
return definition.consumableUsage.Trim();
}
switch (definition.consumableType)
{
case equipmentConsumableSO.EquipmentConsumableType.UpgradeMaterial:
return GetDisplayName(ItemUsageTag.EquipmentUpgrade);
case equipmentConsumableSO.EquipmentConsumableType.BreakthroughMaterial:
return GetDisplayName(ItemUsageTag.EquipmentIllusion);
case equipmentConsumableSO.EquipmentConsumableType.TransferMaterial:
return GetDisplayName(ItemUsageTag.EquipmentTransfer);
case equipmentConsumableSO.EquipmentConsumableType.FinalDreamMaterial:
return GetDisplayName(ItemUsageTag.FinalDream);
default:
return GetDisplayName(ItemUsageTag.EquipmentMaterial);
}
}
public static string ResolveDisplayName(notebook_faterType definition)
{
if (definition == null)
{
return GetDisplayName(ItemUsageTag.PreciousItem);
}
if (definition.usageTag != ItemUsageTag.Auto)
{
return GetDisplayName(definition.usageTag);
}
switch (definition.fatherType)
{
case notebook_faterType.notebook_fatherType.idols:
return GetDisplayName(ItemUsageTag.CharacterClue);
case notebook_faterType.notebook_fatherType.content:
return GetDisplayName(ItemUsageTag.StoryClue);
default:
return GetDisplayName(ItemUsageTag.PreciousItem);
}
}
public static string GetDisplayName(ItemUsageTag tag)
{
switch (tag)
{
case ItemUsageTag.CharacterCultivation:
return "角色培养";
case ItemUsageTag.CharacterBreakthrough:
return "角色突破";
case ItemUsageTag.EquipmentUpgrade:
return "装备升级";
case ItemUsageTag.EquipmentIllusion:
return "装备幻化";
case ItemUsageTag.EquipmentTransfer:
return "装备洗炼";
case ItemUsageTag.FinalDream:
return "梦醒登顶";
case ItemUsageTag.EquipmentAcquisition:
return "装备获取";
case ItemUsageTag.CharacterUnlock:
return "角色";
case ItemUsageTag.SongUnlock:
return "关卡";
case ItemUsageTag.CharacterClue:
return "角色线索";
case ItemUsageTag.StoryClue:
return "故事线索";
case ItemUsageTag.PreciousItem:
return "珍贵物品";
case ItemUsageTag.EquipmentMaterial:
return "装备材料";
case ItemUsageTag.Consumable:
return "消耗品";
case ItemUsageTag.Other:
return "其他";
case ItemUsageTag.Auto:
default:
return string.Empty;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2938ba317138c12429c1ab572ab5af03
+36
View File
@@ -37,6 +37,7 @@ public class UI_userBag : MonoBehaviour
{
InitializeToggleGroup();
BindToggles();
BindCloseButton();
SelectDefaultPanel();
}
@@ -44,6 +45,7 @@ public class UI_userBag : MonoBehaviour
{
InitializeToggleGroup();
BindToggles();
BindCloseButton();
SelectDefaultPanel();
}
@@ -54,6 +56,7 @@ public class UI_userBag : MonoBehaviour
UnbindToggle(equipIllusion, HandleEquipIllusionChanged);
UnbindToggle(equipAttributeTransfer, HandleEquipAttributeTransferChanged);
UnbindToggle(equipAwake, HandleEquipAwakeChanged);
UnbindCloseButton();
}
private void InitializeToggleGroup()
@@ -111,6 +114,27 @@ public class UI_userBag : MonoBehaviour
toggle.onValueChanged.RemoveListener(action);
}
private void BindCloseButton()
{
if (closeBagButton == null)
{
return;
}
closeBagButton.onClick.RemoveListener(HandleCloseBagClicked);
closeBagButton.onClick.AddListener(HandleCloseBagClicked);
}
private void UnbindCloseButton()
{
if (closeBagButton == null)
{
return;
}
closeBagButton.onClick.RemoveListener(HandleCloseBagClicked);
}
private void SelectDefaultPanel()
{
if (equipUpdate != null)
@@ -163,6 +187,18 @@ public class UI_userBag : MonoBehaviour
}
}
private void HandleCloseBagClicked()
{
uBag bagRoot = GetComponentInParent<uBag>();
if (bagRoot != null)
{
Destroy(bagRoot.gameObject);
return;
}
Destroy(gameObject);
}
private void ApplyPanelState(GameObject activeObject)
{
SetObjectActive(equipUpdateObj, activeObject == equipUpdateObj);
File diff suppressed because it is too large Load Diff
+3 -79
View File
@@ -136,81 +136,6 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &1461514365686782202
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3825196502166614931}
- component: {fileID: 7320344665523024176}
- component: {fileID: 2809462446489510354}
m_Layer: 5
m_Name: background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3825196502166614931
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1461514365686782202}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8166262725233797895}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7320344665523024176
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1461514365686782202}
m_CullTransparentMesh: 1
--- !u!114 &2809462446489510354
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1461514365686782202}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.6666667, g: 0.47058827, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1539455413490435037
GameObject:
m_ObjectHideFlags: 0
@@ -243,7 +168,6 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3825196502166614931}
- {fileID: 1138651227379855337}
- {fileID: 8744455463297095448}
m_Father: {fileID: 0}
@@ -289,7 +213,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.5754717, g: 0.5754717, b: 0.5754717, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
@@ -385,7 +309,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 90, y: 90}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4379564356498831347
CanvasRenderer:
@@ -415,7 +339,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 1859534b1ba2595498f81300a718e9fd, type: 3}
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
@@ -11,11 +11,12 @@ public class bagItemPreviewPrefab : MonoBehaviour
public Text itemDescription;
public TextMeshProUGUI itemAmount;
public void Bind(Color backgroundColor, Sprite icon, string displayName, string usage, string description, string amountText)
public void Bind(Color backgroundColor, Sprite backgroundSprite, Sprite icon, string displayName, string usage, string description, string amountText)
{
if (btm_img != null)
{
btm_img.color = backgroundColor;
btm_img.sprite = backgroundSprite;
btm_img.color = backgroundSprite != null ? Color.white : backgroundColor;
}
if (profileImage != null)
@@ -354,7 +354,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.54036653, g: 1, b: 0.34276712, a: 1}
m_Color: {r: 1, g: 0.75, b: 0.75, a: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 0
+144 -105
View File
@@ -50,7 +50,6 @@ public class uBag : MonoBehaviour
[Header("OBJ")]
public GameObject bagObj;
public GameObject equipObj;
public Button closeBagButton;
[Header("right panel")]
public Image btmImg;
@@ -58,7 +57,10 @@ public class uBag : MonoBehaviour
public TextMeshProUGUI itemAmount;
public Text itemName;
public Text itemUse;
public Text itemUsageLegacy;
public Text itemDescription;
public Image bottom_rarityImg;
public Sprite[] bottom_rarityImg_sprites;
[Header("list")]
public Transform itemParent;
@@ -72,8 +74,10 @@ public class uBag : MonoBehaviour
public int introductionHorizontalOffset = 12;
[Header("colors")]
public bool useRarityColorForItemName = true;
public Color fallbackColor = Color.white;
public Sprite fallbackItemIcon;
public Sprite fallbackBackgroundSprite;
public ItemRarityColorConfigSO rarityColorConfig;
[Header("paths")]
@@ -97,7 +101,6 @@ public class uBag : MonoBehaviour
{
InitializeToggleGroup();
BindToggles();
BindCloseButton();
BindLedgerEvents();
InitializeViewMode();
SelectDefaultCategory();
@@ -107,7 +110,6 @@ public class uBag : MonoBehaviour
{
InitializeToggleGroup();
BindToggles();
BindCloseButton();
BindLedgerEvents();
InitializeViewMode();
Rebuild();
@@ -120,7 +122,6 @@ public class uBag : MonoBehaviour
UnbindToggle(preciousToggle, HandlePreciousChanged);
UnbindToggle(otherToggle, HandleOtherChanged);
UnbindToggle(equipSystemToggle, HandleEquipSystemChanged);
UnbindCloseButton();
UnbindLedgerEvents();
HideCurrentPreview();
}
@@ -163,27 +164,6 @@ public class uBag : MonoBehaviour
RebindToggle(equipSystemToggle, HandleEquipSystemChanged);
}
private void BindCloseButton()
{
if (closeBagButton == null)
{
return;
}
closeBagButton.onClick.RemoveListener(HandleCloseBagClicked);
closeBagButton.onClick.AddListener(HandleCloseBagClicked);
}
private void UnbindCloseButton()
{
if (closeBagButton == null)
{
return;
}
closeBagButton.onClick.RemoveListener(HandleCloseBagClicked);
}
private void RebindToggle(Toggle toggle, UnityAction<bool> action)
{
if (toggle == null)
@@ -277,11 +257,6 @@ public class uBag : MonoBehaviour
SetObjectActive(equipObj, isOn);
}
private void HandleCloseBagClicked()
{
Destroy(gameObject);
}
private void ApplyCategory(BagCategory category)
{
currentCategory = category;
@@ -412,7 +387,10 @@ public class uBag : MonoBehaviour
Color color = rarityColorConfig != null
? rarityColorConfig.GetColor(entry.rarity, fallbackColor)
: fallbackColor;
previewView.Bind(color, icon, entry.displayName, entry.usage, entry.description, entry.amountText);
Sprite backgroundSprite = rarityColorConfig != null
? rarityColorConfig.GetBackgroundSprite(entry.rarity, fallbackBackgroundSprite)
: fallbackBackgroundSprite;
previewView.Bind(color, backgroundSprite, icon, entry.displayName, entry.usage, entry.description, entry.amountText);
}
PositionIntroduction(source, spawnedIntroduction);
@@ -466,7 +444,7 @@ public class uBag : MonoBehaviour
: definition != null && !string.IsNullOrEmpty(definition.expBottleName) ? definition.expBottleName : descriptor.DisplayName,
countText = count.ToString(),
amountText = count.ToString(),
usage = ResolveExpBottleUsage(sourceDefinition),
usage = ItemUsageTagUtility.ResolveDisplayName(sourceDefinition),
description = BuildPreferredDescription(
storeItem != null ? storeItem.itemDetailedDescription : null,
sourceDefinition != null ? sourceDefinition.expBottleDescription : null,
@@ -508,7 +486,7 @@ public class uBag : MonoBehaviour
: definition != null && !string.IsNullOrEmpty(definition.growthMaterialName) ? definition.growthMaterialName : descriptor.DisplayName,
countText = count.ToString(),
amountText = count.ToString(),
usage = ResolveGrowthMaterialUsage(sourceDefinition),
usage = ItemUsageTagUtility.ResolveDisplayName(sourceDefinition),
description = BuildPreferredDescription(
storeItem != null ? storeItem.itemDetailedDescription : null,
sourceDefinition != null ? sourceDefinition.growthMaterialDescription : null,
@@ -550,7 +528,7 @@ public class uBag : MonoBehaviour
: definition != null && !string.IsNullOrEmpty(definition.consumableName) ? definition.consumableName : descriptor.DisplayName,
countText = count.ToString(),
amountText = count.ToString(),
usage = ResolveEquipmentConsumableUsage(sourceDefinition),
usage = ItemUsageTagUtility.ResolveDisplayName(sourceDefinition),
description = BuildPreferredDescription(
storeItem != null ? storeItem.itemDetailedDescription : null,
sourceDefinition != null ? sourceDefinition.consumableDescription : null,
@@ -588,7 +566,7 @@ public class uBag : MonoBehaviour
displayName = story.class_name,
countText = "1",
amountText = "1",
usage = ResolveNotebookUsage(story),
usage = ItemUsageTagUtility.ResolveDisplayName(story),
description = story.class_description,
icon = ResolvePreferredSprite(story.class_image, fallbackItemIcon),
category = BagCategory.Precious,
@@ -620,7 +598,7 @@ public class uBag : MonoBehaviour
displayName = item.itemName,
countText = "1",
amountText = "1",
usage = kind == PreciousKind.Character ? "角色" : "关卡",
usage = ItemUsageTagUtility.ResolveDisplayName(item),
description = BuildPreferredDescription(item.itemDetailedDescription, item.itemDescription),
icon = ResolvePreferredSprite(item.itemIcon, fallbackItemIcon),
category = BagCategory.Precious,
@@ -705,7 +683,10 @@ public class uBag : MonoBehaviour
Color color = rarityColorConfig != null
? rarityColorConfig.GetColor(entry.rarity, fallbackColor)
: fallbackColor;
prefabView.Bind(this, icon, entry.countText, color, introductionHoverDelay);
Sprite backgroundSprite = rarityColorConfig != null
? rarityColorConfig.GetBackgroundSprite(entry.rarity, fallbackBackgroundSprite)
: fallbackBackgroundSprite;
prefabView.Bind(this, icon, entry.countText, color, backgroundSprite, introductionHoverDelay);
viewEntries[prefabView] = entry;
}
@@ -754,10 +735,22 @@ public class uBag : MonoBehaviour
Color color = rarityColorConfig != null
? rarityColorConfig.GetColor(entry.rarity, fallbackColor)
: fallbackColor;
Sprite backgroundSprite = rarityColorConfig != null
? rarityColorConfig.GetBackgroundSprite(entry.rarity, fallbackBackgroundSprite)
: fallbackBackgroundSprite;
if (btmImg != null)
{
btmImg.color = color;
btmImg.sprite = backgroundSprite;
btmImg.color = backgroundSprite != null ? Color.white : color;
}
if (bottom_rarityImg != null)
{
Sprite raritySprite = ResolveBottomRaritySprite(entry.rarity);
bottom_rarityImg.sprite = raritySprite;
bottom_rarityImg.enabled = raritySprite != null;
bottom_rarityImg.color = Color.white;
}
if (itemDprofile != null)
@@ -774,7 +767,9 @@ public class uBag : MonoBehaviour
if (itemName != null)
{
itemName.text = entry.displayName ?? string.Empty;
itemName.supportRichText = false;
itemName.text = StripRichTextTags(entry.displayName);
itemName.color = useRarityColorForItemName ? color : Color.white;
}
if (itemUse != null)
@@ -782,6 +777,11 @@ public class uBag : MonoBehaviour
itemUse.text = entry.usage ?? string.Empty;
}
if (itemUsageLegacy != null)
{
itemUsageLegacy.text = entry.usage ?? string.Empty;
}
if (itemDescription != null)
{
itemDescription.text = entry.description ?? string.Empty;
@@ -792,7 +792,16 @@ public class uBag : MonoBehaviour
{
if (btmImg != null)
{
btmImg.color = fallbackColor;
btmImg.sprite = fallbackBackgroundSprite;
btmImg.color = fallbackBackgroundSprite != null ? Color.white : fallbackColor;
}
if (bottom_rarityImg != null)
{
Sprite fallbackRaritySprite = GetBottomRarityFallbackSprite();
bottom_rarityImg.sprite = fallbackRaritySprite;
bottom_rarityImg.enabled = fallbackRaritySprite != null;
bottom_rarityImg.color = Color.white;
}
if (itemDprofile != null)
@@ -809,7 +818,9 @@ public class uBag : MonoBehaviour
if (itemName != null)
{
itemName.supportRichText = false;
itemName.text = string.Empty;
itemName.color = Color.white;
}
if (itemUse != null)
@@ -817,6 +828,11 @@ public class uBag : MonoBehaviour
itemUse.text = string.Empty;
}
if (itemUsageLegacy != null)
{
itemUsageLegacy.text = string.Empty;
}
if (itemDescription != null)
{
itemDescription.text = string.Empty;
@@ -855,6 +871,94 @@ public class uBag : MonoBehaviour
return string.CompareOrdinal(left.displayName, right.displayName);
}
private static string StripRichTextTags(string value)
{
if (string.IsNullOrEmpty(value))
{
return string.Empty;
}
bool insideTag = false;
System.Text.StringBuilder builder = null;
for (int i = 0; i < value.Length; i++)
{
char current = value[i];
if (current == '<')
{
if (!insideTag)
{
builder ??= new System.Text.StringBuilder(value.Length);
}
insideTag = true;
continue;
}
if (current == '>')
{
insideTag = false;
continue;
}
if (!insideTag)
{
if (builder != null)
{
builder.Append(current);
}
}
}
return builder != null ? builder.ToString() : value;
}
private Sprite ResolveBottomRaritySprite(ItemRarity rarity)
{
if (bottom_rarityImg_sprites != null)
{
if (bottom_rarityImg_sprites.Length >= System.Enum.GetValues(typeof(ItemRarity)).Length)
{
int enumIndex = (int)rarity;
if (enumIndex >= 0 && enumIndex < bottom_rarityImg_sprites.Length)
{
Sprite directSprite = bottom_rarityImg_sprites[enumIndex];
if (directSprite != null)
{
return directSprite;
}
}
}
else if (rarity != ItemRarity.None)
{
int compactIndex = (int)rarity - 1;
if (compactIndex >= 0 && compactIndex < bottom_rarityImg_sprites.Length)
{
Sprite compactSprite = bottom_rarityImg_sprites[compactIndex];
if (compactSprite != null)
{
return compactSprite;
}
}
}
}
return GetBottomRarityFallbackSprite();
}
private Sprite GetBottomRarityFallbackSprite()
{
if (rarityColorConfig != null)
{
Sprite noneSprite = rarityColorConfig.GetBackgroundSprite(ItemRarity.None, fallbackBackgroundSprite);
if (noneSprite != null)
{
return noneSprite;
}
}
return fallbackBackgroundSprite;
}
private expBottlesSO[] LoadExpBottleDefinitions()
{
var result = new List<expBottlesSO>();
@@ -1115,71 +1219,6 @@ public class uBag : MonoBehaviour
return null;
}
private static string ResolveNotebookUsage(notebook_faterType story)
{
if (story == null)
{
return string.Empty;
}
switch (story.fatherType)
{
case notebook_faterType.notebook_fatherType.idols:
return "角色线索";
case notebook_faterType.notebook_fatherType.content:
return "故事线索";
default:
return "珍贵物品";
}
}
private static string ResolveExpBottleUsage(expBottlesSO definition)
{
if (definition != null && !string.IsNullOrWhiteSpace(definition.expBottleUsage))
{
return definition.expBottleUsage;
}
return "角色培养";
}
private static string ResolveGrowthMaterialUsage(growthMaterialSO definition)
{
if (definition != null && !string.IsNullOrWhiteSpace(definition.growthMaterialUsage))
{
return definition.growthMaterialUsage;
}
return "角色突破";
}
private static string ResolveEquipmentConsumableUsage(equipmentConsumableSO definition)
{
if (definition != null && !string.IsNullOrWhiteSpace(definition.consumableUsage))
{
return definition.consumableUsage;
}
if (definition == null)
{
return "装备材料";
}
switch (definition.consumableType)
{
case equipmentConsumableSO.EquipmentConsumableType.UpgradeMaterial:
return "装备升级";
case equipmentConsumableSO.EquipmentConsumableType.BreakthroughMaterial:
return "装备幻化";
case equipmentConsumableSO.EquipmentConsumableType.TransferMaterial:
return "装备洗炼";
case equipmentConsumableSO.EquipmentConsumableType.FinalDreamMaterial:
return "梦醒登顶";
default:
return "装备材料";
}
}
private static Sprite ResolvePreferredSprite(params Sprite[] sprites)
{
for (int i = 0; i < sprites.Length; i++)
+3 -2
View File
@@ -15,7 +15,7 @@ public class uBagItemPrefab : MonoBehaviour, IPointerEnterHandler, IPointerExitH
private Coroutine hoverRoutine;
private float hoverDelaySeconds = 0.5f;
public void Bind(uBag bagOwner, Sprite icon, string countText, Color backgroundColor, float hoverDelay)
public void Bind(uBag bagOwner, Sprite icon, string countText, Color backgroundColor, Sprite backgroundSprite, float hoverDelay)
{
owner = bagOwner;
hoverDelaySeconds = hoverDelay > 0f ? hoverDelay : 0.5f;
@@ -34,7 +34,8 @@ public class uBagItemPrefab : MonoBehaviour, IPointerEnterHandler, IPointerExitH
if (itemBtmImg != null)
{
itemBtmImg.color = backgroundColor;
itemBtmImg.sprite = backgroundSprite;
itemBtmImg.color = backgroundSprite != null ? Color.white : backgroundColor;
}
}