@@ -275,28 +275,41 @@ static int MaskedEnumFieldPostProcess(int[] itemValues, int val, int maskVal, in
275275 }
276276
277277 internal static string StringField ( string label , string value , bool readOnly , params GUILayoutOption [ ] options ) {
278- int lines = CountLines ( value ) ;
279- if ( lines > 1 ) {
280- var _opts = options . ToList ( ) ;
281- _opts . Add ( GUILayout . Height ( EditorGUIUtility . singleLineHeight * lines ) ) ;
282- _opts . Add ( GUILayout . MaxWidth ( EditorGUIUtility . currentViewWidth ) ) ;
283- EditorGUILayout . BeginVertical ( ) ;
284- EditorGUILayout . PrefixLabel ( label ) ;
285- if ( readOnly )
286- EditorGUILayout . SelectableLabel ( value , EditorStyles . textArea , _opts . ToArray ( ) ) ;
287- else
288- value = EditorGUILayout . TextArea ( value , _opts . ToArray ( ) ) ;
289- EditorGUILayout . EndVertical ( ) ;
278+ int length = value == null ? 0 : value . Length ;
279+ if ( length > 5000 ) {
280+ EditorGUILayout . BeginHorizontal ( ) ;
281+ EditorGUILayout . LabelField ( label , "Text too long to display (" + length + " characters)" ) ;
282+ if ( GUILayout . Button ( "Copy" , GUILayout . ExpandWidth ( false ) ) )
283+ EditorGUIUtility . systemCopyBuffer = value ;
284+ if ( ! readOnly && GUILayout . Button ( "Paste" , GUILayout . ExpandWidth ( false ) ) ) {
285+ value = EditorGUIUtility . systemCopyBuffer ;
286+ GUI . changed = true ;
287+ }
288+ EditorGUILayout . EndHorizontal ( ) ;
290289 } else {
291- if ( readOnly ) {
290+ int lines = CountLines ( value ) ;
291+ if ( lines > 1 ) {
292292 var _opts = options . ToList ( ) ;
293- _opts . Add ( GUILayout . Height ( EditorGUIUtility . singleLineHeight ) ) ;
294- EditorGUILayout . BeginHorizontal ( ) ;
293+ _opts . Add ( GUILayout . Height ( EditorGUIUtility . singleLineHeight * lines ) ) ;
294+ _opts . Add ( GUILayout . MaxWidth ( EditorGUIUtility . currentViewWidth ) ) ;
295+ EditorGUILayout . BeginVertical ( ) ;
295296 EditorGUILayout . PrefixLabel ( label ) ;
296- EditorGUILayout . SelectableLabel ( value , EditorStyles . textField , _opts . ToArray ( ) ) ;
297- EditorGUILayout . EndHorizontal ( ) ;
298- } else
299- value = EditorGUILayout . TextField ( label , value , options ) ;
297+ if ( readOnly )
298+ EditorGUILayout . SelectableLabel ( value , EditorStyles . textArea , _opts . ToArray ( ) ) ;
299+ else
300+ value = EditorGUILayout . TextArea ( value , _opts . ToArray ( ) ) ;
301+ EditorGUILayout . EndVertical ( ) ;
302+ } else {
303+ if ( readOnly ) {
304+ var _opts = options . ToList ( ) ;
305+ _opts . Add ( GUILayout . Height ( EditorGUIUtility . singleLineHeight ) ) ;
306+ EditorGUILayout . BeginHorizontal ( ) ;
307+ EditorGUILayout . PrefixLabel ( label ) ;
308+ EditorGUILayout . SelectableLabel ( value , EditorStyles . textField , _opts . ToArray ( ) ) ;
309+ EditorGUILayout . EndHorizontal ( ) ;
310+ } else
311+ value = EditorGUILayout . TextField ( label , value , options ) ;
312+ }
300313 }
301314 return value ;
302315 }
0 commit comments