Reputation: 11319
For example I set the window size to 800x800 also the scroll view size is 800x800
But in this case when the content is not expanded so the content is on the top but the rest of the window is empty. I could resize the window now on my own but then when I expand the content I will have to resize the window again.
Visual it looks bad.
Then when expanding the content : Now the content is over too much the window size so now the scroll view is show up :
But now I have another problem. The scroll view vertical is not working. When trying to scroll down it keep moving the scroller back up. It never move down.
And if I will collapse back up the content it will look like again like in the first screenshot.
In general my problem is how to use the window size with the scroll view and the content so it will not look like in the first screenshot and that the scroll view will work when it show up.
The editor window script :
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
public class ConversationsEditorWindow : EditorWindow
{
Vector2 scrollPos;
[MenuItem("Window/Editor Window Test")]
static void Init()
{
const int width = 800;
const int height = 800;
var x = (Screen.currentResolution.width - width) / 2;
var y = (Screen.currentResolution.height - height) / 2;
GetWindow<ConversationsEditorWindow>().position = new Rect(x, y, width, height);
}
void OnGUI()
{
GameObject sel = Selection.activeGameObject;
ConversationTrigger targetComp = sel.GetComponent<ConversationTrigger>();
if (targetComp != null)
{
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(800), GUILayout.Height(800));
var editor = Editor.CreateEditor(targetComp);
var tar = editor.targets;
editor.OnInspectorGUI();
EditorGUILayout.EndScrollView();
EditorGUILayout.EndVertical();
}
}
}
Upvotes: 1
Views: 6101
Reputation: 31
Your scroll view isn't working because need to save the current scroll position:
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(800), GUILayout.Height(800));
Upvotes: 2