Merge branch 'xxSeys1-PressGToGameModeAndPToNavigate'
This commit is contained in:
@@ -13,6 +13,7 @@ namespace FlaxEditor.Gizmo
|
||||
public abstract class GizmoBase
|
||||
{
|
||||
private IGizmoOwner _owner;
|
||||
private bool _visible = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the gizmo owner.
|
||||
@@ -34,6 +35,11 @@ namespace FlaxEditor.Gizmo
|
||||
/// </summary>
|
||||
public virtual BoundingSphere FocusBounds => BoundingSphere.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this gizmo is visible.
|
||||
/// </summary>
|
||||
public bool Visible { get { return _visible; } set { _visible = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GizmoBase"/> class.
|
||||
/// </summary>
|
||||
|
||||
@@ -387,6 +387,14 @@ namespace FlaxEditor.Options
|
||||
[EditorDisplay("Viewport"), EditorOrder(1760)]
|
||||
public InputBinding ToggleOrthographic = new InputBinding(KeyboardKeys.NumpadDecimal);
|
||||
|
||||
[DefaultValue(typeof(InputBinding), "G")]
|
||||
[EditorDisplay("Viewport"), EditorOrder(1770)]
|
||||
public InputBinding ToggleGameView = new InputBinding(KeyboardKeys.G);
|
||||
|
||||
[DefaultValue(typeof(InputBinding), "P")]
|
||||
[EditorDisplay("Viewport"), EditorOrder(1770)]
|
||||
public InputBinding ToggleNavMeshVisibility = new InputBinding(KeyboardKeys.P);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Debug Views
|
||||
|
||||
@@ -584,7 +584,7 @@ namespace FlaxEditor.Viewport
|
||||
_cameraButton = new ViewportWidgetButton(string.Format(MovementSpeedTextFormat, _movementSpeed), _editor.Icons.Camera64, cameraCM, false, cameraSpeedTextWidth)
|
||||
{
|
||||
Tag = this,
|
||||
TooltipText = "Camera Settings",
|
||||
TooltipText = "Camera Settings.",
|
||||
Parent = _cameraWidget
|
||||
};
|
||||
_cameraWidget.Parent = this;
|
||||
@@ -593,7 +593,7 @@ namespace FlaxEditor.Viewport
|
||||
_orthographicModeButton = new ViewportWidgetButton(string.Empty, _editor.Icons.CamSpeed32, null, true)
|
||||
{
|
||||
Checked = !_isOrtho,
|
||||
TooltipText = "Toggle Orthographic/Perspective Mode",
|
||||
TooltipText = "Toggle Orthographic/Perspective Mode.",
|
||||
Parent = _cameraWidget
|
||||
};
|
||||
_orthographicModeButton.Toggled += OnOrthographicModeToggled;
|
||||
@@ -832,7 +832,7 @@ namespace FlaxEditor.Viewport
|
||||
ViewWidgetButtonMenu = new ContextMenu();
|
||||
var viewModeButton = new ViewportWidgetButton("View", SpriteHandle.Invalid, ViewWidgetButtonMenu)
|
||||
{
|
||||
TooltipText = "View properties",
|
||||
TooltipText = "View properties.",
|
||||
Parent = viewMode
|
||||
};
|
||||
viewMode.Parent = this;
|
||||
@@ -863,8 +863,10 @@ namespace FlaxEditor.Viewport
|
||||
{
|
||||
}
|
||||
});
|
||||
viewLayers.AddButton("Reset layers", () => Task.ViewLayersMask = LayersMask.Default).Icon = _editor.Icons.Rotate32;
|
||||
viewLayers.AddButton("Disable layers", () => Task.ViewLayersMask = new LayersMask(0));
|
||||
viewLayers.AddButton("Reset layers", () => Task.ViewLayersMask = LayersMask.Default).Icon = Editor.Instance.Icons.Rotate32;
|
||||
viewLayers.AddSeparator();
|
||||
viewLayers.AddButton("Enable all", () => Task.ViewLayersMask = new LayersMask(-1)).Icon = Editor.Instance.Icons.CheckBoxTick12;
|
||||
viewLayers.AddButton("Disable all", () => Task.ViewLayersMask = new LayersMask(0)).Icon = Editor.Instance.Icons.Cross12;
|
||||
viewLayers.AddSeparator();
|
||||
var layers = LayersAndTagsSettings.GetCurrentLayers();
|
||||
if (layers != null && layers.Length > 0)
|
||||
@@ -904,8 +906,10 @@ namespace FlaxEditor.Viewport
|
||||
{
|
||||
}
|
||||
});
|
||||
viewFlags.AddButton("Reset flags", () => Task.ViewFlags = ViewFlags.DefaultEditor).Icon = _editor.Icons.Rotate32;
|
||||
viewFlags.AddButton("Disable flags", () => Task.ViewFlags = ViewFlags.None);
|
||||
viewFlags.AddButton("Reset flags", () => Task.ViewFlags = ViewFlags.DefaultEditor).Icon = Editor.Instance.Icons.Rotate32;
|
||||
viewFlags.AddSeparator();
|
||||
viewFlags.AddButton("Enable all", () => Task.ViewFlags = ViewFlags.All).Icon = Editor.Instance.Icons.CheckBoxTick12;
|
||||
viewFlags.AddButton("Disable all", () => Task.ViewFlags = ViewFlags.None).Icon = Editor.Instance.Icons.Cross12;
|
||||
viewFlags.AddSeparator();
|
||||
for (int i = 0; i < ViewFlagsValues.Length; i++)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace FlaxEditor.Viewport
|
||||
private readonly Editor _editor;
|
||||
private readonly ContextMenuButton _showGridButton;
|
||||
private readonly ContextMenuButton _showNavigationButton;
|
||||
private readonly ContextMenuButton _toggleGameViewButton;
|
||||
private SelectionOutline _customSelectionOutline;
|
||||
|
||||
/// <summary>
|
||||
@@ -108,6 +109,13 @@ namespace FlaxEditor.Viewport
|
||||
private EditorSpritesRenderer _editorSpritesRenderer;
|
||||
private ViewportRubberBandSelector _rubberBandSelector;
|
||||
|
||||
private bool _gameViewActive;
|
||||
private ViewFlags _preGameViewFlags;
|
||||
private ViewMode _preGameViewViewMode;
|
||||
private bool _gameViewWasGridShown;
|
||||
private bool _gameViewWasFpsCounterShown;
|
||||
private bool _gameViewWasNagivationShown;
|
||||
|
||||
/// <summary>
|
||||
/// Drag and drop handlers
|
||||
/// </summary>
|
||||
@@ -185,6 +193,7 @@ namespace FlaxEditor.Viewport
|
||||
: base(Object.New<SceneRenderTask>(), editor.Undo, editor.Scene.Root)
|
||||
{
|
||||
_editor = editor;
|
||||
var inputOptions = _editor.Options.Options.Input;
|
||||
DragHandlers = new ViewportDragHandlers(this, this, ValidateDragItem, ValidateDragActorType, ValidateDragScriptItem);
|
||||
|
||||
// Prepare rendering task
|
||||
@@ -232,9 +241,14 @@ namespace FlaxEditor.Viewport
|
||||
_showGridButton.CloseMenuOnClick = false;
|
||||
|
||||
// Show navigation widget
|
||||
_showNavigationButton = ViewWidgetShowMenu.AddButton("Navigation", () => ShowNavigation = !ShowNavigation);
|
||||
_showNavigationButton = ViewWidgetShowMenu.AddButton("Navigation", inputOptions.ToggleNavMeshVisibility, () => ShowNavigation = !ShowNavigation);
|
||||
_showNavigationButton.CloseMenuOnClick = false;
|
||||
|
||||
// Game View
|
||||
ViewWidgetButtonMenu.AddSeparator();
|
||||
_toggleGameViewButton = ViewWidgetButtonMenu.AddButton("Game View", inputOptions.ToggleGameView, ToggleGameView);
|
||||
_toggleGameViewButton.CloseMenuOnClick = false;
|
||||
|
||||
// Create camera widget
|
||||
ViewWidgetButtonMenu.AddSeparator();
|
||||
ViewWidgetButtonMenu.AddButton("Create camera here", CreateCameraAtView);
|
||||
@@ -259,6 +273,10 @@ namespace FlaxEditor.Viewport
|
||||
InputActions.Add(options => options.FocusSelection, FocusSelection);
|
||||
InputActions.Add(options => options.RotateSelection, RotateSelection);
|
||||
InputActions.Add(options => options.Delete, _editor.SceneEditing.Delete);
|
||||
InputActions.Add(options => options.ToggleNavMeshVisibility, () => ShowNavigation = !ShowNavigation);
|
||||
|
||||
// Game View
|
||||
InputActions.Add(options => options.ToggleGameView, ToggleGameView);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -373,9 +391,12 @@ namespace FlaxEditor.Viewport
|
||||
public void DrawEditorPrimitives(GPUContext context, ref RenderContext renderContext, GPUTexture target, GPUTexture targetDepth)
|
||||
{
|
||||
// Draw gizmos
|
||||
for (int i = 0; i < Gizmos.Count; i++)
|
||||
foreach (var gizmo in Gizmos)
|
||||
{
|
||||
Gizmos[i].Draw(ref renderContext);
|
||||
if (gizmo.Visible)
|
||||
{
|
||||
gizmo.Draw(ref renderContext);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw selected objects debug shapes and visuals
|
||||
@@ -481,6 +502,36 @@ namespace FlaxEditor.Viewport
|
||||
TransformGizmo.EndTransforming();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles game view view mode on or off.
|
||||
/// </summary>
|
||||
public void ToggleGameView()
|
||||
{
|
||||
if (!_gameViewActive)
|
||||
{
|
||||
// Cache flags & values
|
||||
_preGameViewFlags = Task.ViewFlags;
|
||||
_preGameViewViewMode = Task.ViewMode;
|
||||
_gameViewWasGridShown = Grid.Enabled;
|
||||
_gameViewWasFpsCounterShown = ShowFpsCounter;
|
||||
_gameViewWasNagivationShown = ShowNavigation;
|
||||
}
|
||||
|
||||
// Set flags & values
|
||||
Task.ViewFlags = _gameViewActive ? _preGameViewFlags : ViewFlags.DefaultGame;
|
||||
Task.ViewMode = _gameViewActive ? _preGameViewViewMode : ViewMode.Default;
|
||||
ShowFpsCounter = _gameViewActive ? _gameViewWasFpsCounterShown : false;
|
||||
ShowNavigation = _gameViewActive ? _gameViewWasNagivationShown : false;
|
||||
Grid.Enabled = _gameViewActive ? _gameViewWasGridShown : false;
|
||||
|
||||
_gameViewActive = !_gameViewActive;
|
||||
|
||||
TransformGizmo.Visible = !_gameViewActive;
|
||||
SelectionOutline.ShowSelectionOutline = !_gameViewActive;
|
||||
|
||||
_toggleGameViewButton.Icon = _gameViewActive ? Style.Current.CheckBoxTick : SpriteHandle.Invalid;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLostFocus()
|
||||
{
|
||||
|
||||
@@ -720,9 +720,12 @@ namespace FlaxEditor.Viewport
|
||||
public override void DrawEditorPrimitives(GPUContext context, ref RenderContext renderContext, GPUTexture target, GPUTexture targetDepth)
|
||||
{
|
||||
// Draw gizmos
|
||||
for (int i = 0; i < Gizmos.Count; i++)
|
||||
foreach (var gizmo in Gizmos)
|
||||
{
|
||||
Gizmos[i].Draw(ref renderContext);
|
||||
if (gizmo.Visible)
|
||||
{
|
||||
gizmo.Draw(ref renderContext);
|
||||
}
|
||||
}
|
||||
|
||||
base.DrawEditorPrimitives(context, ref renderContext, target, targetDepth);
|
||||
|
||||
@@ -1094,6 +1094,11 @@ API_ENUM(Attributes="Flags") enum class ViewFlags : uint64
|
||||
/// Default flags for materials/models previews generating.
|
||||
/// </summary>
|
||||
DefaultAssetPreview = Reflections | Decals | DirectionalLights | PointLights | SpotLights | SkyLights | SpecularLight | AntiAliasing | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | Sky | Particles,
|
||||
|
||||
/// <summary>
|
||||
/// All flags enabled.
|
||||
/// </summary>
|
||||
All = None | DebugDraw | EditorSprites | Reflections | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | Decals | DepthOfField | PhysicsDebug | Fog | MotionBlur | ContactShadows | GlobalSDF | Sky | LightsDebug | Particles,
|
||||
};
|
||||
|
||||
DECLARE_ENUM_OPERATORS(ViewFlags);
|
||||
|
||||
Reference in New Issue
Block a user