这两个特性不是在命名空间UnityEditor下的,而是在UnityEngine下的
public class Player2 : MonoBehaviour {
[ContextMenuItem("Add Hp","AddHp")]
public int hp = 1000;//对属性右键弹出
void AddHp(){
this.hp += 100;
}
[ContextMenu("ResetHp")]
void ResetHp(){//扩展组件右键菜单
this.hp = 100;
}
}ContextMenuItem的第一个参数为菜单名称,第二个为要调用的方法