单位编辑器中此可选滚动的名称?

时间:2019-01-25 14:14:15

标签: unity3d

enter image description here 正如您在图片中看到的那样,选择了深蓝色的“ Layout0”。

我也想在自定义编辑器中创建此框,但实际上发现的不是 EditorGUILayout.BeginScrollView 和其他任何东西。

有人可以告诉我这个可选框的关键字吗?

1 个答案:

答案 0 :(得分:0)

我不太确定突出显示的工作原理,但是我认为这是如何实现的。

  1. 使用GUILayout.BeginScrollView
  2. 进行滚动视图
  3. 进行垂直查看,但具有帮助框样式GUILayout.BeginVertical(EditorStyles.helpBox)
  4. 对于突出显示,创建蓝色纹理并将其分配给GUIStyle,然后将其用于按钮。在Awake上执行此操作,因此您只需执行一次。

    Texture2D texture = new Texture2D(1, 1);
    for(int x = 0; x < 1; x++)
    {
        for(int y = 0; y < 1; y++)
        {
            texture.SetPixel(x, y, Color.blue);
        }
    }
    
    texture.Apply();
    
    this.selectedStyle = new GUIStyle();
    this.selectedStyle.normal.textColor  = Color.white;
    this.selectedStyle.normal.background = texture;
    
  5. 将按钮更改为标签按钮GUILayout.Button("name", currentSelected ? this.selectedStyle : GUIStyle.label)