1.把下面脚本放到Editor文件夹下,这样脚本继承Button之后,新声明的public变量才能在Inspector面板显示出来. using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEditor.UI; using UnityEngine; [CustomEditor(typeof(MyButton), true)] [CanEditMultipleObjects]