我创建了ScriptableObject,但不幸的是我无法将创建的类分配给它。我该怎么办?
代码
CardScript
屏幕截图
我试图做类似的事情,但是现在我无法将脚本添加到纸牌游戏对象中
public class CardDisplay : MonoBehaviour
{
public Card card;
public TextMeshProUGUI nameText;
public TextMeshProUGUI descText;
public TextMeshProUGUI APText;
public Image cardbackground;
public Image artworkImage;
public Image maskImage;
public void SetProperties()
{
///To take a data from localizer. Shalalalaaaa.
var NameText = LocalizationSettings.StringDatabase.GetLocalizedStringAsync("CARD_NAME", card.Key);
NameText.Completed += (op) => nameText.text = op.Result;
var DescText = LocalizationSettings.StringDatabase.GetLocalizedStringAsync("CARD_DESC", card.Key);
DescText.Completed += (op) => descText.text = op.Result;
APText.text = card.ActionPoint.ToString();
if (card.Artwork != null)
artworkImage.sprite = card.Artwork;
cardbackground.sprite = Resources.Load<Sprite>("Items/Card/CardBackgrounds/Card_"+card.rarity);
maskImage.sprite = Resources.Load<Sprite>("Items/Card/CardMasks/"+ card.rarity +"_Mask");
foreach (CardScript a in Resources.LoadAll<CardScript>("Items/Card/CardScripts"))
{
Debug.Log(a.name);
}
if(Resources.Load<CardScript>("Items/Card/CardScripts/"+card.Key) != null)
gameObject.AddComponent(Resources.Load("Items/Card/CardScripts/"+card.Key).GetType());
}
}