【问题标题】:Unity ScrollViewScope horizontal scroll not working with EditorGUILayoutUnity ScrollViewScope 水平滚动不适用于 EditorGUILayout
【发布时间】:2021-10-25 10:43:46
【问题描述】:

我需要使用 EditorGUI.IndentLevelScope,它仅适用于 LabelField、Foldout 等 EditorGUILayout,不适用于 Label 等 GUILayout。

这是我的代码

                using (var midScroll = new EditorGUILayout.ScrollViewScope(midSPos, true, true))
                {
                    using (new EditorGUI.IndentLevelScope(1))
                    {
                        midSPos = midScroll.scrollPosition;
                        for (int i = 0; i < 50; i++)
                        {
                            EditorGUILayout.LabelField("This is a EditorGUILayout.LabelField. This is a EditorGUILayout.LabelField.", GUI.skin.GetStyle("LinkLabel"));
                        }
                    }
                }

垂直工作而不是水平工作 图片:https://gyazo.com/70382d83222dc7fc2db54c4745836dfc

与 GUILayout.Label 相同的代码都可以工作 我想念什么

【问题讨论】:

  • 听起来你还没有真正告诉你的滚动视图它应该覆盖的垂直宽度......如果没有更多的上下文很难说

标签: unity3d unity-editor


【解决方案1】:

最后我找到了 Label 的解决方案,通过在 GUILayout 的前后添加一个空的PrefixLabel,滚动现在可以工作了。

HorizontalScope
    EditorGUILayout.PrefixLabel("");
    GUILayout.Label("content");

但是,我的 foldout 仍然存在一些问题,因为我无法向其中添加 Horizo​​ntalScope。

InitRow(row row)
{
    if (isShowing = EditorGUILayout.Foldout(isShowing, "Foldout"))
    {
        InitRow(child);
    }
}

【讨论】:

    猜你喜欢
    • 2021-02-03
    • 2022-01-04
    • 2020-02-20
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-19
    • 1970-01-01
    相关资源
    最近更新 更多