好多新内容
This commit is contained in:
@@ -13,6 +13,7 @@ using Steamworks;
|
||||
public class playerMessagePrefab : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Image playerProfile;
|
||||
[SerializeField] Image playerTitleImage;
|
||||
[SerializeField] Text playerTitle;
|
||||
[SerializeField] Text playerName;
|
||||
[SerializeField] Text messageText;
|
||||
@@ -48,14 +49,16 @@ public class playerMessagePrefab : MonoBehaviour
|
||||
}
|
||||
|
||||
public void Bind(string steamId, string avatarUrl, string displayName, string title, string content, Color bubbleColor)
|
||||
{
|
||||
Bind(steamId, avatarUrl, displayName, string.Empty, title, content, bubbleColor);
|
||||
}
|
||||
|
||||
public void Bind(string steamId, string avatarUrl, string displayName, string titleId, string title, string content, Color bubbleColor)
|
||||
{
|
||||
_boundSteamId = steamId ?? string.Empty;
|
||||
_boundAvatarUrl = avatarUrl ?? string.Empty;
|
||||
|
||||
if (playerTitle != null)
|
||||
{
|
||||
playerTitle.text = string.IsNullOrWhiteSpace(title) ? string.Empty : title;
|
||||
}
|
||||
BindPlayerTitle(titleId, title);
|
||||
|
||||
if (playerName != null)
|
||||
{
|
||||
@@ -79,6 +82,51 @@ public class playerMessagePrefab : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void BindPlayerTitle(string titleId, string title)
|
||||
{
|
||||
EnsureTitleImageReference();
|
||||
|
||||
PlayerTitleResolver.ResolvedTitle resolvedTitle = PlayerTitleResolver.Resolve(titleId, title);
|
||||
bool hasTitleSprite = resolvedTitle.HasSprite;
|
||||
bool hasTitleText = resolvedTitle.HasText;
|
||||
|
||||
if (playerTitleImage != null)
|
||||
{
|
||||
playerTitleImage.sprite = resolvedTitle.titleSprite;
|
||||
playerTitleImage.enabled = hasTitleSprite;
|
||||
playerTitleImage.gameObject.SetActive(hasTitleSprite);
|
||||
if (!hasTitleSprite)
|
||||
{
|
||||
playerTitleImage.sprite = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerTitle != null)
|
||||
{
|
||||
playerTitle.text = !hasTitleSprite && hasTitleText ? resolvedTitle.titleText : string.Empty;
|
||||
playerTitle.gameObject.SetActive(!hasTitleSprite && hasTitleText);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureTitleImageReference()
|
||||
{
|
||||
if (playerTitleImage != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Transform[] children = GetComponentsInChildren<Transform>(true);
|
||||
for (int i = 0; i < children.Length; i++)
|
||||
{
|
||||
Transform child = children[i];
|
||||
if (child != null && child.name == "玩家称号image")
|
||||
{
|
||||
playerTitleImage = child.GetComponent<Image>();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task WarmAvatarCacheAsync(string steamId, string avatarUrl)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(steamId) && string.IsNullOrWhiteSpace(avatarUrl))
|
||||
|
||||
Reference in New Issue
Block a user