//在指定脚本中右键添加按钮 CONTEXT/组件名/按钮名
[MenuItem("CONTEXT/PlayerHealth/InitHealthAndSpeed")]
//MenuCommand : 当前右键点击的组件
static void InitHealthAndSpeed(MenuCommand cmd)
{
PlayerHealth health = cmd.context as PlayerHealth;
health.startingHealth = 200;
Debug.Log("Init");
}
[MenuItem("CONTEXT/Rigidbody/Clear")]
static void ClearMassAndGravity(MenuCommand cmd)
{
Rigidbody rgd = cmd.context as Rigidbody;
rgd.mass = 0.1f;
rgd.useGravity = false;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerHealth : MonoBehaviour
{
public int startingHealth;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}