如何在Unity上获取引用类实例?

时间:2019-07-11 03:20:31

标签: c# unity3d

此问题涉及Unity3d Engine。

如何在Inspector中轻松地向此“ R Item Probs”中添加项目类实例?

https://ibb.co/v4L5v3p https://ibb.co/vvxzt7k

我想创建一个具有所有项目名称的新枚举,然后,如果该名称与项目类的名称匹配,则获取该类的引用。

但是还有其他更好的方法吗?

public class RItemProb
{
    public RewardItem RItem;
    public float GenProb;        // this item's appearance probability
    public bool Drop100;        // 100%, this item will be dropped. 
    public int HowMany = 1;         // how many item will be given this time?, default is 1
}

public class RewardItem
{
    public string Name;
    public string Description; 
    public int Price;
    public Sprite IcomImage;
    public Rarity Rareness; 
    public float Probability;        
}

0 个答案:

没有答案