使用 ContextMenu
Attribute 不运行 Unity, 执行 MonoBehavior 函数
示例代码如下:
[ContextMenu("ResizeDialogueText")]
private void ResizeDialogueTextHeight()
{
var height = dialogueText.preferredHeight;
var size = dialogueBgRect.sizeDelta;
size.y = height + 60f;
dialogueBgRect.sizeDelta = size;
var pos = dialogueText.transform.localPosition;
pos.y = height + 30f;
dialogueText.transform.localPosition = pos;
}
–EOF–