【发布时间】:2017-09-22 03:22:36
【问题描述】:
我在 Unity 中做游戏,需要帮助将我的结构列表转换为字符串。我下面的代码放在一个名为 MonsterHandler 的类中。
public enum S_STATE
{
S_IDLE,
S_PATROL,
S_ATTACK,
NONE
}
public struct MONSTERS
{
public string Name;
public int Health;
public int Damage;
public S_STATE State;
};
public List<MONSTERS> monsterList= new List<MONSTERS>();
void Start()
{
// add data into the monsterList
// Debug.Log(monsterList.Count); // print out 5
Debug.Log(monsterList.ToArray()); //printed out "MonsterHandler + MONSTERS"
// i want to do something like this
// "Monster_Zombie, 100, 20, S_IDLE, Monster_Donkey, 80, 30, S_IDLE, Monster_Chicken, 120 , 10, IDLE,.."
}
}
有没有办法将我的结构列表转换为字符串[],然后转换为字符串?或者还有其他方法
【问题讨论】:
-
您要打印什么?
-
@KeithNicholas 我想打印出这样的东西
-
"Monster_Zombie, 100, 20, S_IDLE, Monster_Donkey, 80, 30, S_IDLE, Monster_Chicken, 120, 10, IDLE,.."
标签: c# string list unity3d casting