Skip to content

Commit

Permalink
Fix SceneView UI layout issues with 2021.2+ (#330)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kerfuffles authored Jan 27, 2022
1 parent 438d6a9 commit 7521cd7
Show file tree
Hide file tree
Showing 24 changed files with 1,400 additions and 911 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
UserSettings*

# Visual Studio cache directory
.vs/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ static void InitializeDefaultCSGModel(Scene currentScene, CSGSceneState sceneSta
bool inPrefabMode = false;
Transform prefabRootTransform = null;
#if UNITY_2018_3_OR_NEWER

#if UNITY_2021_2_OR_NEWER
var currentPrefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
#else
#if !UNITY_2021_2_OR_NEWER
var currentPrefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
#endif

if (currentPrefabStage != null)
#else
var currentPrefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
#endif
if (currentPrefabStage != null)
{
var prefabRoot = currentPrefabStage.prefabContentsRoot;
prefabRootTransform = prefabRoot.transform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,87 +9,97 @@
using UnityEngine.SceneManagement;
using RealtimeCSG.Helpers;


namespace RealtimeCSG
{
internal sealed class SceneViewEventHandler
{
static bool mousePressed;
internal sealed class SceneViewEventHandler
{
static bool mousePressed;

static int prevFocusControl;

internal static void OnScene(SceneView sceneView)
{
CSGSettings.RegisterSceneView(sceneView);
if (!RealtimeCSG.CSGSettings.EnableRealtimeCSG)
return;

if (EditorApplication.isPlayingOrWillChangePlaymode)
return;
UpdateLoop.UpdateOnSceneChange();

if (!RealtimeCSG.CSGSettings.EnableRealtimeCSG)
ColorSettings.isInitialized = false;
else
if (!ColorSettings.isInitialized)
{
if (Event.current.type == EventType.Repaint)
{
ColorSettings.Update();
}
}

if (!UpdateLoop.IsActive())
UpdateLoop.ResetUpdateRoutine();

if (Event.current.type == EventType.MouseDown ||
Event.current.type == EventType.MouseDrag) { mousePressed = true; }
else if (Event.current.type == EventType.MouseUp ||
Event.current.type == EventType.MouseMove) { mousePressed = false; }

SceneDragToolManager.OnHandleDragAndDrop(sceneView);
RectangleSelectionManager.Update(sceneView);
EditModeManager.InitSceneGUI(sceneView);

if (Event.current.type == EventType.Repaint)
MeshInstanceManager.UpdateHelperSurfaces();

if (Event.current.type == EventType.Repaint)
{
SceneToolRenderer.OnPaint(sceneView);
} else
//if (fallbackGUI)
{
SceneViewBottomBarGUI.ShowGUI(sceneView);
internal static void OnScene( SceneView sceneView )
{
CSGSettings.RegisterSceneView( sceneView );

if( !RealtimeCSG.CSGSettings.EnableRealtimeCSG )
return;

if( EditorApplication.isPlayingOrWillChangePlaymode )
return;

UpdateLoop.UpdateOnSceneChange();

if( !RealtimeCSG.CSGSettings.EnableRealtimeCSG )
ColorSettings.isInitialized = false;
else if( !ColorSettings.isInitialized )
{
if( Event.current.type == EventType.Repaint )
{
ColorSettings.Update();
}
}

if( !UpdateLoop.IsActive() )
UpdateLoop.ResetUpdateRoutine();

if( Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag )
{
mousePressed = true;
}
else if( Event.current.type == EventType.MouseUp || Event.current.type == EventType.MouseMove )
{
mousePressed = false;
}

SceneDragToolManager.OnHandleDragAndDrop( sceneView );
RectangleSelectionManager.Update( sceneView );
EditModeManager.InitSceneGUI( sceneView );

if( Event.current.type == EventType.Repaint )
MeshInstanceManager.UpdateHelperSurfaces();

if( Event.current.type == EventType.Repaint )
{
SceneToolRenderer.OnPaint( sceneView );
}
else
//if (fallbackGUI)
{
SceneViewBottomBarGUI.ShowGUI( sceneView );
SceneViewInfoGUI.DrawInfoGUI( sceneView );
}

EditModeManager.OnSceneGUI(sceneView);

//if (fallbackGUI)
{
TooltipUtility.InitToolTip(sceneView);
if (Event.current.type == EventType.Repaint)
{
SceneViewBottomBarGUI.ShowGUI(sceneView);
SceneViewInfoGUI.DrawInfoGUI( sceneView );
}
if (!mousePressed)
{
Handles.BeginGUI();
TooltipUtility.DrawToolTip(getLastRect: false);
Handles.EndGUI();
}
}

if (Event.current.type == EventType.Layout)
}

EditModeManager.OnSceneGUI( sceneView );

//if (fallbackGUI)
{
TooltipUtility.InitToolTip( sceneView );

if( Event.current.type == EventType.Repaint )
{
SceneViewBottomBarGUI.ShowGUI( sceneView, false );
SceneViewInfoGUI.DrawInfoGUI( sceneView );
}

if( !mousePressed )
{
Handles.BeginGUI();
TooltipUtility.DrawToolTip( getLastRect: false );
Handles.EndGUI();
}
}

if( Event.current.type == EventType.Layout )
{
var currentFocusControl = CSGHandles.FocusControl;
if (prevFocusControl != currentFocusControl)

if( prevFocusControl != currentFocusControl )
{
prevFocusControl = currentFocusControl;
HandleUtility.Repaint();
}
}
}
}
}
}
}
Loading

0 comments on commit 7521cd7

Please sign in to comment.