我收到一条错误,指出“'damageScript':成员名称不能与其封闭类型相同”它只显示它所说的“public HealthDamageInfo damageScript”;
internal class damageScript
{
public HealthDamageInfo damageScript;
public string tagName;
public string otherTag;
public string message;
// Use this for initialization
void Start()
{
damageScript = GetComponent<HealthDamageInfo>();
}
private HealthDamageInfo GetComponent<T>()
{
throw new NotImplementedException();
}
// Update is called once per frame
void Update()
{
}
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == tagName)
{
damageScript.SendMessage("SwitchInteractionTarget", message);
}
else if (other.gameObject.tag == otherTag)
{
damageScript.SendMessage("SwitchInteractionTarget", message);
}
}
}
答案 0 :(得分:2)
正如错误所述,您的班级damageScript
也不能包含变量damageScript
。如果重命名变量或类,则错误将消失。
答案 1 :(得分:0)
public HealthDamageInfo damageScript;
包含在internal class damageScript
。
您必须更改班级名称或成员变量。