Merge remote-tracking branch 'origin/1.1' into 1.2

# Conflicts:
#	Source/Editor/Editor.Build.cs
This commit is contained in:
Wojtek Figat
2021-03-15 09:38:58 +01:00
86 changed files with 4242 additions and 317 deletions

View File

@@ -75,6 +75,8 @@ namespace FlaxEditor.Content
}
}
public int MetadataToken => 0;
/// <inheritdoc />
public bool HasAttribute(Type attributeType, bool inherit)
{
@@ -195,6 +197,8 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public ScriptType ValueType => _returnType;
public int MetadataToken => 0;
/// <inheritdoc />
public bool HasAttribute(Type attributeType, bool inherit)
{

View File

@@ -29,7 +29,7 @@ namespace FlaxEditor.Content
if (asset)
{
var source = Editor.GetShaderSourceCode(asset);
Utilities.Utils.ShowSourceCodeWindow(source, "Shader Source");
Utilities.Utils.ShowSourceCodeWindow(source, "Shader Source", item.RootWindow.Window);
}
return null;
}

View File

@@ -79,6 +79,11 @@ bool LinuxPlatformTools::OnDeployBinaries(CookingData& data)
const String gameExePath = outputPath / TEXT("FlaxGame");
#endif
// Ensure the output binary can be executed
#if PLATFORM_LINUX
system(*StringAnsi(String::Format(TEXT("chmod +x \"{0}\""), gameExePath)));
#endif
// Apply game icon
TextureData iconData;
if (!EditorUtilities::GetApplicationImage(platformSettings->OverrideIcon, iconData))

View File

@@ -101,7 +101,7 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
// Deploy files
Array<String> files(16);
const String outputPath = StringUtils::GetDirectoryName(path);
FileSystem::DirectoryGetFiles(files, outputPath, TEXT("*.*"), DirectorySearchOption::TopDirectoryOnly);
FileSystem::DirectoryGetFiles(files, outputPath, TEXT("*"), DirectorySearchOption::TopDirectoryOnly);
for (int32 i = files.Count() - 1; i >= 0; i--)
{
bool skip = false;

View File

@@ -368,6 +368,7 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
// Compile for a target platform
switch (data.Data.Platform)
{
#if PLATFORM_TOOLS_WINDOWS
case BuildPlatform::Windows32:
case BuildPlatform::Windows64:
{
@@ -391,6 +392,7 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
}
break;
}
#endif
#if PLATFORM_TOOLS_UWP
case BuildPlatform::UWPx86:
case BuildPlatform::UWPx64:
@@ -408,12 +410,14 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
break;
}
#endif
#if PLATFORM_TOOLS_UWP
case BuildPlatform::XboxOne:
{
const char* platformDefineName = "PLATFORM_XBOX_ONE";
COMPILE_PROFILE(DirectX_SM4, SHADER_FILE_CHUNK_INTERNAL_D3D_SM4_CACHE);
break;
}
#endif
#if PLATFORM_TOOLS_LINUX
case BuildPlatform::LinuxX64:
{
@@ -426,24 +430,30 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
break;
}
#endif
#if PLATFORM_TOOLS_PS4
case BuildPlatform::PS4:
{
const char* platformDefineName = "PLATFORM_PS4";
COMPILE_PROFILE(PS4, SHADER_FILE_CHUNK_INTERNAL_GENERIC_CACHE);
break;
}
#endif
#if PLATFORM_TOOLS_XBOX_SCARLETT
case BuildPlatform::XboxScarlett:
{
const char* platformDefineName = "PLATFORM_XBOX_SCARLETT";
COMPILE_PROFILE(DirectX_SM6, SHADER_FILE_CHUNK_INTERNAL_D3D_SM6_CACHE);
break;
}
#endif
#if PLATFORM_TOOLS_ANDROID
case BuildPlatform::AndroidARM64:
{
const char* platformDefineName = "PLATFORM_ANDROID";
COMPILE_PROFILE(Vulkan_SM5, SHADER_FILE_CHUNK_INTERNAL_VULKAN_SM5_CACHE);
break;
}
#endif
default:
{
LOG(Warning, "Not implemented platform or shaders not supported.");
@@ -895,21 +905,27 @@ bool CookAssetsStep::Perform(CookingData& data)
cache.Load(data);
// Update build settings
#if PLATFORM_TOOLS_WINDOWS
{
const auto settings = WindowsPlatformSettings::Get();
cache.Settings.Windows.SupportDX11 = settings->SupportDX11;
cache.Settings.Windows.SupportDX10 = settings->SupportDX10;
cache.Settings.Windows.SupportVulkan = settings->SupportVulkan;
}
#endif
#if PLATFORM_TOOLS_UWP
{
const auto settings = UWPPlatformSettings::Get();
cache.Settings.UWP.SupportDX11 = settings->SupportDX11;
cache.Settings.UWP.SupportDX10 = settings->SupportDX10;
}
#endif
#if PLATFORM_TOOLS_LINUX
{
const auto settings = LinuxPlatformSettings::Get();
cache.Settings.Linux.SupportVulkan = settings->SupportVulkan;
}
#endif
{
cache.Settings.Global.ShadersNoOptimize = buildSettings->ShadersNoOptimize;
cache.Settings.Global.ShadersGenerateDebugData = buildSettings->ShadersGenerateDebugData;

View File

@@ -2,7 +2,9 @@
using System;
using System.Linq;
using System.Reflection;
using FlaxEditor.CustomEditors.Editors;
using FlaxEditor.CustomEditors.Elements;
using FlaxEditor.GUI;
using FlaxEditor.GUI.ContextMenu;
using FlaxEditor.Scripting;
@@ -349,6 +351,176 @@ namespace FlaxEditor.CustomEditors.Dedicated
// Show control properties
base.Initialize(layout);
for (int i = 0; i < layout.Children.Count; i++)
{
if (layout.Children[i] is GroupElement group && group.Panel.HeaderText == "Transform")
{
VerticalPanelElement mainHor = VerticalPanelWithoutMargin(group);
CreateTransformElements(mainHor, ValuesTypes);
group.ContainerControl.ChangeChildIndex(mainHor.Control, 0);
break;
}
}
}
private void CreateTransformElements(LayoutElementsContainer main, ScriptType[] valueTypes)
{
main.Space(10);
HorizontalPanelElement sidePanel = main.HorizontalPanel();
sidePanel.Panel.ClipChildren = false;
ScriptMemberInfo anchorInfo = valueTypes[0].GetProperty("AnchorPreset");
ItemInfo anchorItem = new ItemInfo(anchorInfo);
sidePanel.Object(anchorItem.GetValues(Values));
VerticalPanelElement group = VerticalPanelWithoutMargin(sidePanel);
group.Panel.AnchorPreset = AnchorPresets.HorizontalStretchTop;
group.Panel.Offsets = new Margin(100, 10, 0, 0);
var horUp = UniformGridTwoByOne(group);
horUp.CustomControl.Height = TextBoxBase.DefaultHeight;
var horDown = UniformGridTwoByOne(group);
horDown.CustomControl.Height = TextBoxBase.DefaultHeight;
GetAnchorEquality(out _cachedXEq, out _cachedYEq, valueTypes);
BuildLocationSizeOffsets(horUp, horDown, _cachedXEq, _cachedYEq, valueTypes);
main.Space(10);
BuildAnchorsDropper(main, valueTypes);
}
private void BuildAnchorsDropper(LayoutElementsContainer main, ScriptType[] valueTypes)
{
ScriptMemberInfo minInfo = valueTypes[0].GetProperty("AnchorMin");
ScriptMemberInfo maxInfo = valueTypes[0].GetProperty("AnchorMax");
ItemInfo minItem = new ItemInfo(minInfo);
ItemInfo maxItem = new ItemInfo(maxInfo);
GroupElement ng = main.Group("Anchors", true);
ng.Panel.Close(false);
ng.Property("Min", minItem.GetValues(Values));
ng.Property("Max", maxItem.GetValues(Values));
}
private void GetAnchorEquality(out bool xEq, out bool yEq, ScriptType[] valueTypes)
{
ScriptMemberInfo minInfo = valueTypes[0].GetProperty("AnchorMin");
ScriptMemberInfo maxInfo = valueTypes[0].GetProperty("AnchorMax");
ItemInfo minItem = new ItemInfo(minInfo);
ItemInfo maxItem = new ItemInfo(maxInfo);
ValueContainer minVal = minItem.GetValues(Values);
ValueContainer maxVal = maxItem.GetValues(Values);
ItemInfo xItem = new ItemInfo(minInfo.ValueType.GetField("X"));
ItemInfo yItem = new ItemInfo(minInfo.ValueType.GetField("Y"));
xEq = xItem.GetValues(minVal).ToList().Any(xItem.GetValues(maxVal).ToList().Contains);
yEq = yItem.GetValues(minVal).ToList().Any(yItem.GetValues(maxVal).ToList().Contains);
}
private void BuildLocationSizeOffsets(LayoutElementsContainer horUp, LayoutElementsContainer horDown, bool xEq, bool yEq, ScriptType[] valueTypes)
{
ScriptMemberInfo xInfo = valueTypes[0].GetProperty("X");
ItemInfo xItem = new ItemInfo(xInfo);
ScriptMemberInfo yInfo = valueTypes[0].GetProperty("Y");
ItemInfo yItem = new ItemInfo(yInfo);
ScriptMemberInfo widthInfo = valueTypes[0].GetProperty("Width");
ItemInfo widthItem = new ItemInfo(widthInfo);
ScriptMemberInfo heightInfo = valueTypes[0].GetProperty("Height");
ItemInfo heightItem = new ItemInfo(heightInfo);
ScriptMemberInfo leftInfo = valueTypes[0].GetProperty("Proxy_Offset_Left", BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
ItemInfo leftItem = new ItemInfo(leftInfo);
ScriptMemberInfo rightInfo = valueTypes[0].GetProperty("Proxy_Offset_Right", BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
ItemInfo rightItem = new ItemInfo(rightInfo);
ScriptMemberInfo topInfo = valueTypes[0].GetProperty("Proxy_Offset_Top", BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
ItemInfo topItem = new ItemInfo(topInfo);
ScriptMemberInfo bottomInfo = valueTypes[0].GetProperty("Proxy_Offset_Bottom", BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
ItemInfo bottomItem = new ItemInfo(bottomInfo);
LayoutElementsContainer xEl;
LayoutElementsContainer yEl;
LayoutElementsContainer hEl;
LayoutElementsContainer vEl;
if (xEq)
{
xEl = UniformPanelCapsuleForObjectWithText(horUp, "X: ", xItem.GetValues(Values));
vEl = UniformPanelCapsuleForObjectWithText(horDown, "Width: ", widthItem.GetValues(Values));
}
else
{
xEl = UniformPanelCapsuleForObjectWithText(horUp, "Left: ", leftItem.GetValues(Values));
vEl = UniformPanelCapsuleForObjectWithText(horDown, "Right: ", rightItem.GetValues(Values));
}
if (yEq)
{
yEl = UniformPanelCapsuleForObjectWithText(horUp, "Y: ", yItem.GetValues(Values));
hEl = UniformPanelCapsuleForObjectWithText(horDown, "Height: ", heightItem.GetValues(Values));
}
else
{
yEl = UniformPanelCapsuleForObjectWithText(horUp, "Top: ", topItem.GetValues(Values));
hEl = UniformPanelCapsuleForObjectWithText(horDown, "Bottom: ", bottomItem.GetValues(Values));
}
xEl.Control.AnchorMin = new Vector2(0, xEl.Control.AnchorMin.Y);
xEl.Control.AnchorMax = new Vector2(0.5f, xEl.Control.AnchorMax.Y);
vEl.Control.AnchorMin = new Vector2(0, xEl.Control.AnchorMin.Y);
vEl.Control.AnchorMax = new Vector2(0.5f, xEl.Control.AnchorMax.Y);
yEl.Control.AnchorMin = new Vector2(0.5f, xEl.Control.AnchorMin.Y);
yEl.Control.AnchorMax = new Vector2(1, xEl.Control.AnchorMax.Y);
hEl.Control.AnchorMin = new Vector2(0.5f, xEl.Control.AnchorMin.Y);
hEl.Control.AnchorMax = new Vector2(1, xEl.Control.AnchorMax.Y);
}
private VerticalPanelElement VerticalPanelWithoutMargin(LayoutElementsContainer cont)
{
var horUp = cont.VerticalPanel();
horUp.Panel.Margin = Margin.Zero;
return horUp;
}
private CustomElementsContainer<UniformGridPanel> UniformGridTwoByOne(LayoutElementsContainer cont)
{
var horUp = cont.CustomContainer<UniformGridPanel>();
horUp.CustomControl.SlotsHorizontally = 2;
horUp.CustomControl.SlotsVertically = 1;
horUp.CustomControl.SlotPadding = Margin.Zero;
horUp.CustomControl.ClipChildren = false;
return horUp;
}
private CustomElementsContainer<UniformGridPanel> UniformPanelCapsuleForObjectWithText(LayoutElementsContainer el, string text, ValueContainer values)
{
CustomElementsContainer<UniformGridPanel> hor = UniformGridTwoByOne(el);
hor.CustomControl.SlotPadding = new Margin(5, 5, 0, 0);
LabelElement lab = hor.Label(text);
hor.Object(values);
return hor;
}
private bool _cachedXEq;
private bool _cachedYEq;
/// <summary>
/// Refreshes if equality of anchors does not correspond to the cached equality
/// </summary>
public void RefreshBaseOnAnchorsEquality()
{
if (Values.HasNull)
return;
GetAnchorEquality(out bool xEq, out bool yEq, ValuesTypes);
if (xEq != _cachedXEq || yEq != _cachedYEq)
{
RebuildLayout();
return;
}
}
/// <inheritdoc />
@@ -361,6 +533,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
RebuildLayout();
return;
}
RefreshBaseOnAnchorsEquality();
//RefreshValues();
base.Refresh();
}
@@ -405,7 +579,13 @@ namespace FlaxEditor.CustomEditors.Dedicated
for (int i = 0; i < uiControls.Count; i++)
{
var uiControl = (UIControl)uiControls[i];
string previousName = uiControl.Control?.GetType()?.Name ?? typeof(UIControl).Name;
uiControl.Control = (Control)controlType.CreateInstance();
if (uiControl.Name.StartsWith(previousName))
{
string newName = controlType.Name + uiControl.Name.Substring(previousName.Length);
uiControl.Name = StringUtils.IncrementNameNumber(newName, x => uiControl.Parent.GetChild(x) == null);
}
}
}
}
@@ -414,7 +594,13 @@ namespace FlaxEditor.CustomEditors.Dedicated
for (int i = 0; i < uiControls.Count; i++)
{
var uiControl = (UIControl)uiControls[i];
string previousName = uiControl.Control?.GetType()?.Name ?? typeof(UIControl).Name;
uiControl.Control = (Control)controlType.CreateInstance();
if (uiControl.Name.StartsWith(previousName))
{
string newName = controlType.Name + uiControl.Name.Substring(previousName.Length);
uiControl.Name = StringUtils.IncrementNameNumber(newName, x => uiControl.Parent.GetChild(x) == null);
}
}
}

View File

@@ -173,6 +173,15 @@ namespace FlaxEditor.CustomEditors.Editors
return string.Compare(Display.Group, other.Display.Group, StringComparison.InvariantCulture);
}
if (Editor.Instance.Options.Options.General.ScriptMembersOrder == Options.GeneralOptions.MembersOrder.Declaration)
{
// By declaration order
if (Info.MetadataToken > other.Info.MetadataToken)
return 1;
if (Info.MetadataToken < other.Info.MetadataToken)
return -1;
}
// By name
return string.Compare(Info.Name, other.Info.Name, StringComparison.InvariantCulture);
}

View File

@@ -51,14 +51,17 @@ public class Editor : EditorModule
var platformToolsRoot = Path.Combine(FolderPath, "Cooker", "Platform");
var platformToolsRootExternal = Path.Combine(Globals.EngineRoot, "Source", "Platforms");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Windows", "PLATFORM_TOOLS_WINDOWS");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "UWP", "PLATFORM_TOOLS_UWP");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "UWP", "PLATFORM_TOOLS_XBOX_ONE");
if (options.Platform.Target == TargetPlatform.Windows)
{
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Windows", "PLATFORM_TOOLS_WINDOWS");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "UWP", "PLATFORM_TOOLS_UWP");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "UWP", "PLATFORM_TOOLS_XBOX_ONE");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "PS4", "PLATFORM_TOOLS_PS4");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "XboxScarlett", "PLATFORM_TOOLS_XBOX_SCARLETT");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Android", "PLATFORM_TOOLS_ANDROID");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Switch", "PLATFORM_TOOLS_SWITCH");
}
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Linux", "PLATFORM_TOOLS_LINUX");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "PS4", "PLATFORM_TOOLS_PS4");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "XboxScarlett", "PLATFORM_TOOLS_XBOX_SCARLETT");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Android", "PLATFORM_TOOLS_ANDROID");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Switch", "PLATFORM_TOOLS_SWITCH");
// Visual Studio integration
if (options.Platform.Target == TargetPlatform.Windows)

View File

@@ -1181,7 +1181,7 @@ namespace FlaxEditor
var win = Windows.GameWin.Root;
if (win != null && win.RootWindow is WindowRootControl root && root.Window.IsFocused)
{
pos = Vector2.Round(Windows.GameWin.Viewport.PointFromWindow(root.Window.ScreenToClient(pos)));
pos = Vector2.Round(Windows.GameWin.Viewport.PointFromScreen(pos) * root.DpiScale);
}
else
{
@@ -1201,7 +1201,7 @@ namespace FlaxEditor
var win = Windows.GameWin.Root;
if (win != null && win.RootWindow is WindowRootControl root && root.Window.IsFocused)
{
pos = Vector2.Round(root.Window.ClientToScreen(Windows.GameWin.Viewport.PointToWindow(pos)));
pos = Vector2.Round(Windows.GameWin.Viewport.PointToScreen(pos / root.DpiScale));
}
else
{
@@ -1231,13 +1231,18 @@ namespace FlaxEditor
var gameWin = Windows.GameWin;
if (gameWin != null)
{
// Handle case when Game window is not selected in tab view
var dockedTo = gameWin.ParentDockPanel;
if (dockedTo != null && dockedTo.SelectedTab != gameWin && dockedTo.SelectedTab != null)
resultAsRef = dockedTo.SelectedTab.Size;
else
resultAsRef = gameWin.Size;
resultAsRef = Vector2.Round(resultAsRef);
var win = gameWin.Root;
if (win != null && win.RootWindow is WindowRootControl root)
{
// Handle case when Game window is not selected in tab view
var dockedTo = gameWin.ParentDockPanel;
if (dockedTo != null && dockedTo.SelectedTab != gameWin && dockedTo.SelectedTab != null)
resultAsRef = dockedTo.SelectedTab.Size * root.DpiScale;
else
resultAsRef = gameWin.Size * root.DpiScale;
resultAsRef = Vector2.Round(resultAsRef);
}
}
}

View File

@@ -124,7 +124,7 @@ namespace FlaxEditor.GUI.ContextMenu
PerformLayout();
// Calculate popup direction and initial location (fit on a single monitor)
var dpiScale = Platform.DpiScale;
var dpiScale = parentWin.DpiScale;
Vector2 dpiSize = Size * dpiScale;
Vector2 locationWS = parent.PointToWindow(location);
Vector2 locationSS = parentWin.PointToScreen(locationWS);
@@ -275,7 +275,7 @@ namespace FlaxEditor.GUI.ContextMenu
{
if (_window != null)
{
_window.ClientSize = Size * Platform.DpiScale;
_window.ClientSize = Size * _window.DpiScale;
}
}

View File

@@ -143,7 +143,7 @@ namespace FlaxEditor.GUI.Dialogs
// Setup initial window settings
CreateWindowSettings settings = CreateWindowSettings.Default;
settings.Title = _title;
settings.Size = _dialogSize * Platform.DpiScale;
settings.Size = _dialogSize * parentWindow.DpiScale;
settings.AllowMaximize = false;
settings.AllowMinimize = false;
settings.HasSizingFrame = false;

View File

@@ -123,9 +123,8 @@ namespace FlaxEditor.GUI.Docking
if (parentWin == null)
throw new InvalidOperationException("Missing parent window.");
var control = _tabsProxy != null ? (Control)_tabsProxy : this;
var dpiScale = Platform.DpiScale;
var clientPos = control.PointToWindow(Vector2.Zero);
return new Rectangle(parentWin.PointToScreen(clientPos), control.Size * dpiScale);
return new Rectangle(parentWin.PointToScreen(clientPos), control.Size * RootWindow.DpiScale);
}
}
@@ -290,6 +289,10 @@ namespace FlaxEditor.GUI.Docking
}
OnSelectedTabChanged();
}
else if (autoFocus && _selectedTab != null && !_selectedTab.ContainsFocus)
{
_selectedTab.Focus();
}
}
/// <summary>

View File

@@ -190,15 +190,15 @@ namespace FlaxEditor.GUI
private WindowHitCodes OnHitTest(ref Vector2 mouse)
{
var pos = _window.ScreenToClient(mouse * Platform.DpiScale);
var dpiScale = _window.DpiScale;
if (_window.IsMinimized)
return WindowHitCodes.NoWhere;
if (!_window.IsMaximized)
{
var dpiScale = Platform.DpiScale;
var winSize = RootWindow.Size * dpiScale;
var pos = _window.ScreenToClient(mouse * dpiScale); // pos is not DPI adjusted
var winSize = _window.Size;
// Distance from which the mouse is considered to be on the border/corner
float distance = 5.0f * dpiScale;
@@ -228,11 +228,11 @@ namespace FlaxEditor.GUI
return WindowHitCodes.Bottom;
}
var menuPos = PointFromWindow(pos);
var controlUnderMouse = GetChildAt(menuPos);
var mousePos = PointFromScreen(mouse * dpiScale);
var controlUnderMouse = GetChildAt(mousePos);
var isMouseOverSth = controlUnderMouse != null && controlUnderMouse != _title;
var rb = GetRightButton();
if (rb != null && _minimizeButton != null && new Rectangle(rb.UpperRight * Platform.DpiScale, (_minimizeButton.BottomLeft - rb.UpperRight) * Platform.DpiScale).Contains(ref menuPos) && !isMouseOverSth)
if (rb != null && _minimizeButton != null && new Rectangle(rb.UpperRight, _minimizeButton.BottomLeft - rb.UpperRight).Contains(ref mousePos) && !isMouseOverSth)
return WindowHitCodes.Caption;
return WindowHitCodes.Client;

View File

@@ -707,8 +707,9 @@ namespace FlaxEditor.Modules
var dpiScale = Platform.DpiScale;
var settings = CreateWindowSettings.Default;
settings.Title = "Flax Editor";
settings.Size = new Vector2(1300 * dpiScale, 900 * dpiScale);
settings.Size = Platform.DesktopSize;
settings.StartPosition = WindowStartPosition.CenterScreen;
settings.ShowAfterFirstPaint = true;
#if PLATFORM_WINDOWS
if (!Editor.Instance.Options.Options.Interface.UseNativeWindowSystem)

View File

@@ -68,6 +68,24 @@ namespace FlaxEditor.Options
CompileScripts,
}
/// <summary>
/// Order of script members show in editor
/// </summary>
public enum MembersOrder
{
/// <summary>
/// Shows properties/fields in alphabetical order
/// </summary>
[Tooltip("Shows properties/fields in alphabetical order")]
Alphabetical,
/// <summary>
/// Shows properties/fields in declaration order
/// </summary>
[Tooltip("Shows properties/fields in declaration order")]
Declaration
}
/// <summary>
/// Gets or sets the scene to load on editor startup.
/// </summary>
@@ -116,6 +134,13 @@ namespace FlaxEditor.Options
[EditorDisplay("Scripting", "Force Script Compilation On Startup"), EditorOrder(501), Tooltip("Determines whether automatically compile game scripts before starting the editor.")]
public bool ForceScriptCompilationOnStartup { get; set; } = true;
/// <summary>
/// Gets or sets an order of script properties/fields in properties panel.
/// </summary>
[DefaultValue(MembersOrder.Alphabetical)]
[EditorDisplay("Scripting", "Script Members Order"), EditorOrder(503), Tooltip("Order of script properties/fields in properties panel")]
public MembersOrder ScriptMembersOrder { get; set; } = MembersOrder.Alphabetical;
/// <summary>
/// Gets or sets a value indicating whether automatically save the Visual Script asset editors when starting the play mode in editor.
/// </summary>

View File

@@ -18,6 +18,13 @@ namespace FlaxEditor.Options
[EditorDisplay("General"), EditorOrder(100), Tooltip("The mouse movement sensitivity scale applied when using the viewport camera.")]
public float MouseSensitivity { get; set; } = 1.0f;
/// <summary>
/// Gets or sets the mouse wheel sensitivity applied to zoom in orthographic mode.
/// </summary>
[DefaultValue(1.0f), Limit(0.01f, 100.0f)]
[EditorDisplay("General"), EditorOrder(101), Tooltip("The mouse wheel sensitivity applied to zoom in orthographic mode.")]
public float MouseWheelSensitivity { get; set; } = 1.0f;
/// <summary>
/// Gets or sets the default movement speed for the viewport camera (must match the dropdown menu values in the viewport).
/// </summary>

View File

@@ -40,6 +40,27 @@ namespace FlaxEditor.Scripting
/// </summary>
public string Name => _managed?.Name ?? _custom?.Name;
/// <summary>
/// Gets a metadata token for sorting so it may not be the actual token.
/// </summary>
public int MetadataToken
{
get
{
int standardToken = _managed?.MetadataToken ?? _custom?.MetadataToken ?? 0;
if (_managed is PropertyInfo && _managed.DeclaringType != null)
{
var field = _managed.DeclaringType.GetField(string.Format("<{0}>k__BackingField", Name), BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null || field.MetadataToken == 0)
{
return standardToken;
}
return field.MetadataToken;
}
return standardToken;
}
}
/// <summary>
/// Gets a value indicating whether the type is declared public.
/// </summary>
@@ -1444,6 +1465,11 @@ namespace FlaxEditor.Scripting
/// </summary>
string Name { get; }
/// <summary>
/// Gets a metadata token for sorting so it may not be the actual token.
/// </summary>
int MetadataToken { get; }
/// <summary>
/// Gets a value indicating whether the type is declared public.
/// </summary>

View File

@@ -108,11 +108,13 @@ namespace FlaxEditor.Surface.ContextMenu
{
_resultPanel.DisposeChildren();
var dpiScale = RootWindow.DpiScale;
if (items.Count == 0)
{
Height = _searchBox.Height + 1;
_resultPanel.ScrollBars = ScrollBars.None;
RootWindow.Window.ClientSize = new Vector2(RootWindow.Window.ClientSize.X, Height * Platform.DpiScale);
RootWindow.Window.ClientSize = new Vector2(RootWindow.Window.ClientSize.X, Height * dpiScale);
return;
}
@@ -146,7 +148,7 @@ namespace FlaxEditor.Surface.ContextMenu
MatchedItems.Add(searchItem);
}
RootWindow.Window.ClientSize = new Vector2(RootWindow.Window.ClientSize.X, Height * Platform.DpiScale);
RootWindow.Window.ClientSize = new Vector2(RootWindow.Window.ClientSize.X, Height * dpiScale);
PerformLayout();
}

View File

@@ -1646,8 +1646,8 @@ namespace FlaxEditor.Utilities
/// </summary>
/// <param name="source">The source code.</param>
/// <param name="title">The window title.</param>
/// <param name="control">The context control used to show source code window popup in a proper location.</param>
public static void ShowSourceCodeWindow(string source, string title, Control control = null)
/// <param name="parentWindow">The optional parent window.</param>
public static void ShowSourceCodeWindow(string source, string title, Window parentWindow = null)
{
if (string.IsNullOrEmpty(source))
{
@@ -1661,8 +1661,8 @@ namespace FlaxEditor.Utilities
settings.AllowMinimize = false;
settings.HasSizingFrame = false;
settings.StartPosition = WindowStartPosition.CenterParent;
settings.Size = new Vector2(500, 600) * Platform.DpiScale;
settings.Parent = control?.RootWindow?.Window ?? Editor.Instance.Windows.MainWindow;
settings.Size = new Vector2(500, 600) * (parentWindow?.DpiScale ?? Platform.DpiScale);
settings.Parent = parentWindow;
settings.Title = title;
var dialog = Platform.CreateWindow(ref settings);

View File

@@ -88,6 +88,17 @@ namespace FlaxEditor.Viewport.Cameras
Editor.GetActorEditorSphere(actor, out BoundingSphere sphere);
ShowSphere(ref sphere);
}
/// <summary>
/// Moves the viewport to visualize selected actors.
/// </summary>
/// <param name="actor">The actors to show.</param>
/// <param name="orientation">The used orientation.</param>
public void ShowActor(Actor actor, ref Quaternion orientation)
{
Editor.GetActorEditorSphere(actor, out BoundingSphere sphere);
ShowSphere(ref sphere, ref orientation);
}
/// <summary>
/// Moves the viewport to visualize selected actors.
@@ -111,17 +122,50 @@ namespace FlaxEditor.Viewport.Cameras
ShowSphere(ref mergesSphere);
}
/// <summary>
/// Moves the viewport to visualize selected actors.
/// </summary>
/// <param name="actors">The actors to show.</param>
/// <param name="orientation">The used orientation.</param>
public void ShowActors(List<SceneGraphNode> actors, ref Quaternion orientation)
{
if (actors.Count == 0)
return;
BoundingSphere mergesSphere = BoundingSphere.Empty;
for (int i = 0; i < actors.Count; i++)
{
if (actors[i] is ActorNode actor)
{
Editor.GetActorEditorSphere(actor.Actor, out BoundingSphere sphere);
BoundingSphere.Merge(ref mergesSphere, ref sphere, out mergesSphere);
}
}
ShowSphere(ref mergesSphere, ref orientation);
}
private void ShowSphere(ref BoundingSphere sphere)
{
// Calculate view transform
Quaternion orientation = new Quaternion(0.424461186f, -0.0940724313f, 0.0443938486f, 0.899451137f);
Vector3 position = sphere.Center - Vector3.Forward * orientation * (sphere.Radius * 2.5f);
// Move viewport
TargetPoint = sphere.Center;
MoveViewport(position, orientation);
var q = new Quaternion(0.424461186f, -0.0940724313f, 0.0443938486f, 0.899451137f);
ShowSphere(ref sphere, ref q);
}
private void ShowSphere(ref BoundingSphere sphere, ref Quaternion orientation)
{
Vector3 position;
if (Viewport.UseOrthographicProjection)
{
position = sphere.Center + Vector3.Backward * orientation * (sphere.Radius * 5.0f);
Viewport.OrthographicScale = Vector3.Distance(position, sphere.Center) / 1000;
}
else
position = sphere.Center - Vector3.Forward * orientation * (sphere.Radius * 2.5f);
TargetPoint = position;
MoveViewport(position, orientation);
}
/// <inheritdoc />
public override void Update(float deltaTime)
{

View File

@@ -1,6 +1,7 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using FlaxEditor.Gizmo;
using FlaxEditor.GUI.ContextMenu;
using FlaxEditor.GUI.Input;
using FlaxEditor.Options;
@@ -538,21 +539,30 @@ namespace FlaxEditor.Viewport
{
_isOrtho = checkBox.Checked;
ViewWidgetButtonMenu.Hide();
if (_isOrtho)
{
var orient = ViewOrientation;
OrientViewport(ref orient);
}
}
};
ViewWidgetButtonMenu.VisibleChanged += control => orthoValue.Checked = _isOrtho;
}
// Cara Orientation
// Camera Viewpoints
{
var cameraView = ViewWidgetButtonMenu.AddChildMenu("Orientation").ContextMenu;
for (int i = 0; i < EditorViewportCameraOrientationValues.Length; i++)
var cameraView = ViewWidgetButtonMenu.AddChildMenu("Viewpoints").ContextMenu;
for (int i = 0; i < EditorViewportCameraViewpointValues.Length; i++)
{
var co = EditorViewportCameraOrientationValues[i];
var co = EditorViewportCameraViewpointValues[i];
var button = cameraView.AddButton(co.Name);
button.Tag = co.Orientation;
}
cameraView.ButtonClicked += button => ViewOrientation = Quaternion.Euler((Vector3)button.Tag);
cameraView.ButtonClicked += button =>
{
var orient = Quaternion.Euler((Vector3)button.Tag);
OrientViewport(ref orient);
};
}
// Field of View
@@ -654,6 +664,19 @@ namespace FlaxEditor.Viewport
task.Begin += OnRenderBegin;
}
private void OrientViewport(ref Quaternion orientation)
{
if (Editor.Instance.SceneEditing.HasSthSelected)
{
((FPSCamera)ViewportCamera).ShowActors(Editor.Instance.Windows.EditWin.Viewport.TransformGizmo.SelectedParents, ref orientation);
}
else
{
var pos = new Vector3(0.0f) + Vector3.Backward * orientation * 2000.0f;
((FPSCamera)ViewportCamera).MoveViewport(pos, orientation);
}
}
private void OnEditorOptionsChanged(EditorOptions options)
{
_mouseSensitivity = options.Viewport.MouseSensitivity;
@@ -994,6 +1017,7 @@ namespace FlaxEditor.Viewport
var options = Editor.Instance.Options.Options.Input;
if (_isControllingMouse)
{
var rmbWheel = false;
// Gather input
{
bool isAltDown = _input.IsAltDown;
@@ -1009,10 +1033,11 @@ namespace FlaxEditor.Viewport
_input.IsOrbiting = isAltDown && lbDown && !mbDown && !rbDown;
// Control move speed with RMB+Wheel
if (useMovementSpeed && _input.IsMouseRightDown && wheelInUse)
rmbWheel = useMovementSpeed && _input.IsMouseRightDown && wheelInUse;
if (rmbWheel)
{
float step = 4.0f;
_wheelMovementChangeDeltaSum += _input.MouseWheelDelta;
_wheelMovementChangeDeltaSum += _input.MouseWheelDelta * Editor.Instance.Options.Options.Viewport.MouseWheelSensitivity;
int camValueIndex = -1;
for (int i = 0; i < EditorViewportCameraSpeedValues.Length; i++)
{
@@ -1076,7 +1101,7 @@ namespace FlaxEditor.Viewport
// Calculate smooth mouse delta not dependant on viewport size
Vector2 offset = _viewMousePos - _startPos;
if (_input.IsZooming && !_input.IsMouseRightDown && !_input.IsMouseLeftDown && !_input.IsMouseMiddleDown)
if (_input.IsZooming && !_input.IsMouseRightDown && !_input.IsMouseLeftDown && !_input.IsMouseMiddleDown && !_isOrtho && !rmbWheel)
{
offset = Vector2.Zero;
}
@@ -1125,6 +1150,14 @@ namespace FlaxEditor.Viewport
Vector2 center = PointToWindow(_startPos);
win.MousePosition = center;
}
// Change Ortho size on mouse scroll
if (_isOrtho && !rmbWheel)
{
var scroll = _input.MouseWheelDelta;
if (scroll > Mathf.Epsilon || scroll < -Mathf.Epsilon)
_orthoSize -= scroll * Editor.Instance.Options.Options.Viewport.MouseWheelSensitivity * 0.2f * _orthoSize;
}
}
else
{
@@ -1260,26 +1293,26 @@ namespace FlaxEditor.Viewport
base.OnDestroy();
}
private struct CameraOrientation
private struct CameraViewpoint
{
public readonly string Name;
public readonly Vector3 Orientation;
public CameraOrientation(string name, Vector3 orientation)
public CameraViewpoint(string name, Vector3 orientation)
{
Name = name;
Orientation = orientation;
}
}
private readonly CameraOrientation[] EditorViewportCameraOrientationValues =
private readonly CameraViewpoint[] EditorViewportCameraViewpointValues =
{
new CameraOrientation("Front", new Vector3(0, 0, 0)),
new CameraOrientation("Back", new Vector3(0, 180, 0)),
new CameraOrientation("Left", new Vector3(0, -90, 0)),
new CameraOrientation("Right", new Vector3(0, 90, 0)),
new CameraOrientation("Top", new Vector3(90, 0, 0)),
new CameraOrientation("Bottom", new Vector3(-90, 0, 0))
new CameraViewpoint("Front", new Vector3(0, 180, 0)),
new CameraViewpoint("Back", new Vector3(0, 0, 0)),
new CameraViewpoint("Left", new Vector3(0, 90, 0)),
new CameraViewpoint("Right", new Vector3(0, -90, 0)),
new CameraViewpoint("Top", new Vector3(90, 0, 0)),
new CameraViewpoint("Bottom", new Vector3(-90, 0, 0))
};
private readonly float[] EditorViewportCameraSpeedValues =

View File

@@ -1042,10 +1042,12 @@ namespace FlaxEditor.Viewport
DisposeModes();
_debugDrawData.Dispose();
//Object.Destroy(ref SelectionOutline);
//Object.Destroy(ref EditorPrimitives);
//Object.Destroy(ref _editorSpritesRenderer);
//Object.Destroy(ref _customSelectionOutline);
if (_task != null)
{
// Release if task is not used to save screenshot for project icon
Object.Destroy(ref _task);
ReleaseResources();
}
base.OnDestroy();
}
@@ -1062,7 +1064,6 @@ namespace FlaxEditor.Viewport
_task = null;
_backBuffer = null;
_editorSpritesRenderer = null;
}
internal void SaveProjectIconEnd()
@@ -1070,9 +1071,19 @@ namespace FlaxEditor.Viewport
if (_savedTask)
{
_savedTask.Enabled = false;
Object.Destroy(_savedTask);
ReleaseResources();
_savedTask = null;
}
Object.Destroy(ref _savedBackBuffer);
}
private void ReleaseResources()
{
Object.Destroy(ref SelectionOutline);
Object.Destroy(ref EditorPrimitives);
Object.Destroy(ref _editorSpritesRenderer);
Object.Destroy(ref _customSelectionOutline);
}
}
}

View File

@@ -240,7 +240,7 @@ namespace FlaxEditor.Windows.Assets
private void ShowSourceCode()
{
var source = Editor.GetShaderSourceCode(_asset);
Utilities.Utils.ShowSourceCodeWindow(source, "Material Source", this);
Utilities.Utils.ShowSourceCodeWindow(source, "Material Source", RootWindow.Window);
}
/// <summary>

View File

@@ -146,7 +146,7 @@ namespace FlaxEditor.Windows.Assets
private void ShowSourceCode()
{
var source = Editor.GetShaderSourceCode(_asset);
Utilities.Utils.ShowSourceCodeWindow(source, "Particle Emitter GPU Simulation Source", this);
Utilities.Utils.ShowSourceCodeWindow(source, "Particle Emitter GPU Simulation Source", RootWindow.Window);
}
/// <inheritdoc />

View File

@@ -371,7 +371,7 @@ namespace FlaxEditor.Windows
// Focus content window
Focus();
RootWindow?.Window.Focus();
RootWindow?.Focus();
}
// Refresh database and view now

View File

@@ -243,7 +243,13 @@ namespace FlaxEditor.Windows
/// </summary>
public void ShowSelectedActors()
{
((FPSCamera)Viewport.ViewportCamera).ShowActors(Viewport.TransformGizmo.SelectedParents);
if (Viewport.UseOrthographicProjection)
{
var orient = Viewport.ViewOrientation;
((FPSCamera)Viewport.ViewportCamera).ShowActors(Viewport.TransformGizmo.SelectedParents, ref orient);
}
else
((FPSCamera)Viewport.ViewportCamera).ShowActors(Viewport.TransformGizmo.SelectedParents);
}
/// <summary>

View File

@@ -61,6 +61,9 @@ namespace FlaxEditor.Windows
public abstract class Platform
{
[HideInEditor]
public bool IsSupported;
[HideInEditor]
public bool IsAvailable;
@@ -93,6 +96,23 @@ namespace FlaxEditor.Windows
{
Output = output;
// Check if can build on that platform
#if PLATFORM_WINDOWS
IsSupported = true;
#elif PLATFORM_LINUX
switch (BuildPlatform)
{
case BuildPlatform.LinuxX64:
IsSupported = true;
break;
default:
IsSupported = false;
break;
}
#else
#error "Unknown platform."
#endif
// TODO: restore build settings from the Editor cache!
// Check if can find installed tools for this platform
@@ -179,7 +199,11 @@ namespace FlaxEditor.Windows
_platform = proxy.Selector.Selected;
var platformObj = proxy.PerPlatformOptions[_platform];
if (platformObj.IsAvailable)
if (!platformObj.IsSupported)
{
layout.Label("This platform is not supported on this system.", TextAlignment.Center);
}
else if (platformObj.IsAvailable)
{
string name;
switch (_platform)

View File

@@ -222,7 +222,7 @@ namespace FlaxEditor.Windows
}
else if (((ContainerControl)_tree.GetChild(0)).ChildrenCount == 0)
{
overlayText = "No scene";
overlayText = "No scene\nOpen one from the content window";
}
if (overlayText != null)
{