我有一个自定义的可序列化结构体,存储在列表元素中。 当结构体只有一个公共字段时
[System.Serializable]
public struct MemoryMoment {
float Importance; //Subjective
Person who;
Room where;
string when;
string what;
//string why;
public string Descr;
public MemoryMoment (float importance, Person who, Room where, string when, string what) {
this.Importance = importance;
this.who = who;
this.where = where;
this.when = when;
this.what = what;
//this.why = "UNUSED";
this.Descr = where.Type.ToString () + " " + when + ", " + who.Name + " " + what;
}
}
但是当结构体中有多个公共字段时
[System.Serializable]
public struct MemoryMoment {
public float Importance; //Subjective
Person who;
Room where;
string when;
string what;
//string why;
public string Descr;
public MemoryMoment (float importance, Person who, Room where, string when, string what) {
this.Importance = importance;
this.who = who;
this.where = where;
this.when = when;
this.what = what;
//this.why = "UNUSED";
this.Descr = where.Type.ToString () + " " + when + ", " + who.Name + " " + what;
}
}
如果结构体只是被命名为"Element N",那么如何为我的结构体提供自定义检视器名称呢?
即像这样:
[NameInInspector]
string n = "(" + Importance.ToString() + ") " + Descr;