3 changed files with 60 additions and 0 deletions
@ -0,0 +1,52 @@
|
||||
using UnityEngine; |
||||
using UnityEditor; |
||||
|
||||
public class SplitViewWindow : EditorWindow |
||||
{ |
||||
private Vector2 scrollPos = Vector2.zero; |
||||
float currentScrollViewHeight; |
||||
bool resize = false; |
||||
Rect cursorChangeRect; |
||||
|
||||
[MenuItem("MyWindows/SplitView")] |
||||
public static void Init(){ |
||||
GetWindow<SplitViewWindow>(); |
||||
} |
||||
|
||||
void OnEnable(){ |
||||
this.position = new Rect(200,200,400,300); |
||||
currentScrollViewHeight = this.position.height/2; |
||||
cursorChangeRect = new Rect(0,currentScrollViewHeight,this.position.width,5f); |
||||
} |
||||
|
||||
void OnGUI(){ |
||||
GUILayout.BeginVertical(); |
||||
scrollPos = GUILayout.BeginScrollView(scrollPos,GUILayout.Height(currentScrollViewHeight)); |
||||
for(int i=0;i<20;i++) |
||||
GUILayout.Label("dfs"); |
||||
GUILayout.EndScrollView(); |
||||
|
||||
ResizeScrollView(); |
||||
|
||||
GUILayout.FlexibleSpace(); |
||||
GUILayout.Label("Lower part"); |
||||
|
||||
GUILayout.EndVertical(); |
||||
Repaint(); |
||||
} |
||||
|
||||
private void ResizeScrollView(){ |
||||
GUI.DrawTexture(cursorChangeRect,EditorGUIUtility.whiteTexture); |
||||
EditorGUIUtility.AddCursorRect(cursorChangeRect,MouseCursor.ResizeVertical); |
||||
|
||||
if( Event.current.type == EventType.mouseDown && cursorChangeRect.Contains(Event.current.mousePosition)){ |
||||
resize = true; |
||||
} |
||||
if(resize){ |
||||
currentScrollViewHeight = Event.current.mousePosition.y; |
||||
cursorChangeRect.Set(cursorChangeRect.x,currentScrollViewHeight,cursorChangeRect.width,cursorChangeRect.height); |
||||
} |
||||
if(Event.current.type == EventType.MouseUp) |
||||
resize = false; |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 15f6cafd40d1c4995b33bc2e71625e7f |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
Binary file not shown.
Loading…
Reference in new issue