66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class esDesPrefab : MonoBehaviour
|
|
{
|
|
public Image skillProfile;
|
|
public Text skillName;
|
|
public Text skillDescription;
|
|
public Text skill_story;
|
|
|
|
public void Bind(string displayName, Sprite icon, string description)
|
|
{
|
|
if (skillProfile != null)
|
|
{
|
|
skillProfile.sprite = icon;
|
|
skillProfile.enabled = icon != null;
|
|
}
|
|
|
|
if (skillName != null)
|
|
{
|
|
skillName.text = displayName ?? string.Empty;
|
|
}
|
|
|
|
string mainText = description ?? string.Empty;
|
|
string storyText = string.Empty;
|
|
int splitIndex = mainText.IndexOf("\n\n", System.StringComparison.Ordinal);
|
|
if (splitIndex >= 0)
|
|
{
|
|
storyText = mainText.Substring(splitIndex + 2).Trim();
|
|
mainText = mainText.Substring(0, splitIndex).Trim();
|
|
}
|
|
|
|
if (skillDescription != null)
|
|
{
|
|
skillDescription.text = mainText;
|
|
}
|
|
|
|
if (skill_story != null)
|
|
{
|
|
skill_story.text = storyText;
|
|
skill_story.gameObject.SetActive(!string.IsNullOrWhiteSpace(storyText));
|
|
}
|
|
}
|
|
|
|
public void Bind(string displayName, Sprite icon, string description, string story)
|
|
{
|
|
if (skillProfile != null)
|
|
{
|
|
skillProfile.sprite = icon;
|
|
skillProfile.enabled = icon != null;
|
|
}
|
|
|
|
if (skillName != null)
|
|
skillName.text = displayName ?? string.Empty;
|
|
|
|
if (skillDescription != null)
|
|
skillDescription.text = description ?? string.Empty;
|
|
|
|
if (skill_story != null)
|
|
{
|
|
skill_story.text = story ?? string.Empty;
|
|
skill_story.gameObject.SetActive(!string.IsNullOrWhiteSpace(skill_story.text));
|
|
}
|
|
}
|
|
}
|