ui基本完毕,修了一大把的bug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameServer.Client;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
@@ -92,7 +93,7 @@ public class mailSlotPrefab : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
string url = reward != null ? (reward.reward_icon_url ?? string.Empty).Trim() : string.Empty;
|
||||
string url = NormalizeRewardIconUrl(reward != null ? (reward.reward_icon_url ?? string.Empty).Trim() : string.Empty);
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
icon.sprite = fallbackRewardPreviewSprite;
|
||||
@@ -175,4 +176,33 @@ public class mailSlotPrefab : MonoBehaviour
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private static string NormalizeRewardIconUrl(string imageUrl)
|
||||
{
|
||||
string trimmed = imageUrl?.Trim() ?? string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(trimmed))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (trimmed.StartsWith("http://", System.StringComparison.OrdinalIgnoreCase)
|
||||
|| trimmed.StartsWith("https://", System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
NetworkManager network = NetworkManager.Instance;
|
||||
if (network == null || string.IsNullOrWhiteSpace(network.ServerUrl))
|
||||
{
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
string baseUrl = network.ServerUrl.TrimEnd('/');
|
||||
if (!trimmed.StartsWith("/"))
|
||||
{
|
||||
trimmed = "/" + trimmed;
|
||||
}
|
||||
|
||||
return baseUrl + trimmed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user