Added ScrollViewScope.

This commit is contained in:
max 2021-04-20 20:23:13 +02:00
parent c207d4887e
commit 14d7e7eb41

View File

@ -10,6 +10,7 @@ namespace TAO.SceneDebugViewer.Editor
public static List<ReplacementShaderSetupScriptableObject> options = new List<ReplacementShaderSetupScriptableObject>(); public static List<ReplacementShaderSetupScriptableObject> options = new List<ReplacementShaderSetupScriptableObject>();
private GUIStyle optionsButtonStyle = null; private GUIStyle optionsButtonStyle = null;
private Vector2 scrollPos;
[MenuItem("Window/Analysis/SceneDebugViewer")] [MenuItem("Window/Analysis/SceneDebugViewer")]
static void Init() static void Init()
@ -37,49 +38,54 @@ namespace TAO.SceneDebugViewer.Editor
Load(); Load();
} }
if (window.position.width <= 101) using (var scope = new GUILayout.ScrollViewScope(scrollPos, false, false))
{ {
// Compact grid. scrollPos = scope.scrollPosition;
optionsButtonStyle = new GUIStyle(GUI.skin.button)
if (window.position.width <= 101)
{ {
alignment = TextAnchor.MiddleCenter, // Compact grid.
fixedHeight = 44 optionsButtonStyle = new GUIStyle(GUI.skin.button)
};
for (int i = 0; i < options.Count; i += 2)
{
GUILayout.BeginHorizontal();
if (GUILayout.Button(options[i].Content.compact, optionsButtonStyle))
{ {
options[i].Replace(); alignment = TextAnchor.MiddleCenter,
} fixedHeight = 44
};
if (i + 1 < options.Count) for (int i = 0; i < options.Count; i += 2)
{ {
if (GUILayout.Button(options[i + 1].Content.compact, optionsButtonStyle)) GUILayout.BeginHorizontal();
if (GUILayout.Button(options[i].Content.compact, optionsButtonStyle))
{ {
options[i + 1].Replace(); options[i].Replace();
} }
if (i + 1 < options.Count)
{
if (GUILayout.Button(options[i + 1].Content.compact, optionsButtonStyle))
{
options[i + 1].Replace();
}
}
GUILayout.EndHorizontal();
} }
GUILayout.EndHorizontal();
} }
} else
else
{
// Normal list.
optionsButtonStyle = new GUIStyle(GUI.skin.button)
{ {
alignment = TextAnchor.MiddleLeft, // Normal list.
fixedHeight = 44 optionsButtonStyle = new GUIStyle(GUI.skin.button)
};
for (int i = 0; i < options.Count; i ++)
{
if (GUILayout.Button(options[i].Content.normal, optionsButtonStyle))
{ {
options[i].Replace(); alignment = TextAnchor.MiddleLeft,
fixedHeight = 44
};
for (int i = 0; i < options.Count; i ++)
{
if (GUILayout.Button(options[i].Content.normal, optionsButtonStyle))
{
options[i].Replace();
}
} }
} }
} }