static SerializedDictionaryDrawer() { storage = new DrawerDataStorage <ReorderableListBase, CreationArgs>(false, (p, a) => { var pairsProperty = a.pairsProperty; var errorProperty = a.errorProperty; var list = new ToolboxEditorList(pairsProperty, "Pair", true, true, false); list.drawHeaderCallback += (rect) => { //cache preprocessed label to get prefab related functions var label = EditorGUI.BeginProperty(rect, null, p); //create additional warning message if there is key collision if (errorProperty.boolValue) { label.image = EditorGuiUtility.GetHelpIcon(MessageType.Warning); label.text += string.Format(" [{0}]", Style.warningMessage); } EditorGUI.LabelField(rect, label); EditorGUI.EndProperty(); }; list.drawFooterCallback += (rect) => { list.DrawStandardFooter(rect); }; list.drawElementCallback += (rect, index, isActive, isFocused) => { list.DrawStandardElement(rect, index, isActive, isFocused, true); }; return(list); }); }
static Style() { backgroundStyle = new GUIStyle(EditorStyles.helpBox) { padding = new RectOffset(13, 13, 8, 8) }; foldoutStyle = new GUIStyle(EditorStyles.miniButton) { #if UNITY_2019_3_OR_NEWER fontSize = 10, #else fontSize = 9, #endif alignment = TextAnchor.MiddleCenter }; previewStyle = new GUIStyle(); previewStyle.normal.background = EditorGuiUtility.CreateColorTexture(); settingsStyle = new GUIStyle() { #if UNITY_2019_3_OR_NEWER padding = new RectOffset(4, 0, 0, 0) #else padding = new RectOffset(5, 0, 0, 0) #endif }; } }
/// <summary> /// Draws provided property as a warning label. /// </summary> public static void DrawEmptyProperty(Rect position, SerializedProperty property, GUIContent label) { label = label ?? new GUIContent(property.displayName); #if UNITY_2019_1_OR_NEWER label.image = EditorGuiUtility.GetHelpIcon(MessageType.Warning); #endif EditorGUI.LabelField(position, label); }
public override void OnGui(Rect rect) { var content = EditorGuiUtility.GetObjectContent(target, typeof(GameObject)); if (content.image) { GUI.Label(rect, content.image); } }
protected virtual void DrawInvalidDrawerLabel(Rect position, string label) { var content = new GUIContent(label); #if UNITY_2019_1_OR_NEWER content.image = EditorGuiUtility.GetHelpIcon(MessageType.Warning); #endif EditorGUI.LabelField(position, content); }
static Style() { inlinedStyle = new GUIStyle(EditorStyles.helpBox) { padding = new RectOffset(13, 12, 8, 8) }; foldoutStyle = new GUIStyle(EditorStyles.foldout) { fontSize = 9, alignment = TextAnchor.MiddleLeft }; previewStyle = new GUIStyle(); previewStyle.normal.background = EditorGuiUtility.CreatePersistantTexture(); }
static SerializedDictionaryDrawer() { storage = new DrawerDataStorage <ReorderableListBase, CreationArgs>(false, (p, a) => { var pairsProperty = a.pairsProperty; var errorProperty = a.errorProperty; var list = new ToolboxEditorList(pairsProperty, "Pair", true, true, false); list.drawHeaderCallback += (rect) => { //cache preprocessed label to get prefab related functions var label = EditorGUI.BeginProperty(rect, null, p); //create additional warning message if there is key collision if (errorProperty.boolValue) { label.image = EditorGuiUtility.GetHelpIcon(MessageType.Warning); label.text += string.Format(" [{0}]", Style.warningMessage); } EditorGUI.LabelField(rect, label); EditorGUI.EndProperty(); }; list.drawFooterCallback += (rect) => { list.DrawStandardFooter(rect); }; list.drawElementCallback += (rect, index, isActive, isFocused) => { var element = pairsProperty.GetArrayElementAtIndex(index); var content = list.GetElementContent(element, index); using (var propertyScope = new PropertyScope(element, content)) { if (!propertyScope.IsVisible) { return; } //draw key/value children and use new, shortened labels EditorGUI.indentLevel++; EditorGUILayout.PropertyField(element.FindPropertyRelative("key"), new GUIContent("K")); EditorGUILayout.PropertyField(element.FindPropertyRelative("value"), new GUIContent("V")); EditorGUI.indentLevel--; } }; return(list); }); }