Skip to content

Commit 020f0e2

Browse files
committed
Edited a bit.
1 parent ef2d6d6 commit 020f0e2

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

Assets/Script Tester/Editor/Helpers.cs

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Assets/Script Tester/Editor/InspectorDrawer.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ public void Draw(bool drawHeader = true, bool readOnly = false) {
9191
if(!Helper.AssignValue(item.Info, target, item.Value)) {
9292
object value;
9393
var propDrawer = item as MethodPropertyDrawer;
94-
if(propDrawer != null && Helper.FetchValue(propDrawer.Info, target, out value)) {
95-
propDrawer.Value = value;
96-
propDrawer.GetException = null;
97-
} else
98-
propDrawer.GetException = value as Exception;
94+
if(propDrawer != null) {
95+
var success = Helper.FetchValue(propDrawer.Info, target, out value);
96+
if(success) {
97+
propDrawer.Value = value;
98+
propDrawer.GetException = null;
99+
} else
100+
propDrawer.GetException = value as Exception;
101+
}
99102
}
100103
}
101104
}

Assets/Script Tester/Editor/InspectorPlus.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void OnFocus() {
3232

3333
void OnGUI() {
3434
GUILayout.BeginHorizontal(EditorStyles.toolbar);
35-
if(GUILayout.Button("Menu", EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)))
35+
if(GUILayout.Button("Menu", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
3636
ShowMenu();
3737
if(Event.current.type == EventType.Repaint)
3838
toolbarMenuPos = GUILayoutUtility.GetLastRect();

Assets/Script Tester/Editor/MethodPropertyDrawer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ public void Draw(bool readOnly, Rect? rect = null) {
288288
}
289289
if(!readOnly && referenceModeBtn) {
290290
if(rect.HasValue) {
291-
if(GUI.Button(Helper.ScaleRect(rect.Value, 1, 0.5F, 0, 0, -EditorGUIUtility.singleLineHeight, -7.5F, 15, 15), "...", EditorStyles.miniButton))
291+
if(GUI.Button(Helper.ScaleRect(rect.Value, 1, 0.5F, 0, 0, -EditorGUIUtility.singleLineHeight, -7.5F, 15, 15), GUIContent.none, Helper.GetGUIStyle("MiniPullDown")))
292292
ShowMenu(rect.Value);
293293
} else {
294-
if(GUILayout.Button("...", EditorStyles.miniButton, GUILayout.Width(EditorGUIUtility.singleLineHeight)))
294+
if(GUILayout.Button(GUIContent.none, Helper.GetGUIStyle("MiniPullDown"), GUILayout.Width(EditorGUIUtility.singleLineHeight)))
295295
ShowMenu(menuButtonRect);
296296
if(Event.current.type == EventType.Repaint)
297297
menuButtonRect = GUILayoutUtility.GetLastRect();

0 commit comments

Comments
 (0)