public void OnGUI()
{
// When we start play (using shortcut keys) we get two OnGui calls and m_Gradient is null: so early out.
if (m_Gradient == null)
{
return;
}
InitIfNeeded();
float gradientEditorHeight = Mathf.Min(position.height, 146);
float distBetween = 10f;
float presetLibraryHeight = position.height - gradientEditorHeight - distBetween;
Rect gradientEditorRect = new Rect(10, 10, position.width - 20, gradientEditorHeight - 20);
Rect gradientLibraryRect = new Rect(0, gradientEditorHeight + distBetween, position.width, presetLibraryHeight);
// Separator
EditorGUI.DrawRect(new Rect(gradientLibraryRect.x, gradientLibraryRect.y - 1, gradientLibraryRect.width, 1), new Color(0, 0, 0, 0.3f));
EditorGUI.DrawRect(new Rect(gradientLibraryRect.x, gradientLibraryRect.y, gradientLibraryRect.width, 1), new Color(1, 1, 1, 0.1f));
// The meat
EditorGUI.BeginChangeCheck();
m_GradientEditor.OnGUI(gradientEditorRect);
if (EditorGUI.EndChangeCheck())
{
gradientChanged = true;
}
m_GradientLibraryEditor.OnGUI(gradientLibraryRect, m_Gradient);
if (gradientChanged)
{
gradientChanged = false;
SendEvent(true);
}
}