请帮我在自定义编辑器中显示UnityEvent变量。
脚本:
public class BTNPattern : MonoBehaviour {
public UnityEvent testEvent;
}
编辑脚本:
CustomEditor(typeof(BTNPattern))]
public class BTNPatternEditor : Editor {
public override void OnInspectorGUI() {
BTNPattern myTarget = (BTNPattern) target;
// what to put here to show myTarget.testEvent ?
}
答案 0 :(得分:0)
SerializedProperty sprop = serializedObject.FindProperty("testEvent");
EditorGUIUtility.LookLikeControls();
EditorGUILayout.PropertyField(sprop);
serializedObject.ApplyModifiedProperties();
public class BTNPattern : MonoBehaviour{
public List UnityEvent testEventS; }
CustomEditor(typeof(BTNPattern))]
public class BTNPatternEditor : Editor{
public override void OnInspectorGUI(){
BTNPattern myTarget = (BTNPattern)target;
// SerializedProperty sprop = serializedObject.FindProperty("testEvent");
// want to see myTarget.testEvents(1);
EditorGUIUtility.LookLikeControls();
EditorGUILayout.PropertyField(sprop);
serializedObject.ApplyModifiedProperties();
} }
答案 1 :(得分:0)
rewrite "^/videa/(.+)$" "/videa/?v=$1";
所以现在我需要表明这一点
public class BTNPattern : MonoBehaviour{
public List<UnityEvent> testEventS; }
SerializedProperty sprop = serializedObject.FindProperty("testEventS");
EditorGUILayout.PropertyField(sprop.GetArrayElementAtIndex(i), true);