Skip to content

Commit 7521cd7

Browse files
authored
Fix SceneView UI layout issues with 2021.2+ (#330)
* Fix SceneView UI layout issues with 2021.2+ * implement fixes suggested by @andreiagmu, clean up UI this implements fixes suggested by @andreiagmu and removes the sliders in the generator popups, in favor of `[<] [>]` buttons, which removes the bugginess of unity sliders in the scene view. * removed redundant/unused imports or braces, fixed compilation errors on versions < 2021.2 * Revert "Merge branch 'master' into 2021.2-update" This reverts commit 762822b, reversing changes made to 142008a. * Merge pull request #328 from epiplon-game-studio/master Fixes a reference error bug with play mode * revert changes from upstream, which adjusts the Y offset of the toolbar. This is now handled automatically by unity, with `rootVisualElement.contentRect`, causing the upstream changes to do nothing. * Update EditModeToolWindow.Editor.cs * Update EditModeToolWindow.Editor.cs * Delete ProjectVersion.txt
1 parent 438d6a9 commit 7521cd7

24 files changed

+1400
-911
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[Bb]uild/
55
[Bb]uilds/
66
Assets/AssetStoreTools*
7+
UserSettings*
78

89
# Visual Studio cache directory
910
.vs/

RealtimeCSG/Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/InternalCSGModelManager.DefaultModel.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ static void InitializeDefaultCSGModel(Scene currentScene, CSGSceneState sceneSta
8888
bool inPrefabMode = false;
8989
Transform prefabRootTransform = null;
9090
#if UNITY_2018_3_OR_NEWER
91-
92-
#if UNITY_2021_2_OR_NEWER
93-
var currentPrefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
94-
#else
91+
#if !UNITY_2021_2_OR_NEWER
9592
var currentPrefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
96-
#endif
97-
98-
if (currentPrefabStage != null)
93+
#else
94+
var currentPrefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
95+
#endif
96+
if (currentPrefabStage != null)
9997
{
10098
var prefabRoot = currentPrefabStage.prefabContentsRoot;
10199
prefabRootTransform = prefabRoot.transform;

RealtimeCSG/Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/SceneViewEventHandler.cs

+80-70
Original file line numberDiff line numberDiff line change
@@ -9,87 +9,97 @@
99
using UnityEngine.SceneManagement;
1010
using RealtimeCSG.Helpers;
1111

12+
1213
namespace RealtimeCSG
1314
{
14-
internal sealed class SceneViewEventHandler
15-
{
16-
static bool mousePressed;
15+
internal sealed class SceneViewEventHandler
16+
{
17+
static bool mousePressed;
1718

1819
static int prevFocusControl;
1920

20-
internal static void OnScene(SceneView sceneView)
21-
{
22-
CSGSettings.RegisterSceneView(sceneView);
23-
if (!RealtimeCSG.CSGSettings.EnableRealtimeCSG)
24-
return;
25-
26-
if (EditorApplication.isPlayingOrWillChangePlaymode)
27-
return;
28-
UpdateLoop.UpdateOnSceneChange();
29-
30-
if (!RealtimeCSG.CSGSettings.EnableRealtimeCSG)
31-
ColorSettings.isInitialized = false;
32-
else
33-
if (!ColorSettings.isInitialized)
34-
{
35-
if (Event.current.type == EventType.Repaint)
36-
{
37-
ColorSettings.Update();
38-
}
39-
}
40-
41-
if (!UpdateLoop.IsActive())
42-
UpdateLoop.ResetUpdateRoutine();
43-
44-
if (Event.current.type == EventType.MouseDown ||
45-
Event.current.type == EventType.MouseDrag) { mousePressed = true; }
46-
else if (Event.current.type == EventType.MouseUp ||
47-
Event.current.type == EventType.MouseMove) { mousePressed = false; }
48-
49-
SceneDragToolManager.OnHandleDragAndDrop(sceneView);
50-
RectangleSelectionManager.Update(sceneView);
51-
EditModeManager.InitSceneGUI(sceneView);
52-
53-
if (Event.current.type == EventType.Repaint)
54-
MeshInstanceManager.UpdateHelperSurfaces();
55-
56-
if (Event.current.type == EventType.Repaint)
57-
{
58-
SceneToolRenderer.OnPaint(sceneView);
59-
} else
60-
//if (fallbackGUI)
61-
{
62-
SceneViewBottomBarGUI.ShowGUI(sceneView);
21+
internal static void OnScene( SceneView sceneView )
22+
{
23+
CSGSettings.RegisterSceneView( sceneView );
24+
25+
if( !RealtimeCSG.CSGSettings.EnableRealtimeCSG )
26+
return;
27+
28+
if( EditorApplication.isPlayingOrWillChangePlaymode )
29+
return;
30+
31+
UpdateLoop.UpdateOnSceneChange();
32+
33+
if( !RealtimeCSG.CSGSettings.EnableRealtimeCSG )
34+
ColorSettings.isInitialized = false;
35+
else if( !ColorSettings.isInitialized )
36+
{
37+
if( Event.current.type == EventType.Repaint )
38+
{
39+
ColorSettings.Update();
40+
}
41+
}
42+
43+
if( !UpdateLoop.IsActive() )
44+
UpdateLoop.ResetUpdateRoutine();
45+
46+
if( Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag )
47+
{
48+
mousePressed = true;
49+
}
50+
else if( Event.current.type == EventType.MouseUp || Event.current.type == EventType.MouseMove )
51+
{
52+
mousePressed = false;
53+
}
54+
55+
SceneDragToolManager.OnHandleDragAndDrop( sceneView );
56+
RectangleSelectionManager.Update( sceneView );
57+
EditModeManager.InitSceneGUI( sceneView );
58+
59+
if( Event.current.type == EventType.Repaint )
60+
MeshInstanceManager.UpdateHelperSurfaces();
61+
62+
if( Event.current.type == EventType.Repaint )
63+
{
64+
SceneToolRenderer.OnPaint( sceneView );
65+
}
66+
else
67+
//if (fallbackGUI)
68+
{
69+
SceneViewBottomBarGUI.ShowGUI( sceneView );
6370
SceneViewInfoGUI.DrawInfoGUI( sceneView );
64-
}
65-
66-
EditModeManager.OnSceneGUI(sceneView);
67-
68-
//if (fallbackGUI)
69-
{
70-
TooltipUtility.InitToolTip(sceneView);
71-
if (Event.current.type == EventType.Repaint)
72-
{
73-
SceneViewBottomBarGUI.ShowGUI(sceneView);
74-
SceneViewInfoGUI.DrawInfoGUI( sceneView );
75-
}
76-
if (!mousePressed)
77-
{
78-
Handles.BeginGUI();
79-
TooltipUtility.DrawToolTip(getLastRect: false);
80-
Handles.EndGUI();
81-
}
82-
}
83-
84-
if (Event.current.type == EventType.Layout)
71+
}
72+
73+
EditModeManager.OnSceneGUI( sceneView );
74+
75+
//if (fallbackGUI)
76+
{
77+
TooltipUtility.InitToolTip( sceneView );
78+
79+
if( Event.current.type == EventType.Repaint )
80+
{
81+
SceneViewBottomBarGUI.ShowGUI( sceneView, false );
82+
SceneViewInfoGUI.DrawInfoGUI( sceneView );
83+
}
84+
85+
if( !mousePressed )
86+
{
87+
Handles.BeginGUI();
88+
TooltipUtility.DrawToolTip( getLastRect: false );
89+
Handles.EndGUI();
90+
}
91+
}
92+
93+
if( Event.current.type == EventType.Layout )
8594
{
8695
var currentFocusControl = CSGHandles.FocusControl;
87-
if (prevFocusControl != currentFocusControl)
96+
97+
if( prevFocusControl != currentFocusControl )
8898
{
8999
prevFocusControl = currentFocusControl;
90100
HandleUtility.Repaint();
91101
}
92102
}
93-
}
94-
}
103+
}
104+
}
95105
}

0 commit comments

Comments
 (0)