Skip to content

Commit 715f9a5

Browse files
committed
tidying up inspector
1 parent ad157d4 commit 715f9a5

File tree

3 files changed

+27
-35
lines changed

3 files changed

+27
-35
lines changed

Editor/Scripts/Layout/Layout.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
////////////////////////////////////////////////////////////////////////////////
22

3-
using UnityEngine;
4-
53
namespace MG.MDV
64
{
75
public class Layout

Editor/Scripts/MarkdownEditor.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,24 @@ public override bool UseDefaultMargins()
5555
return false;
5656
}
5757

58-
#if UNITY_2020_1_OR_NEWER
59-
public override void OnInspectorGUI()
60-
{
61-
DrawEditor();
62-
}
63-
64-
protected override void OnHeaderGUI()
65-
{
66-
// DrawEditor();
67-
}
68-
#elif UNITY_2019_2_OR_NEWER
69-
// TODO: workaround for bug in 2019.2
70-
// https://forum.unity.com/threads/oninspectorgui-not-being-called-on-defaultasset-in-2019-2-0f1.724328/
7158
protected override void OnHeaderGUI()
7259
{
60+
#if UNITY_2019_2_OR_NEWER && !UNITY_2020_1_OR_NEWER
61+
// TODO: workaround for bug in 2019.2
62+
// https://forum.unity.com/threads/oninspectorgui-not-being-called-on-defaultasset-in-2019-2-0f1.724328/
7363
DrawEditor();
64+
#endif
7465
}
75-
#else
66+
7667
public override void OnInspectorGUI()
7768
{
69+
#if !UNITY_2019_2_OR_NEWER || UNITY_2020_1_OR_NEWER
7870
DrawEditor();
79-
}
8071
#endif
72+
}
8173

8274

83-
//------------------------------------------------------------------------------
75+
//------------------------------------------------------------------------------
8476

8577
private Editor mDefaultEditor;
8678

Editor/Scripts/MarkdownViewer.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,38 +75,39 @@ Layout ParseDocument()
7575

7676
//------------------------------------------------------------------------------
7777

78-
public void Draw()
78+
private void ClearBackground( float height )
7979
{
80-
GUI.skin = mSkin;
81-
GUI.enabled = true;
80+
var rectFullScreen = new Rect( 0.0f, 0.0f, Screen.width, Mathf.Max( height, Screen.height ) );
81+
GUI.DrawTexture( rectFullScreen, mSkin.window.normal.background, ScaleMode.StretchToFill, false );
82+
}
8283

83-
// clear background
8484

85-
var rectFullScreen = new Rect( 0.0f, 0.0f, Screen.width, Screen.height );
86-
GUI.DrawTexture( rectFullScreen, GUI.skin.window.normal.background, ScaleMode.StretchToFill, false );
85+
//------------------------------------------------------------------------------
8786

87+
public void Draw()
88+
{
89+
GUI.skin = mSkin;
90+
GUI.enabled = true;
8891

89-
// content rect
92+
// useable width of inspector windows
9093

91-
var contentWidth = EditorGUIUtility.currentViewWidth - GUI.skin.verticalScrollbar.fixedWidth - 2.0f * Margin.x;
94+
var contentWidth = EditorGUIUtility.currentViewWidth - mSkin.verticalScrollbar.fixedWidth - 2.0f * Margin.x;
9295

9396

9497
// draw content
9598

9699
if( mRaw )
97100
{
98-
EditorGUILayout.SelectableLabel( mText, GUI.skin.GetStyle( "raw" ) );
101+
var style = mSkin.GetStyle( "raw" );
102+
var width = contentWidth - mSkin.button.fixedHeight;
103+
var height = style.CalcHeight( new GUIContent( mText ), width );
104+
105+
ClearBackground( height );
106+
EditorGUILayout.SelectableLabel( mText, style, new GUILayoutOption[] { GUILayout.Width( width ), GUILayout.Height( height ) } );
99107
}
100108
else
101109
{
102-
// reserve the space
103-
104-
#if !UNITY_2018
105-
GUILayout.Space( mLayout.Height );
106-
#else
107-
GUILayout.FlexibleSpace();
108-
#endif
109-
110+
ClearBackground( mLayout.Height );
110111
DrawMarkdown( contentWidth );
111112
}
112113

@@ -167,6 +168,7 @@ void DrawMarkdown( float width )
167168
break;
168169

169170
case EventType.Layout:
171+
GUILayout.Space( mLayout.Height );
170172
mLayout.Arrange( width );
171173
break;
172174

0 commit comments

Comments
 (0)