我在网上复制的单例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");
}
}
同学你好,可以参考一下:
https://m.wenda.so.com/q/1534043066216378
https://blog.csdn.net/ivan2015/article/details/79799831
http://www.jiaonan.tv/html/blog/1/29606.htm