Skip to content

Commit 67aa037

Browse files
committed
Possibily to force Toolbar repaint externally
1 parent 03993d8 commit 67aa037

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Assets/Editor Toolbox/Editor/ToolboxEditorToolbar.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static ToolboxEditorToolbar()
4646
private static readonly FieldInfo onGuiHandler = containterType.GetField("m_OnGUIHandler",
4747
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
4848

49+
private static readonly MethodInfo repaintMethod = toolbarType.GetMethod("RepaintToolbar",
50+
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
51+
4952
private static Object toolbar;
5053

5154
private static IEnumerator Initialize()
@@ -106,7 +109,7 @@ private static IEnumerator Initialize()
106109

107110
private static void OnGui()
108111
{
109-
if (!IsToolbarAllowed || OnToolbarGui == null)
112+
if (!IsToolbarAllowed || !IsToolbarValid)
110113
{
111114
return;
112115
}
@@ -142,9 +145,18 @@ private static void OnGui()
142145
#endif
143146
}
144147

148+
public static void Repaint()
149+
{
150+
if (toolbar == null)
151+
{
152+
return;
153+
}
154+
155+
repaintMethod?.Invoke(toolbar, null);
156+
}
145157

146158
public static bool IsToolbarAllowed { get; set; } = true;
147-
159+
public static bool IsToolbarValid => toolbar != null && OnToolbarGui != null;
148160
public static float FromToolsOffset { get; set; } = 400.0f;
149161
public static float FromStripOffset { get; set; } = 150.0f;
150162

0 commit comments

Comments
 (0)