Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(196评价)
价格: 4069.00元
为什么list中添加元素却还是返回空?
春华发起了问答2020-11-28
1
回复
555
浏览

我在网上复制的单例A,然后用一个类B去继承A, B的一个属性就是list<T> C,我在构造函数中初始化C并添加了元素,为什么还是返回null?

具体代码:  

public sealed class CharacterManager : Singleton<CharacterManager>
{
    private List<Character> m_totalcharacterlist;
    public List<Character> TotalCharacterList
    {
        get { return m_totalcharacterlist; }
        set { m_totalcharacterlist = TotalCharacterList; }
    }

    public CharacterManager()
    {
        Debug.Log("0");
        TotalCharacterList = new List<Character>
        {
            new Character("the spirit of peach blossom", false),
            new Character("the girl with a bird", false),
            new Character("the vampire bat", false),
            new Character("the saber of killing demon", true),
            new Character("the spirit of snake", false),
            new Character("the female general ", false),
            new Character("the spirit of blade", false),
            new Character("the girl with a bird", false),
            new Character("the imperial heir", true),
        };
        Debug.Log(TotalCharacterList);
        Debug.Log("0.1");
    }
}

所有回复
  • 老师_Trigger 2020-11-29

    同学你好,可以参考一下:

    https://m.wenda.so.com/q/1534043066216378

    https://blog.csdn.net/ivan2015/article/details/79799831

    http://www.jiaonan.tv/html/blog/1/29606.htm

    还有-5条回复,点击查看
    你还没有登录,请先登录注册
发表回复
你还没有登录,请先 登录或 注册!