DrawComponentEvents() public static method

Draw all UnityEventBase fields
public static DrawComponentEvents ( UnityEditor.SerializedProperty component, UnityEditor.SerializedProperty eventProperty ) : int
component UnityEditor.SerializedProperty
eventProperty UnityEditor.SerializedProperty
return int
コード例 #1
0
    public override void OnInspectorGUI()
    {
        // Only update the focused element name during the Layout event, since all controls must be static between Layout & Repaint.
        if (Event.current.type == EventType.Layout)
        {
            _focusedControl = GUI.GetNameOfFocusedControl();
        }

        serializedObject.Update();

        EditorGUILayout.PropertyField(_vprop);
        if (_vprop.objectReferenceValue != null)
        {
            INPCBindingEditor.DrawComponentEvents(_vprop, _veprop);
        }

        INPCBindingEditor.DrawCRefProp(serializedObject.targetObject.GetInstanceID(), _focusedControl, _vmprop, GUIContent.none, typeof(ICommand));

        var rect  = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
        var label = EditorGUI.BeginProperty(rect, null, _parmprop);

        GUI.Label(rect, label);

        //parameter type
        var typeProp = _parmprop.FindPropertyRelative("Type");
        var trect    = rect;

        trect.x     += EditorGUIUtility.labelWidth;
        trect.width -= EditorGUIUtility.labelWidth;
        EditorGUI.PropertyField(trect, typeProp);

        //value field
        var typeValue = (BindingParameterType)Enum.GetValues(typeof(BindingParameterType)).GetValue(typeProp.enumValueIndex);
        SerializedProperty valueProp = null;

        switch (typeValue)
        {
        case BindingParameterType.None:
            break;

        default:
            valueProp = _parmprop.FindPropertyRelative(typeValue.ToString());
            break;
        }
        if (valueProp != null)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(valueProp);
            EditorGUI.indentLevel--;
        }

        EditorGUI.EndProperty();

        serializedObject.ApplyModifiedProperties();
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(_vprop);
        if (_vprop.objectReferenceValue != null)
        {
            INPCBindingEditor.DrawComponentEvents(_vprop, _veprop);
        }

        INPCBindingEditor.DrawCRefProp(_vmprop, GUIContent.none, typeof(ICommand));

        var rect  = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
        var label = EditorGUI.BeginProperty(rect, null, _parmprop);

        GUI.Label(rect, label);

        //parameter type
        var typeProp = _parmprop.FindPropertyRelative("Type");
        var trect    = rect;

        trect.x     += EditorGUIUtility.labelWidth;
        trect.width -= EditorGUIUtility.labelWidth;
        EditorGUI.PropertyField(trect, typeProp);

        //value field
        var typeValue = (BindingParameterType)Enum.GetValues(typeof(BindingParameterType)).GetValue(typeProp.enumValueIndex);
        SerializedProperty valueProp = null;

        switch (typeValue)
        {
        case BindingParameterType.None:
            break;

        default:
            valueProp = _parmprop.FindPropertyRelative(typeValue.ToString());
            break;
        }
        if (valueProp != null)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(valueProp);
            EditorGUI.indentLevel--;
        }

        EditorGUI.EndProperty();

        serializedObject.ApplyModifiedProperties();
    }