Example #1
0
    private void GenerateKeywordCard(Keyword keyword)
    {
        RectTransform        prototype = keyword.basic ? abilityInfoCardPrefab : keywordInfoCardPrefab;
        List <RectTransform> list      = keyword.basic ? ref abilityCards : ref keywordCards;

        RectTransform keywordCard = Instantiate(prototype, transform);

        keywordCard.transform.position  = prototype.transform.position;
        keywordCard.transform.position -= Vector3.up * (keywordCard.rect.height + 15f) * list.Count;
        keywordCard.gameObject.SetActive(true);
        list.Add(keywordCard);

        // Set Sprite
        Image image = keywordCard.transform.Find("KeywordIcon").GetComponent <Image>();

        image.sprite = keyword.GetSprite();

        // Set Text
        TextMeshProUGUI keywordText = keywordCard.transform.Find("KeywordText").GetComponent <TextMeshProUGUI>();

        keywordText.text = SText.Format($"<b>{keyword.keywordName}:</b> {keyword.keywordText}");
    }