public static PopupButton ( |
||
label | ||
buttonContent | ||
style | ||
buttonRect | ||
return | bool |
public static bool PopupButton(GUIContent label, GUIContent buttonContent, GUIStyle style, out Rect buttonRect, params GUILayoutOption[] options)
{
if (label != null)
{
Rect position = EditorGUILayout.s_LastRect = EditorGUILayout.GetControlRect(true, 16f, style, options);
int id = GUIUtility.GetControlID("EditorPopup".GetHashCode(), FocusType.Keyboard, position);
buttonRect = EditorGUI.PrefixLabel(position, id, label);
}
else
{
Rect rect2 = GUILayoutUtility.GetRect(buttonContent, style, options);
buttonRect = rect2;
}
return EditorGUI.ButtonMouseDown(buttonRect, buttonContent, FocusType.Passive, style);
}
public static void AssetPopup <T>(SerializedProperty serializedProperty, GUIContent label, string fileExtension, string defaultFieldName) where T : UnityEngine.Object, new() { bool showMixedValue = EditorGUI.showMixedValue; EditorGUI.showMixedValue = serializedProperty.hasMultipleDifferentValues; string objectReferenceTypeString = serializedProperty.objectReferenceTypeString; GUIContent buttonContent; if (serializedProperty.hasMultipleDifferentValues) { buttonContent = EditorGUI.mixedValueContent; } else if (serializedProperty.objectReferenceValue != null) { buttonContent = GUIContent.Temp(serializedProperty.objectReferenceStringValue); } else { buttonContent = GUIContent.Temp(defaultFieldName); } Rect buttonRect; if (AudioMixerEffectGUI.PopupButton(label, buttonContent, EditorStyles.popup, out buttonRect, new GUILayoutOption[0])) { AssetPopupBackend.ShowAssetsPopupMenu <T>(buttonRect, objectReferenceTypeString, serializedProperty, fileExtension, defaultFieldName); } EditorGUI.showMixedValue = showMixedValue; }