From 6ed436765d74ef946fb75d3ae526196ee08322f5 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Fri, 25 Jul 2014 17:04:23 +0100 Subject: [PATCH] Scroll window automatically resizes --- Assets/Fungus/Editor/FungusEditorWindow.cs | 21 ++++++++++++------ .../Fungus/Tests/Sequence/SequenceTest.unity | Bin 67932 -> 67932 bytes 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Assets/Fungus/Editor/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusEditorWindow.cs index 10064963..dd6a579e 100755 --- a/Assets/Fungus/Editor/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusEditorWindow.cs @@ -78,19 +78,26 @@ public class FungusEditorWindow : EditorWindow GUILayout.Space(30); GUILayout.EndHorizontal(); - // BeginScrollView lets you specify a region that 'looks into' a much larger area. In this case, we create a canvas - // 1000px X 1000px in size that's constrained to the same region as the EditorWindow. If the scrollbars are modified, - // the new values are stored in the Vector2 that's returned. - // http://docs.unity3d.com/Documentation/ScriptReference/GUI.BeginScrollView.html - scrollPos = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPos, new Rect(0, 0, 1000, 1000)); + Sequence[] sequences = sequenceController.GetComponentsInChildren(); + + Rect scrollViewRect = new Rect(); + foreach (Sequence s in sequences) + { + scrollViewRect.xMin = Mathf.Min(scrollViewRect.xMin, s.nodeRect.xMin); + scrollViewRect.xMax = Mathf.Max(scrollViewRect.xMax, s.nodeRect.xMax); + scrollViewRect.yMin = Mathf.Min(scrollViewRect.yMin, s.nodeRect.yMin); + scrollViewRect.yMax = Mathf.Max(scrollViewRect.yMax, s.nodeRect.yMax); + } + scrollViewRect.xMin -= 10; + scrollViewRect.yMin -= 10; + + scrollPos = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPos, scrollViewRect); // In games, GUI.Window pops up a window on your screen. In the Editor, GUI.Window shows a sub-window inside an EditorWindow. // All calls to GUI.Window need to be wrapped in a BeginWindows / EndWindows pair. // http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow.BeginWindows.html BeginWindows(); - Sequence[] sequences = sequenceController.GetComponentsInChildren(); - windowSequenceMap.Clear(); for (int i = 0; i < sequences.Length; ++i) { diff --git a/Assets/Fungus/Tests/Sequence/SequenceTest.unity b/Assets/Fungus/Tests/Sequence/SequenceTest.unity index 6bb4f8389184257a0ad42ad035ea052aea52021b..3d0698cd3baffa52e2b687e9b622d81e1ed1c427 100644 GIT binary patch delta 106 zcmcaJiRI2DmJO4Bva&lfFo;i|&%vlTIpHVI<|9APF|sZ=z`!5^75mMydC%`KR<;8` vv4Dfq7jQ5tO#Q&fvfYM}QI(0Efdi-=Dm=Y`2`Jvf%*e+IGPR){WWrtm7X2dE delta 105 zcmcaJiRI2DmJO4Bvg$fBFoaK^&%vlTIpHVI<|9APF|wX;WMD9civ4EUyytfqE1M2b y9gEZS1sseDQ$H}WY`0-#RApjoSOgS~04tr|zyuWTVP@oGWj*J_(6A9Cx)%V(b0T>F