cusstorm编辑器中的UnityEvent变量

时间:2016-02-13 18:44:08

标签: events unity3d editor

请帮我在自定义编辑器中显示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 ?
}

2 个答案:

答案 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);