Merge remote-tracking branch 'origin/master' into linux-editor

# Conflicts:
#	Source/Engine/Core/Math/Color.cs
#	Source/Engine/Navigation/Navigation.cpp
#	Source/Engine/Platform/Win32/Win32Platform.cpp
This commit is contained in:
Wojtek Figat
2021-02-23 22:29:07 +01:00
147 changed files with 1740 additions and 1311 deletions

View File

@@ -5,6 +5,7 @@
API_CLASS() class %module%%class% : public Script
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE(%class%);
// [Script]

View File

@@ -26,8 +26,7 @@ namespace FlaxEditor.Content
{
if (reader.TokenType == JsonToken.String)
{
Guid id;
FlaxEngine.Json.JsonSerializer.ParseID((string)reader.Value, out id);
FlaxEngine.Json.JsonSerializer.ParseID((string)reader.Value, out Guid id);
return Editor.Instance.ContentDatabase.Find(id);
}

View File

@@ -113,8 +113,7 @@ namespace FlaxEditor.Content.Import
extension = extension.ToLower();
// Check if use overriden type
ImportFileEntryHandler createDelegate;
if (FileTypes.TryGetValue(extension, out createDelegate))
if (FileTypes.TryGetValue(extension, out ImportFileEntryHandler createDelegate))
return createDelegate(ref request);
// Use default type

View File

@@ -32,7 +32,7 @@ namespace FlaxEditor.Content.Import
var result = 0;
for (int i = 0; i < _rootNode.ChildrenCount; i++)
{
if (_rootNode.Children[i].Tag is ImportFileEntry fileEntry)
if (_rootNode.Children[i].Tag is ImportFileEntry)
result++;
}
return result;
@@ -215,8 +215,7 @@ namespace FlaxEditor.Content.Import
var entries = new List<ImportFileEntry>(_rootNode.ChildrenCount);
for (int i = 0; i < _rootNode.ChildrenCount; i++)
{
var fileEntry = _rootNode.Children[i].Tag as ImportFileEntry;
if (fileEntry != null)
if (_rootNode.Children[i].Tag is ImportFileEntry fileEntry)
entries.Add(fileEntry);
}
Editor.Instance.ContentImporting.LetThemBeImportedxD(entries);

View File

@@ -599,7 +599,7 @@ namespace FlaxEditor.Content
public override bool OnShowTooltip(out string text, out Vector2 location, out Rectangle area)
{
UpdateTooltipText();
var result = base.OnShowTooltip(out text, out location, out area);
var result = base.OnShowTooltip(out text, out _, out area);
location = Size * new Vector2(0.9f, 0.5f);
return result;
}

View File

@@ -74,12 +74,13 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
var actor = arg as Actor;
if (actor == null)
if (!(arg is Actor actor))
{
// Create default prefab root object
actor = new EmptyActor();
actor.Name = "Root";
actor = new EmptyActor
{
Name = "Root"
};
// Cleanup it after usage
Object.Destroy(actor, 20.0f);

View File

@@ -120,9 +120,8 @@ namespace FlaxEditor.Content
}
else
{
QueryFilterHelper.Range[] ranges;
var text = Text;
if (QueryFilterHelper.Match(filterText, text, out ranges))
if (QueryFilterHelper.Match(filterText, text, out QueryFilterHelper.Range[] ranges))
{
// Update highlights
if (_highlights == null)

View File

@@ -33,8 +33,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
var scriptsMember = type.GetProperty("Scripts");
if (scriptsMember != ScriptMemberInfo.Null)
{
var item = new ItemInfo(scriptsMember);
item.CustomEditor = new CustomEditorAttribute(typeof(ScriptsEditor));
var item = new ItemInfo(scriptsMember)
{
CustomEditor = new CustomEditorAttribute(typeof(ScriptsEditor))
};
items.Add(item);
}
@@ -195,9 +197,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
private TreeNode CreateDiffNode(CustomEditor editor)
{
var node = new TreeNode(false);
node.Tag = editor;
var node = new TreeNode(false)
{
Tag = editor
};
// Removed Script
if (editor is RemovedScriptDummy removed)

View File

@@ -493,8 +493,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
var index = (int)image.Tag;
var cm = new ContextMenu();
cm.Tag = index;
var cm = new ContextMenu
{
Tag = index
};
cm.AddButton("Remove", OnClickMissingRemove);
cm.Show(image, image.Size);
}
@@ -746,8 +748,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
var scriptType = TypeUtils.GetType(script.TypeName);
var item = scriptType.ContentItem;
var cm = new ContextMenu();
cm.Tag = script;
var cm = new ContextMenu
{
Tag = script
};
cm.AddButton("Remove", OnClickRemove).Icon = Editor.Instance.Icons.Cross12;
cm.AddButton("Move up", OnClickMoveUp).Enabled = script.OrderInParent > 0;
cm.AddButton("Move down", OnClickMoveDown).Enabled = script.OrderInParent < script.Actor.Scripts.Length - 1;

View File

@@ -26,8 +26,7 @@ namespace FlaxEditor.CustomEditors.Editors
private void OnEditEnd()
{
Guid value;
if (Guid.TryParse(_element.Text, out value))
if (Guid.TryParse(_element.Text, out Guid value))
{
SetValue(value);
}

View File

@@ -63,8 +63,7 @@ namespace FlaxEditor.CustomEditors.Editors
float z = ZElement.FloatValue.Value;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding;
var token = isSliding ? this : null;
Quaternion value;
Quaternion.Euler(x, y, z, out value);
Quaternion.Euler(x, y, z, out Quaternion value);
SetValue(value, token);
}

View File

@@ -261,13 +261,17 @@ namespace FlaxEditor.CustomEditors.Editors
// Ensure to have valid drag helpers (uses lazy init)
if (_dragActors == null)
_dragActors = new DragActors(x => IsValid(TypeUtils.GetObjectType(x.Actor)));
if (_dragScripts == null)
_dragScripts = new DragScripts(x => IsValid(TypeUtils.GetObjectType(x)));
if (_dragHandlers == null)
{
_dragHandlers = new DragHandlers();
_dragHandlers.Add(_dragActors);
_dragHandlers.Add(_dragScripts);
_dragHandlers = new DragHandlers
{
_dragActors,
_dragScripts
};
}
_hasValidDragOver = _dragHandlers.OnDragEnter(data) != DragDropEffect.None;

View File

@@ -21,8 +21,10 @@ namespace FlaxEditor.CustomEditors.Elements
/// </summary>
public LabelElement()
{
Label = new Label(0, 0, 100, 18);
Label.HorizontalAlignment = TextAlignment.Near;
Label = new Label(0, 0, 100, 18)
{
HorizontalAlignment = TextAlignment.Near
};
// TODO: auto height for label
}

View File

@@ -193,8 +193,10 @@ namespace FlaxEditor.GUI.ContextMenu
/// <returns>Created context menu item control.</returns>
public ContextMenuButton AddButton(string text)
{
var item = new ContextMenuButton(this, text);
item.Parent = _panel;
var item = new ContextMenuButton(this, text)
{
Parent = _panel
};
SortButtons();
return item;
}
@@ -207,8 +209,10 @@ namespace FlaxEditor.GUI.ContextMenu
/// <returns>Created context menu item control.</returns>
public ContextMenuButton AddButton(string text, string shortKeys)
{
var item = new ContextMenuButton(this, text, shortKeys);
item.Parent = _panel;
var item = new ContextMenuButton(this, text, shortKeys)
{
Parent = _panel
};
SortButtons();
return item;
}
@@ -221,8 +225,10 @@ namespace FlaxEditor.GUI.ContextMenu
/// <returns>Created context menu item control.</returns>
public ContextMenuButton AddButton(string text, Action clicked)
{
var item = new ContextMenuButton(this, text);
item.Parent = _panel;
var item = new ContextMenuButton(this, text)
{
Parent = _panel
};
item.Clicked += clicked;
SortButtons();
return item;
@@ -236,8 +242,10 @@ namespace FlaxEditor.GUI.ContextMenu
/// <returns>Created context menu item control.</returns>
public ContextMenuButton AddButton(string text, Action<ContextMenuButton> clicked)
{
var item = new ContextMenuButton(this, text);
item.Parent = _panel;
var item = new ContextMenuButton(this, text)
{
Parent = _panel
};
item.ButtonClicked += clicked;
SortButtons();
return item;
@@ -252,8 +260,10 @@ namespace FlaxEditor.GUI.ContextMenu
/// <returns>Created context menu item control.</returns>
public ContextMenuButton AddButton(string text, string shortKeys, Action clicked)
{
var item = new ContextMenuButton(this, text, shortKeys);
item.Parent = _panel;
var item = new ContextMenuButton(this, text, shortKeys)
{
Parent = _panel
};
item.Clicked += clicked;
SortButtons();
return item;
@@ -285,8 +295,10 @@ namespace FlaxEditor.GUI.ContextMenu
var item = GetChildMenu(text);
if (item == null)
{
item = new ContextMenuChildMenu(this, text);
item.Parent = _panel;
item = new ContextMenuChildMenu(this, text)
{
Parent = _panel
};
}
return item;
@@ -299,8 +311,10 @@ namespace FlaxEditor.GUI.ContextMenu
/// <returns>Created context menu item control.</returns>
public ContextMenuChildMenu AddChildMenu(string text)
{
var item = new ContextMenuChildMenu(this, text);
item.Parent = _panel;
var item = new ContextMenuChildMenu(this, text)
{
Parent = _panel
};
return item;
}
@@ -310,8 +324,10 @@ namespace FlaxEditor.GUI.ContextMenu
/// <returns>Created context menu item control.</returns>
public ContextMenuSeparator AddSeparator()
{
var item = new ContextMenuSeparator(this);
item.Parent = _panel;
var item = new ContextMenuSeparator(this)
{
Parent = _panel
};
return item;
}

View File

@@ -113,53 +113,71 @@ namespace FlaxEditor.GUI.Dialogs
_onClosed = pickerClosed;
// Selector
_cSelector = new ColorSelectorWithSliders(180, 18);
_cSelector.Location = new Vector2(PickerMargin, PickerMargin);
_cSelector = new ColorSelectorWithSliders(180, 18)
{
Location = new Vector2(PickerMargin, PickerMargin),
Parent = this
};
_cSelector.ColorChanged += x => SelectedColor = x;
_cSelector.Parent = this;
// Red
_cRed = new FloatValueBox(0, _cSelector.Right + PickerMargin + RGBAMargin + ChannelTextWidth, PickerMargin, 100, 0, float.MaxValue, 0.001f);
_cRed = new FloatValueBox(0, _cSelector.Right + PickerMargin + RGBAMargin + ChannelTextWidth, PickerMargin, 100, 0, float.MaxValue, 0.001f)
{
Parent = this
};
_cRed.ValueChanged += OnRGBAChanged;
_cRed.Parent = this;
// Green
_cGreen = new FloatValueBox(0, _cRed.X, _cRed.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f);
_cGreen = new FloatValueBox(0, _cRed.X, _cRed.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f)
{
Parent = this
};
_cGreen.ValueChanged += OnRGBAChanged;
_cGreen.Parent = this;
// Blue
_cBlue = new FloatValueBox(0, _cRed.X, _cGreen.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f);
_cBlue = new FloatValueBox(0, _cRed.X, _cGreen.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f)
{
Parent = this
};
_cBlue.ValueChanged += OnRGBAChanged;
_cBlue.Parent = this;
// Alpha
_cAlpha = new FloatValueBox(0, _cRed.X, _cBlue.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f);
_cAlpha = new FloatValueBox(0, _cRed.X, _cBlue.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f)
{
Parent = this
};
_cAlpha.ValueChanged += OnRGBAChanged;
_cAlpha.Parent = this;
// Hue
_cHue = new FloatValueBox(0, PickerMargin + HSVMargin + ChannelTextWidth, _cSelector.Bottom + PickerMargin, 100, 0, 360);
_cHue = new FloatValueBox(0, PickerMargin + HSVMargin + ChannelTextWidth, _cSelector.Bottom + PickerMargin, 100, 0, 360)
{
Parent = this
};
_cHue.ValueChanged += OnHSVChanged;
_cHue.Parent = this;
// Saturation
_cSaturation = new FloatValueBox(0, _cHue.X, _cHue.Bottom + ChannelsMargin, _cHue.Width, 0, 100.0f, 0.1f);
_cSaturation = new FloatValueBox(0, _cHue.X, _cHue.Bottom + ChannelsMargin, _cHue.Width, 0, 100.0f, 0.1f)
{
Parent = this
};
_cSaturation.ValueChanged += OnHSVChanged;
_cSaturation.Parent = this;
// Value
_cValue = new FloatValueBox(0, _cHue.X, _cSaturation.Bottom + ChannelsMargin, _cHue.Width, 0, float.MaxValue, 0.1f);
_cValue = new FloatValueBox(0, _cHue.X, _cSaturation.Bottom + ChannelsMargin, _cHue.Width, 0, float.MaxValue, 0.1f)
{
Parent = this
};
_cValue.ValueChanged += OnHSVChanged;
_cValue.Parent = this;
// Set valid dialog size based on UI content
_dialogSize = Size = new Vector2(_cRed.Right + PickerMargin, 300);
// Hex
const float hexTextBoxWidth = 80;
_cHex = new TextBox(false, Width - hexTextBoxWidth - PickerMargin, _cSelector.Bottom + PickerMargin, hexTextBoxWidth);
_cHex.Parent = this;
_cHex = new TextBox(false, Width - hexTextBoxWidth - PickerMargin, _cSelector.Bottom + PickerMargin, hexTextBoxWidth)
{
Parent = this
};
_cHex.EditEnd += OnHexChanged;
// Cancel
@@ -233,8 +251,7 @@ namespace FlaxEditor.GUI.Dialogs
if (_disableEvents)
return;
Color color;
if (Color.TryParseHex(_cHex.Text, out color))
if (Color.TryParseHex(_cHex.Text, out Color color))
SelectedColor = color;
}

View File

@@ -597,8 +597,10 @@ namespace FlaxEditor.GUI.Docking
if (_tabsProxy == null)
{
// Create proxy and make set simple full dock
_tabsProxy = new DockPanelProxy(this);
_tabsProxy.Parent = this;
_tabsProxy = new DockPanelProxy(this)
{
Parent = this
};
_tabsProxy.UnlockChildrenRecursive();
}
}

View File

@@ -402,8 +402,7 @@ namespace FlaxEditor.GUI.Docking
else if (MouseDownWindow != null && _panel.TabsCount > 1)
{
// Check if mouse left current tab rect
Rectangle currWinRect;
GetTabRect(MouseDownWindow, out currWinRect);
GetTabRect(MouseDownWindow, out Rectangle currWinRect);
if (!currWinRect.Contains(location))
{
int index = _panel.GetTabIndex(MouseDownWindow);
@@ -496,8 +495,10 @@ namespace FlaxEditor.GUI.Docking
private void ShowContextMenu(DockWindow tab, ref Vector2 location)
{
var menu = new ContextMenu.ContextMenu();
menu.Tag = tab;
var menu = new ContextMenu.ContextMenu
{
Tag = tab
};
tab.OnShowContextMenu(menu);
menu.AddButton("Close", OnTabMenuCloseClicked);
menu.AddButton("Close All", OnTabMenuCloseAllClicked);

View File

@@ -134,7 +134,7 @@ namespace FlaxEditor.GUI.Docking
});
// Link to the master panel
_masterPanel?.linkWindow(this);
_masterPanel?.LinkWindow(this);
}
/// <summary>
@@ -409,7 +409,7 @@ namespace FlaxEditor.GUI.Docking
Undock();
// Unlink from the master panel
_masterPanel?.unlinkWindow(this);
_masterPanel?.UnlinkWindow(this);
base.OnDestroy();
}

View File

@@ -97,13 +97,13 @@ namespace FlaxEditor.GUI.Docking
return base.HitTest(ref position);
}
internal void linkWindow(DockWindow window)
internal void LinkWindow(DockWindow window)
{
// Add to the windows list
Windows.Add(window);
}
internal void unlinkWindow(DockWindow window)
internal void UnlinkWindow(DockWindow window)
{
// Call event to the window
window.OnUnlinkInternal();

View File

@@ -112,8 +112,7 @@ namespace FlaxEditor.GUI.Drag
for (int i = 0; i < ids.Length; i++)
{
// Find element
Guid id;
if (Guid.TryParse(ids[i], out id))
if (Guid.TryParse(ids[i], out Guid id))
{
var obj = Editor.Instance.Scene.GetActorNode(id);

View File

@@ -98,8 +98,7 @@ namespace FlaxEditor.GUI.Drag
for (int i = 0; i < ids.Length; i++)
{
// Find element
Guid id;
if (Guid.TryParse(ids[i], out id))
if (Guid.TryParse(ids[i], out Guid id))
{
var obj = FlaxEngine.Object.Find<Script>(ref id);
@@ -129,8 +128,7 @@ namespace FlaxEditor.GUI.Drag
for (int i = 0; i < ids.Length; i++)
{
// Find element
Guid id;
if (Guid.TryParse(ids[i], out id))
if (Guid.TryParse(ids[i], out Guid id))
{
var obj = FlaxEngine.Object.Find<Script>(ref id);

View File

@@ -117,8 +117,7 @@ namespace FlaxEditor.GUI.Input
protected override void TryGetValue()
{
// Try to parse long
long value;
if (long.TryParse(Text, out value))
if (long.TryParse(Text, out long value))
{
// Set value
Value = value;

View File

@@ -250,6 +250,7 @@ namespace FlaxEditor.GUI
{
if (b == null && control is MainMenuButton)
b = (MainMenuButton)control;
if (control is MainMenuButton && control.Right > b.Right)
b = (MainMenuButton)control;
}

View File

@@ -41,13 +41,19 @@ namespace FlaxEditor.GUI
// Buttons
float buttonsWidth = (width - 6.0f) * 0.5f;
float buttonsHeight = 20.0f;
var revertAll = new Button(2.0f, 2.0f, buttonsWidth, buttonsHeight);
revertAll.Text = "Revert All";
revertAll.Parent = this;
var revertAll = new Button(2.0f, 2.0f, buttonsWidth, buttonsHeight)
{
Text = "Revert All",
Parent = this
};
revertAll.Clicked += OnRevertAllClicked;
var applyAll = new Button(revertAll.Right + 2.0f, 2.0f, buttonsWidth, buttonsHeight);
applyAll.Text = "Apply All";
applyAll.Parent = this;
var applyAll = new Button(revertAll.Right + 2.0f, 2.0f, buttonsWidth, buttonsHeight)
{
Text = "Apply All",
Parent = this
};
applyAll.Clicked += OnApplyAllClicked;
// Actual panel
@@ -56,6 +62,7 @@ namespace FlaxEditor.GUI
Bounds = new Rectangle(0, applyAll.Bottom + 2.0f, Width, Height - applyAll.Bottom - 2.0f),
Parent = this
};
Tree = new Tree.Tree
{
AnchorPreset = AnchorPresets.HorizontalStretchTop,

View File

@@ -96,17 +96,17 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// <param name="req">The request data.</param>
public void OnThumbnailRenderingBegin(SceneRenderTask task, GPUContext context, ref CameraCutThumbnailRenderer.Request req)
{
var view = new RenderView();
RenderView view = new RenderView();
var track = (CameraCutTrack)Track;
var cam = track.Camera;
Camera cam = track.Camera;
var viewport = new FlaxEngine.Viewport(Vector2.Zero, task.Buffers.Size);
var orientation = Quaternion.Identity;
Quaternion orientation = Quaternion.Identity;
view.Near = 10.0f;
view.Far = 20000.0f;
var usePerspective = true;
var orthoScale = 1.0f;
var fov = 60.0f;
var customAspectRatio = 0.0f;
bool usePerspective = true;
float orthoScale = 1.0f;
float fov = 60.0f;
float customAspectRatio = 0.0f;
// Try to evaluate camera properties based on the initial camera state
if (cam)
@@ -122,7 +122,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
}
// Try to evaluate camera properties based on the animated tracks
var time = req.ThumbnailIndex == 0 ? Start : Start + Duration;
float time = req.ThumbnailIndex == 0 ? Start : Start + Duration;
foreach (var subTrack in track.SubTracks)
{
if (subTrack is MemberTrack memberTrack)
@@ -133,18 +133,25 @@ namespace FlaxEditor.GUI.Timeline.Tracks
// TODO: try to make it better
if (memberTrack.MemberName == "Position" && value is Vector3 asPosition)
view.Position = asPosition;
else if (memberTrack.MemberName == "Orientation" && value is Quaternion asRotation)
orientation = asRotation;
else if (memberTrack.MemberName == "NearPlane" && value is float asNearPlane)
view.Near = asNearPlane;
else if (memberTrack.MemberName == "FarPlane" && value is float asFarPlane)
view.Far = asFarPlane;
else if (memberTrack.MemberName == "UsePerspective" && value is bool asUsePerspective)
usePerspective = asUsePerspective;
else if (memberTrack.MemberName == "FieldOfView" && value is float asFieldOfView)
fov = asFieldOfView;
else if (memberTrack.MemberName == "CustomAspectRatio" && value is float asCustomAspectRatio)
customAspectRatio = asCustomAspectRatio;
else if (memberTrack.MemberName == "OrthographicScale" && value is float asOrthographicScale)
orthoScale = asOrthographicScale;
}
@@ -162,6 +169,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
{
view.Projection = Matrix.Ortho(viewport.Width * orthoScale, viewport.Height * orthoScale, view.Near, view.Far);
}
Vector3 target = view.Position + view.Direction;
var up = Vector3.Transform(Vector3.Up, orientation);
view.View = Matrix.LookAt(view.Position, target, up);
@@ -186,19 +194,23 @@ namespace FlaxEditor.GUI.Timeline.Tracks
if (image == null)
{
if (req.ThumbnailIndex == 0)
{
image = new Image
{
AnchorPreset = AnchorPresets.MiddleLeft,
Parent = this,
Bounds = new Rectangle(2, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
};
}
else
{
image = new Image
{
AnchorPreset = AnchorPresets.MiddleRight,
Parent = this,
Bounds = new Rectangle(Width - 2 - CameraCutThumbnailRenderer.Width, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
};
}
image.UnlockChildrenRecursive();
_thumbnails[req.ThumbnailIndex] = image;
UpdateUI();

View File

@@ -72,8 +72,11 @@ namespace FlaxEditor.GUI.Timeline.Tracks
{
var time = stream.ReadSingle();
var key = new EventKey();
key.Parameters = new object[paramsCount];
var key = new EventKey
{
Parameters = new object[paramsCount]
};
for (int j = 0; j < paramsCount; j++)
{
stream.Read(dataBuffer, 0, e.EventParamsSizes[j]);
@@ -316,8 +319,11 @@ namespace FlaxEditor.GUI.Timeline.Tracks
}
// Build default value
var defaultValue = new EventKey();
defaultValue.Parameters = new object[EventParamsTypes.Length];
var defaultValue = new EventKey
{
Parameters = new object[EventParamsTypes.Length]
};
for (int i = 0; i < EventParamsTypes.Length; i++)
defaultValue.Parameters[i] = Activator.CreateInstance(EventParamsTypes[i]);
Events.DefaultValue = defaultValue;

View File

@@ -68,7 +68,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
var e = (ParticleEmitterTrack)track;
Guid id = new Guid(stream.ReadBytes(16));
e.Asset = FlaxEngine.Content.LoadAsync<ParticleEmitter>(id);
var emitterIndex = stream.ReadInt32();
stream.ReadInt32(); // Skip emitterIndex
var m = e.TrackMedia;
m.StartFrame = stream.ReadInt32();
m.DurationFrames = stream.ReadInt32();

View File

@@ -297,7 +297,7 @@ namespace FlaxEditor.GUI.Tree
}
}
private void walkSelectExpandedTree(List<TreeNode> selection, TreeNode node)
private void WalkSelectExpandedTree(List<TreeNode> selection, TreeNode node)
{
for (int i = 0; i < node.ChildrenCount; i++)
{
@@ -305,7 +305,7 @@ namespace FlaxEditor.GUI.Tree
{
selection.Add(child);
if (child.IsExpanded)
walkSelectExpandedTree(selection, child);
WalkSelectExpandedTree(selection, child);
}
}
}
@@ -322,7 +322,7 @@ namespace FlaxEditor.GUI.Tree
// Update selection
Selection.Clear();
walkSelectExpandedTree(Selection, _children[0] as TreeNode);
WalkSelectExpandedTree(Selection, _children[0] as TreeNode);
// Check if changed
if (Selection.Count != prev.Count || !Selection.SequenceEqual(prev))

View File

@@ -29,7 +29,6 @@ namespace FlaxEditor.Gizmo
private bool IntersectsRotateCircle(Vector3 normal, ref Ray ray, out float distance)
{
distance = float.MaxValue;
var plane = new Plane(Vector3.Zero, normal);
if (!plane.Intersects(ref ray, out distance))
@@ -47,8 +46,7 @@ namespace FlaxEditor.Gizmo
// Transform ray into local space of the gizmo
Ray localRay;
Matrix invGizmoWorld;
Matrix.Invert(ref _gizmoWorld, out invGizmoWorld);
Matrix.Invert(ref _gizmoWorld, out Matrix invGizmoWorld);
Vector3.TransformNormal(ref ray.Direction, ref invGizmoWorld, out localRay.Direction);
Vector3.Transform(ref ray.Position, ref invGizmoWorld, out localRay.Position);
@@ -66,11 +64,13 @@ namespace FlaxEditor.Gizmo
_activeAxis = Axis.X;
closestintersection = intersection;
}
if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Y;
closestintersection = intersection;
}
if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Z;
@@ -85,6 +85,7 @@ namespace FlaxEditor.Gizmo
_activeAxis = Axis.XY;
closestintersection = intersection;
}
if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestintersection)
{
_activeAxis = Axis.ZX;

View File

@@ -157,9 +157,8 @@ namespace FlaxEditor.Gizmo
_screenScale = vLength.Length / GizmoScaleFactor * gizmoSize;
Matrix.Scaling(_screenScale, out _screenScaleMatrix);
Matrix rotation;
Quaternion orientation = GetSelectedObject(0).Orientation;
Matrix.RotationQuaternion(ref orientation, out rotation);
Matrix.RotationQuaternion(ref orientation, out Matrix rotation);
_localForward = rotation.Forward;
_localUp = rotation.Up;

View File

@@ -124,8 +124,7 @@ namespace FlaxEditor.Modules
/// <param name="skipSettingsDialog">True if skip any popup dialogs showing for import options adjusting. Can be used when importing files from code.</param>
public void Reimport(BinaryAssetItem item, object settings = null, bool skipSettingsDialog = false)
{
string importPath;
if (item != null && !item.GetImportPath(out importPath))
if (item != null && !item.GetImportPath(out string importPath))
{
// Check if input file is missing
if (!System.IO.File.Exists(importPath))

View File

@@ -138,8 +138,11 @@ namespace FlaxEditor.Modules
public void CreateSceneFile(string path)
{
// Create a sample scene
var scene = new Scene();
scene.StaticFlags = StaticFlags.FullyStatic;
var scene = new Scene
{
StaticFlags = StaticFlags.FullyStatic
};
//
var sun = scene.AddChild<DirectionalLight>();
sun.Name = "Sun";

View File

@@ -380,8 +380,10 @@ namespace FlaxEditor.Modules
private void InitMainMenu(RootControl mainWindow)
{
MainMenu = new MainMenu(mainWindow);
MainMenu.Parent = mainWindow;
MainMenu = new MainMenu(mainWindow)
{
Parent = mainWindow
};
// File
MenuFile = MainMenu.AddButton("File");

View File

@@ -415,8 +415,7 @@ namespace FlaxEditor.Modules
writer.WriteStartElement("Panel");
float splitterValue;
DockState state = p.TryGetDockState(out splitterValue);
DockState state = p.TryGetDockState(out float splitterValue);
writer.WriteAttributeString("DockState", ((int)state).ToString());
writer.WriteAttributeString("SplitterValue", splitterValue.ToString(CultureInfo.InvariantCulture));
@@ -684,8 +683,7 @@ namespace FlaxEditor.Modules
}
// Check if it's an asset ID
Guid id;
if (Guid.TryParse(typename, out id))
if (Guid.TryParse(typename, out Guid id))
{
var el = Editor.ContentDatabase.Find(id);
if (el != null)

View File

@@ -21,9 +21,11 @@ namespace FlaxEditor.Options
// Reset options button
layout.Space(30);
var panel = layout.Space(30);
var resetButton = new Button(4, 4, 100);
resetButton.Text = "Reset";
resetButton.Parent = panel.ContainerControl;
var resetButton = new Button(4, 4, 100)
{
Text = "Reset",
Parent = panel.ContainerControl
};
resetButton.Clicked += OnResetButtonClicked;
}

View File

@@ -212,46 +212,47 @@ namespace FlaxEditor.Options
/// <returns>The style object.</returns>
public Style CreateDefaultStyle()
{
var style = new Style();
// Metro Style colors
style.Background = Color.FromBgra(0xFF1C1C1C);
style.LightBackground = Color.FromBgra(0xFF2D2D30);
style.Foreground = Color.FromBgra(0xFFFFFFFF);
style.ForegroundGrey = Color.FromBgra(0xFFA9A9B3);
style.ForegroundDisabled = Color.FromBgra(0xFF787883);
style.BackgroundHighlighted = Color.FromBgra(0xFF54545C);
style.BorderHighlighted = Color.FromBgra(0xFF6A6A75);
style.BackgroundSelected = Color.FromBgra(0xFF007ACC);
style.BorderSelected = Color.FromBgra(0xFF1C97EA);
style.BackgroundNormal = Color.FromBgra(0xFF3F3F46);
style.BorderNormal = Color.FromBgra(0xFF54545C);
style.TextBoxBackground = Color.FromBgra(0xFF333337);
style.TextBoxBackgroundSelected = Color.FromBgra(0xFF3F3F46);
style.DragWindow = style.BackgroundSelected * 0.7f;
style.ProgressNormal = Color.FromBgra(0xFF0ad328);
// Fonts
var options = Options;
style.FontTitle = options.Interface.TitleFont.GetFont();
style.FontLarge = options.Interface.LargeFont.GetFont();
style.FontMedium = options.Interface.MediumFont.GetFont();
style.FontSmall = options.Interface.SmallFont.GetFont();
var style = new Style
{
Background = Color.FromBgra(0xFF1C1C1C),
LightBackground = Color.FromBgra(0xFF2D2D30),
Foreground = Color.FromBgra(0xFFFFFFFF),
ForegroundGrey = Color.FromBgra(0xFFA9A9B3),
ForegroundDisabled = Color.FromBgra(0xFF787883),
BackgroundHighlighted = Color.FromBgra(0xFF54545C),
BorderHighlighted = Color.FromBgra(0xFF6A6A75),
BackgroundSelected = Color.FromBgra(0xFF007ACC),
BorderSelected = Color.FromBgra(0xFF1C97EA),
BackgroundNormal = Color.FromBgra(0xFF3F3F46),
BorderNormal = Color.FromBgra(0xFF54545C),
TextBoxBackground = Color.FromBgra(0xFF333337),
TextBoxBackgroundSelected = Color.FromBgra(0xFF3F3F46),
ProgressNormal = Color.FromBgra(0xFF0ad328),
// Icons
style.ArrowDown = Editor.Icons.ArrowDown12;
style.ArrowRight = Editor.Icons.ArrowRight12;
style.Search = Editor.Icons.Search12;
style.Settings = Editor.Icons.Settings12;
style.Cross = Editor.Icons.Cross12;
style.CheckBoxIntermediate = Editor.Icons.CheckBoxIntermediate12;
style.CheckBoxTick = Editor.Icons.CheckBoxTick12;
style.StatusBarSizeGrip = Editor.Icons.StatusBarSizeGrip12;
style.Translate = Editor.Icons.Translate16;
style.Rotate = Editor.Icons.Rotate16;
style.Scale = Editor.Icons.Scale16;
// Fonts
FontTitle = options.Interface.TitleFont.GetFont(),
FontLarge = options.Interface.LargeFont.GetFont(),
FontMedium = options.Interface.MediumFont.GetFont(),
FontSmall = options.Interface.SmallFont.GetFont(),
style.SharedTooltip = new Tooltip();
// Icons
ArrowDown = Editor.Icons.ArrowDown12,
ArrowRight = Editor.Icons.ArrowRight12,
Search = Editor.Icons.Search12,
Settings = Editor.Icons.Settings12,
Cross = Editor.Icons.Cross12,
CheckBoxIntermediate = Editor.Icons.CheckBoxIntermediate12,
CheckBoxTick = Editor.Icons.CheckBoxTick12,
StatusBarSizeGrip = Editor.Icons.StatusBarSizeGrip12,
Translate = Editor.Icons.Translate16,
Rotate = Editor.Icons.Rotate16,
Scale = Editor.Icons.Scale16,
SharedTooltip = new Tooltip()
};
style.DragWindow = style.BackgroundSelected * 0.7f;
return style;
}

View File

@@ -125,9 +125,8 @@ namespace FlaxEditor.SceneGraph.GUI
}
else
{
QueryFilterHelper.Range[] ranges;
var text = Text;
if (QueryFilterHelper.Match(filterText, text, out ranges))
if (QueryFilterHelper.Match(filterText, text, out QueryFilterHelper.Range[] ranges))
{
// Update highlights
if (_highlights == null)
@@ -386,15 +385,14 @@ namespace FlaxEditor.SceneGraph.GUI
public ReparentAction(List<Actor> actors)
{
var allActors = new List<Actor>();
allActors.Capacity = Mathf.NextPowerOfTwo(actors.Count);
var allActors = new List<Actor>(Mathf.NextPowerOfTwo(actors.Count));
for (int i = 0; i < actors.Count; i++)
{
GetAllActors(allActors, actors[i]);
}
var allScripts = new List<Script>();
allScripts.Capacity = allActors.Capacity;
var allScripts = new List<Script>(allActors.Capacity);
GetAllScripts(allActors, allScripts);
int allCount = allActors.Count + allScripts.Count;
@@ -409,6 +407,7 @@ namespace FlaxEditor.SceneGraph.GUI
_prefabIds[i] = allActors[i].PrefabID;
_prefabObjectIds[i] = allActors[i].PrefabObjectID;
}
for (int i = 0; i < allScripts.Count; i++)
{
int j = _actorsCount + i;
@@ -570,11 +569,14 @@ namespace FlaxEditor.SceneGraph.GUI
{
// Create actor
var model = FlaxEngine.Content.LoadAsync<SkinnedModel>(assetItem.ID);
var actor = new AnimatedModel();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.SkinnedModel = model;
actor.Transform = Actor.Transform;
var actor = new AnimatedModel
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
SkinnedModel = model,
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -583,11 +585,14 @@ namespace FlaxEditor.SceneGraph.GUI
{
// Create actor
var model = FlaxEngine.Content.LoadAsync<Model>(assetItem.ID);
var actor = new StaticModel();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.Model = model;
actor.Transform = Actor.Transform;
var actor = new StaticModel
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
Model = model,
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -595,11 +600,13 @@ namespace FlaxEditor.SceneGraph.GUI
else if (assetItem.IsOfType<CollisionData>())
{
// Create actor
var actor = new MeshCollider();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.CollisionData = FlaxEngine.Content.LoadAsync<CollisionData>(assetItem.ID);
actor.Transform = Actor.Transform;
var actor = new MeshCollider
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
CollisionData = FlaxEngine.Content.LoadAsync<CollisionData>(assetItem.ID),
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -607,11 +614,13 @@ namespace FlaxEditor.SceneGraph.GUI
else if (assetItem.IsOfType<ParticleSystem>())
{
// Create actor
var actor = new ParticleEffect();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.ParticleSystem = FlaxEngine.Content.LoadAsync<ParticleSystem>(assetItem.ID);
actor.Transform = Actor.Transform;
var actor = new ParticleEffect
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
ParticleSystem = FlaxEngine.Content.LoadAsync<ParticleSystem>(assetItem.ID),
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -619,11 +628,13 @@ namespace FlaxEditor.SceneGraph.GUI
else if (assetItem.IsOfType<SceneAnimation>())
{
// Create actor
var actor = new SceneAnimationPlayer();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.Animation = FlaxEngine.Content.LoadAsync<SceneAnimation>(assetItem.ID);
actor.Transform = Actor.Transform;
var actor = new SceneAnimationPlayer
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
Animation = FlaxEngine.Content.LoadAsync<SceneAnimation>(assetItem.ID),
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -631,11 +642,13 @@ namespace FlaxEditor.SceneGraph.GUI
else if (assetItem.IsOfType<AudioClip>())
{
// Create actor
var actor = new AudioSource();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.Clip = FlaxEngine.Content.LoadAsync<AudioClip>(assetItem.ID);
actor.Transform = Actor.Transform;
var actor = new AudioSource
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
Clip = FlaxEngine.Content.LoadAsync<AudioClip>(assetItem.ID),
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -728,20 +741,28 @@ namespace FlaxEditor.SceneGraph.GUI
{
if (assetItem.IsOfType<SkinnedModel>())
return true;
if (assetItem.IsOfType<Model>())
return true;
if (assetItem.IsOfType<AudioClip>())
return true;
if (assetItem.IsOfType<Prefab>())
return true;
if (assetItem.IsOfType<CollisionData>())
return true;
if (assetItem.IsOfType<ParticleSystem>())
return true;
if (assetItem.IsOfType<SceneAnimation>())
return true;
if (assetItem is VisualScriptItem visualScriptItem && new ScriptType(typeof(Actor)).IsAssignableFrom(visualScriptItem.ScriptType) && visualScriptItem.ScriptType.CanCreateInstance)
return true;
return false;
}

View File

@@ -82,8 +82,7 @@ namespace FlaxEditor.SceneGraph
if (id == Guid.Empty)
return null;
SceneGraphNode result;
Nodes.TryGetValue(id, out result);
Nodes.TryGetValue(id, out SceneGraphNode result);
return result;
}
@@ -94,8 +93,7 @@ namespace FlaxEditor.SceneGraph
/// <returns>The result node.</returns>
public static SceneGraphNode GetNode(Guid id)
{
SceneGraphNode result;
Nodes.TryGetValue(id, out result);
Nodes.TryGetValue(id, out SceneGraphNode result);
if (result == null)
{
var actor = Object.TryFind<Actor>(ref id);

View File

@@ -396,34 +396,45 @@ namespace FlaxEditor.Surface.Archetypes
{
var layoutOffsetY = FlaxEditor.Surface.Constants.LayoutOffsetY;
_selectedAnimationLabel = new Label(300, 3 * layoutOffsetY, 120.0f, layoutOffsetY);
_selectedAnimationLabel.HorizontalAlignment = TextAlignment.Near;
_selectedAnimationLabel.Text = "Selected Animation:";
_selectedAnimationLabel.Parent = this;
_selectedAnimationLabel = new Label(300, 3 * layoutOffsetY, 120.0f, layoutOffsetY)
{
HorizontalAlignment = TextAlignment.Near,
Text = "Selected Animation:",
Parent = this
};
_selectedAnimation = new ComboBox(_selectedAnimationLabel.X, 4 * layoutOffsetY, _selectedAnimationLabel.Width)
{
Parent = this
};
_selectedAnimation = new ComboBox(_selectedAnimationLabel.X, 4 * layoutOffsetY, _selectedAnimationLabel.Width);
_selectedAnimation.PopupShowing += OnSelectedAnimationPopupShowing;
_selectedAnimation.SelectedIndexChanged += OnSelectedAnimationChanged;
_selectedAnimation.Parent = this;
var items = new List<string>(MaxAnimationsCount);
while (items.Count < MaxAnimationsCount)
items.Add(string.Empty);
_selectedAnimation.Items = items;
_animationPicker = new AssetPicker(new ScriptType(typeof(FlaxEngine.Animation)), new Vector2(_selectedAnimation.Left, _selectedAnimation.Bottom + 4));
_animationPicker = new AssetPicker(new ScriptType(typeof(FlaxEngine.Animation)), new Vector2(_selectedAnimation.Left, _selectedAnimation.Bottom + 4))
{
Parent = this
};
_animationPicker.SelectedItemChanged += OnAnimationPickerItemChanged;
_animationPicker.Parent = this;
_animationSpeedLabel = new Label(_animationPicker.Left, _animationPicker.Bottom + 4, 40, TextBox.DefaultHeight);
_animationSpeedLabel.HorizontalAlignment = TextAlignment.Near;
_animationSpeedLabel.Text = "Speed:";
_animationSpeedLabel.Parent = this;
_animationSpeedLabel = new Label(_animationPicker.Left, _animationPicker.Bottom + 4, 40, TextBox.DefaultHeight)
{
HorizontalAlignment = TextAlignment.Near,
Text = "Speed:",
Parent = this
};
_animationSpeed = new FloatValueBox(1.0f, _animationSpeedLabel.Right + 4, _animationSpeedLabel.Y, _selectedAnimation.Right - _animationSpeedLabel.Right - 4);
_animationSpeed.SlideSpeed = 0.01f;
_animationSpeed = new FloatValueBox(1.0f, _animationSpeedLabel.Right + 4, _animationSpeedLabel.Y, _selectedAnimation.Right - _animationSpeedLabel.Right - 4)
{
SlideSpeed = 0.01f,
Parent = this
};
_animationSpeed.ValueChanged += OnAnimationSpeedValueChanged;
_animationSpeed.Parent = this;
}
private void OnSelectedAnimationPopupShowing(ComboBox comboBox)
@@ -619,15 +630,19 @@ namespace FlaxEditor.Surface.Archetypes
public MultiBlend1D(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
{
_animationXLabel = new Label(_animationSpeedLabel.Left, _animationSpeedLabel.Bottom + 4, 40, TextBox.DefaultHeight);
_animationXLabel.HorizontalAlignment = TextAlignment.Near;
_animationXLabel.Text = "X:";
_animationXLabel.Parent = this;
_animationXLabel = new Label(_animationSpeedLabel.Left, _animationSpeedLabel.Bottom + 4, 40, TextBoxBase.DefaultHeight)
{
HorizontalAlignment = TextAlignment.Near,
Text = "X:",
Parent = this
};
_animationX = new FloatValueBox(0.0f, _animationXLabel.Right + 4, _animationXLabel.Y, _selectedAnimation.Right - _animationXLabel.Right - 4);
_animationX.SlideSpeed = 0.01f;
_animationX = new FloatValueBox(0.0f, _animationXLabel.Right + 4, _animationXLabel.Y, _selectedAnimation.Right - _animationXLabel.Right - 4)
{
SlideSpeed = 0.01f,
Parent = this
};
_animationX.ValueChanged += OnAnimationXChanged;
_animationX.Parent = this;
_editor = new Editor(this,
FlaxEditor.Surface.Constants.NodeMarginX,
@@ -745,25 +760,33 @@ namespace FlaxEditor.Surface.Archetypes
public MultiBlend2D(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
{
_animationXLabel = new Label(_animationSpeedLabel.Left, _animationSpeedLabel.Bottom + 4, 40, TextBox.DefaultHeight);
_animationXLabel.HorizontalAlignment = TextAlignment.Near;
_animationXLabel.Text = "X:";
_animationXLabel.Parent = this;
_animationXLabel = new Label(_animationSpeedLabel.Left, _animationSpeedLabel.Bottom + 4, 40, TextBox.DefaultHeight)
{
HorizontalAlignment = TextAlignment.Near,
Text = "X:",
Parent = this
};
_animationX = new FloatValueBox(0.0f, _animationXLabel.Right + 4, _animationXLabel.Y, _selectedAnimation.Right - _animationXLabel.Right - 4);
_animationX.SlideSpeed = 0.01f;
_animationX = new FloatValueBox(0.0f, _animationXLabel.Right + 4, _animationXLabel.Y, _selectedAnimation.Right - _animationXLabel.Right - 4)
{
SlideSpeed = 0.01f,
Parent = this
};
_animationX.ValueChanged += OnAnimationXChanged;
_animationX.Parent = this;
_animationYLabel = new Label(_animationXLabel.Left, _animationXLabel.Bottom + 4, 40, TextBox.DefaultHeight);
_animationYLabel.HorizontalAlignment = TextAlignment.Near;
_animationYLabel.Text = "Y:";
_animationYLabel.Parent = this;
_animationYLabel = new Label(_animationXLabel.Left, _animationXLabel.Bottom + 4, 40, TextBox.DefaultHeight)
{
HorizontalAlignment = TextAlignment.Near,
Text = "Y:",
Parent = this
};
_animationY = new FloatValueBox(0.0f, _animationYLabel.Right + 4, _animationYLabel.Y, _selectedAnimation.Right - _animationYLabel.Right - 4);
_animationY.SlideSpeed = 0.01f;
_animationY = new FloatValueBox(0.0f, _animationYLabel.Right + 4, _animationYLabel.Y, _selectedAnimation.Right - _animationYLabel.Right - 4)
{
SlideSpeed = 0.01f,
Parent = this
};
_animationY.ValueChanged += OnAnimationYChanged;
_animationY.Parent = this;
_editor = new Editor(this,
FlaxEditor.Surface.Constants.NodeMarginX,

View File

@@ -81,9 +81,11 @@ namespace FlaxEditor.Surface.Archetypes
var marginX = FlaxEditor.Surface.Constants.NodeMarginX;
var uiStartPosY = FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize;
var editButton = new Button(marginX, uiStartPosY, 246, 20);
editButton.Text = "Edit";
editButton.Parent = this;
var editButton = new Button(marginX, uiStartPosY, 246, 20)
{
Text = "Edit",
Parent = this
};
editButton.Clicked += Edit;
var maxTransitionsPerUpdateLabel = new Label(marginX, editButton.Bottom + 4, 153, TextBox.DefaultHeight)
@@ -253,8 +255,7 @@ namespace FlaxEditor.Surface.Archetypes
private void OnSurfaceLoaded(VisjectSurfaceContext context)
{
// Ensure that loaded surface has entry node for state machine
var entryNode = context.FindNode(9, 19);
if (entryNode == null)
if (context.FindNode(9, 19) == null)
{
var wasEnabled = true;
if (Surface.Undo != null)
@@ -263,7 +264,7 @@ namespace FlaxEditor.Surface.Archetypes
Surface.Undo.Enabled = false;
}
entryNode = context.SpawnNode(9, 19, new Vector2(100.0f));
context.SpawnNode(9, 19, new Vector2(100.0f));
if (Surface.Undo != null)
{
@@ -545,9 +546,11 @@ namespace FlaxEditor.Surface.Archetypes
private void Add()
{
var context = _context.Get(_surface);
var src = context.FindNode(_srcStateId) as StateMachineState;
if (src == null)
throw new Exception("Missing source state.");
var dst = context.FindNode(_dstStateId) as StateMachineState;
if (dst == null)
throw new Exception("Missing destination state.");
@@ -565,12 +568,13 @@ namespace FlaxEditor.Surface.Archetypes
private void Remove()
{
var context = _context.Get(_surface);
var src = context.FindNode(_srcStateId) as StateMachineState;
if (src == null)
if (!(context.FindNode(_srcStateId) is StateMachineState src))
throw new Exception("Missing source state.");
var dst = context.FindNode(_dstStateId) as StateMachineState;
if (dst == null)
if (!(context.FindNode(_dstStateId) is StateMachineState dst))
throw new Exception("Missing destination state.");
var transition = src.Transitions.Find(x => x.DestinationState == dst);
if (transition == null)
throw new Exception("Missing transition.");
@@ -1308,8 +1312,7 @@ namespace FlaxEditor.Surface.Archetypes
private void OnSurfaceLoaded(VisjectSurfaceContext context)
{
// Ensure that loaded surface has output node for state
var entryNode = context.FindNode(9, 21);
if (entryNode == null)
if (context.FindNode(9, 21) == null)
{
var wasEnabled = true;
if (Surface.Undo != null)
@@ -1318,7 +1321,7 @@ namespace FlaxEditor.Surface.Archetypes
Surface.Undo.Enabled = false;
}
entryNode = context.SpawnNode(9, 21, new Vector2(100.0f));
context.SpawnNode(9, 21, new Vector2(100.0f));
if (Surface.Undo != null)
{
@@ -1676,8 +1679,7 @@ namespace FlaxEditor.Surface.Archetypes
private void OnSurfaceLoaded(VisjectSurfaceContext context)
{
// Ensure that loaded surface has rule output node
var ruleOutputNode = context.FindNode(9, 22);
if (ruleOutputNode == null)
if (context.FindNode(9, 22) == null)
{
var wasEnabled = true;
var undo = SourceState.Surface.Undo;
@@ -1687,7 +1689,7 @@ namespace FlaxEditor.Surface.Archetypes
undo.Enabled = false;
}
ruleOutputNode = context.SpawnNode(9, 22, new Vector2(100.0f));
context.SpawnNode(9, 22, new Vector2(100.0f));
// TODO: add default rule nodes for easier usage

View File

@@ -393,7 +393,7 @@ namespace FlaxEditor.Surface.Archetypes
int count = 0;
if (ExtractNumber(ref filterText, out vec[count]))
{
count = count + 1;
count++;
while (count < 4)
{
if (ExtractComma(ref filterText) && ExtractNumber(ref filterText, out vec[count]))

View File

@@ -766,9 +766,11 @@ namespace FlaxEditor.Surface.Archetypes
private SignatureInfo LoadSignature()
{
var signature = new SignatureInfo();
var data = Values[4] as byte[];
if (data == null || data.Length == 0)
return signature;
if (data[0] == 4)
{
using (var stream = new MemoryStream(data))
@@ -1449,8 +1451,11 @@ namespace FlaxEditor.Surface.Archetypes
private void LoadSignature()
{
_signature = new Signature();
_signature.Node = this;
_signature = new Signature
{
Node = this
};
if (Values[0] is byte[] data && data.Length != 0)
{
using (var stream = new MemoryStream(data))

View File

@@ -816,6 +816,40 @@ namespace FlaxEditor.Surface.Archetypes
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(Vector3), 1),
}
},
new NodeArchetype
{
TypeID = 36,
Title = "HSVToRGB",
Description = "Converts a HSV value to linear RGB [X = 0/360, Y = 0/1, Z = 0/1]",
Flags = NodeFlags.MaterialGraph,
Size = new Vector2(160, 25),
DefaultValues = new object[]
{
new Vector3(240, 1, 1),
},
Elements = new[]
{
NodeElementArchetype.Factory.Input(0, "HSV", true, typeof(Vector3), 0, 0),
NodeElementArchetype.Factory.Output(0, "RGB", typeof(Vector3), 1),
}
},
new NodeArchetype
{
TypeID = 37,
Title = "RGBToHSV",
Description = "Converts a linear RGB value to HSV [X = 0/360, Y = 0/1, Z = 0/1]",
Flags = NodeFlags.MaterialGraph,
Size = new Vector2(160, 25),
DefaultValues = new object[]
{
new Vector3(0, 1, 0),
},
Elements = new[]
{
NodeElementArchetype.Factory.Input(0, "RGB", true, typeof(Vector3), 0, 0),
NodeElementArchetype.Factory.Output(0, "HSV", typeof(Vector3), 1),
}
}
};
}
}

View File

@@ -171,16 +171,22 @@ namespace FlaxEditor.Surface.ContextMenu
// Check if can create group for them
if (nodes.Count > 0)
{
var group = new VisjectCMGroup(this, groupArchetype);
group.HeaderText = groupArchetype.Name;
var group = new VisjectCMGroup(this, groupArchetype)
{
HeaderText = groupArchetype.Name
};
group.Close(false);
for (int i = 0; i < nodes.Count; i++)
{
var item = new VisjectCMItem(group, groupArchetype, nodes[i]);
item.Parent = group;
var item = new VisjectCMItem(group, groupArchetype, nodes[i])
{
Parent = group
};
}
group.SortChildren();
group.Parent = panel2;
_groups.Add(group);
}
}
@@ -209,16 +215,21 @@ namespace FlaxEditor.Surface.ContextMenu
// Create new group if name is unique
if (group == null)
{
group = new VisjectCMGroup(this, info.CustomNodesGroup);
group.HeaderText = groupName;
group = new VisjectCMGroup(this, info.CustomNodesGroup)
{
HeaderText = groupName
};
group.Close(false);
group.Parent = _groupsPanel;
_groups.Add(group);
}
// Add new item
var item = new VisjectCMItem(group, info.CustomNodesGroup, nodeArchetype);
item.Parent = group;
var item = new VisjectCMItem(group, info.CustomNodesGroup, nodeArchetype)
{
Parent = group
};
// Order items
group.SortChildren();
@@ -237,16 +248,23 @@ namespace FlaxEditor.Surface.ContextMenu
{
Profiler.BeginEvent("VisjectCM.AddGroup");
var group = new VisjectCMGroup(this, groupArchetype);
group.HeaderText = groupArchetype.Name;
var group = new VisjectCMGroup(this, groupArchetype)
{
HeaderText = groupArchetype.Name
};
group.Close(false);
foreach (var nodeArchetype in groupArchetype.Archetypes)
{
var item = new VisjectCMItem(group, groupArchetype, nodeArchetype);
item.Parent = group;
var item = new VisjectCMItem(group, groupArchetype, nodeArchetype)
{
Parent = group
};
}
group.SortChildren();
group.Parent = _groupsPanel;
_groups.Add(group);
if (!IsLayoutLocked)
@@ -281,17 +299,24 @@ namespace FlaxEditor.Surface.ContextMenu
var groups = new List<VisjectCMGroup>();
foreach (var groupArchetype in groupArchetypes)
{
var group = new VisjectCMGroup(this, groupArchetype);
group.HeaderText = groupArchetype.Name;
var group = new VisjectCMGroup(this, groupArchetype)
{
HeaderText = groupArchetype.Name
};
group.Close(false);
foreach (var nodeArchetype in groupArchetype.Archetypes)
{
var item = new VisjectCMItem(group, groupArchetype, nodeArchetype);
item.Parent = group;
var item = new VisjectCMItem(group, groupArchetype, nodeArchetype)
{
Parent = group
};
}
group.SortChildren();
group.Parent = _groupsPanel;
_groups.Add(group);
groups.Add(group);
}
Profiler.EndEvent();
@@ -497,8 +522,11 @@ namespace FlaxEditor.Surface.ContextMenu
Archetypes = archetypes
};
var group = new VisjectCMGroup(this, groupArchetype);
group.HeaderText = groupArchetype.Name;
var group = new VisjectCMGroup(this, groupArchetype)
{
HeaderText = groupArchetype.Name
};
group.Close(false);
archetypeIndex = 0;
for (int i = 0; i < parameters.Count; i++)
@@ -507,13 +535,17 @@ namespace FlaxEditor.Surface.ContextMenu
if (!param.IsPublic)
continue;
var item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++]);
item.Parent = group;
var item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++])
{
Parent = group
};
if (_parameterSetNodeArchetype != null)
{
item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++]);
item.Parent = group;
item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++])
{
Parent = group
};
}
}
group.SortChildren();

View File

@@ -305,8 +305,11 @@ namespace FlaxEditor.Surface.Elements
if (HasAnyConnection)
{
// Remove all connections
var toUpdate = new List<Box>(1 + Connections.Count);
toUpdate.Add(this);
var toUpdate = new List<Box>(1 + Connections.Count)
{
this
};
for (int i = 0; i < Connections.Count; i++)
{
var targetBox = Connections[i];

View File

@@ -146,9 +146,10 @@ namespace FlaxEditor.Surface
for (int i = 0; i < entries; i++)
{
Entry e = new Entry();
e.TypeID = stream.ReadInt32();
Entry e = new Entry
{
TypeID = stream.ReadInt32()
};
stream.ReadInt64(); // don't use CreationTime
uint dataSize = stream.ReadUInt32();

View File

@@ -156,7 +156,6 @@ namespace FlaxEditor.Surface
/// <param name="height">The height.</param>
protected void Resize(float width, float height)
{
var prevSize = Size;
Size = CalculateNodeSize(width, height);
// Update boxes on width change
@@ -794,7 +793,7 @@ namespace FlaxEditor.Surface
/// <inheritdoc />
public override bool OnShowTooltip(out string text, out Vector2 location, out Rectangle area)
{
var result = base.OnShowTooltip(out text, out location, out area);
var result = base.OnShowTooltip(out text, out _, out area);
// Change the position
location = new Vector2(_headerRect.Width * 0.5f, _headerRect.Bottom);

View File

@@ -37,8 +37,7 @@ namespace FlaxEditor.Surface
// Push clipping mask
if (ClipChildren)
{
Rectangle clientArea;
GetDesireClientArea(out clientArea);
GetDesireClientArea(out Rectangle clientArea);
Render2D.PushClip(ref clientArea);
}

View File

@@ -76,9 +76,11 @@ namespace FlaxEditor.Surface.Undo
var iB = _input.Get(context);
var oB = _output.Get(context);
var toUpdate = new HashSet<Box>();
toUpdate.Add(iB);
toUpdate.Add(oB);
var toUpdate = new HashSet<Box>
{
iB,
oB
};
toUpdate.AddRange(iB.Connections);
toUpdate.AddRange(oB.Connections);

View File

@@ -54,8 +54,7 @@ namespace FlaxEditor.Surface
return;
// Get or create context
VisjectSurfaceContext surfaceContext;
if (!_contextCache.TryGetValue(context, out surfaceContext))
if (!_contextCache.TryGetValue(context, out VisjectSurfaceContext surfaceContext))
{
surfaceContext = CreateContext(_context, context);
_context?.Children.Add(surfaceContext);
@@ -119,8 +118,7 @@ namespace FlaxEditor.Surface
}
// Check if has context in cache
VisjectSurfaceContext surfaceContext;
if (_contextCache.TryGetValue(context, out surfaceContext))
if (_contextCache.TryGetValue(context, out VisjectSurfaceContext surfaceContext))
{
// Remove from navigation path
while (ContextStack.Contains(surfaceContext))
@@ -149,8 +147,7 @@ namespace FlaxEditor.Surface
return;
// Check if already in a path
VisjectSurfaceContext surfaceContext;
if (_contextCache.TryGetValue(context, out surfaceContext) && ContextStack.Contains(surfaceContext))
if (_contextCache.TryGetValue(context, out VisjectSurfaceContext surfaceContext) && ContextStack.Contains(surfaceContext))
{
// Change stack
do

View File

@@ -743,6 +743,7 @@ namespace FlaxEditor.Surface
{
if (!CanEdit)
return;
var node = control as SurfaceNode;
if (node == null)
{
@@ -750,6 +751,7 @@ namespace FlaxEditor.Surface
MarkAsEdited();
return;
}
if ((node.Archetype.Flags & NodeFlags.NoRemove) != 0)
return;

View File

@@ -577,7 +577,7 @@ namespace FlaxEditor.Surface
// Store node typename in values container
node.Values[0] = typeName;
}
if (node is MissingNode missingNode)
if (node is MissingNode)
{
// Read all values
Array.Resize(ref node.Values, valuesCnt);
@@ -623,7 +623,7 @@ namespace FlaxEditor.Surface
for (int j = 0; j < boxesCount; j++)
{
var id = stream.ReadByte();
uint type = stream.ReadUInt32();
stream.ReadUInt32(); // Skip type
ushort connectionsCnt = stream.ReadUInt16();
ConnectionHint hint;
@@ -749,7 +749,7 @@ namespace FlaxEditor.Surface
// Store node typename in values container
node.Values[0] = typeName;
}
if (node is MissingNode missingNode)
if (node is MissingNode)
{
// Read all values
Array.Resize(ref node.Values, valuesCnt);
@@ -769,7 +769,7 @@ namespace FlaxEditor.Surface
{
Editor.LogWarning(string.Format("Invalid node values. Loaded: {0}, expected: {1}. Type: {2}, {3}", valuesCnt, nodeValuesCnt, node.Archetype.Title, node.Archetype.TypeID));
object dummy = null;
object dummy;
for (int j = firstValueReadIdx; j < valuesCnt; j++)
{
dummy = stream.ReadVariant();
@@ -789,7 +789,7 @@ namespace FlaxEditor.Surface
for (int j = 0; j < boxesCount; j++)
{
var id = stream.ReadByte();
var type = stream.ReadVariantType();
stream.ReadVariantType(); // Skip type
var connectionsCnt = stream.ReadUInt16();
ConnectionHint hint;

View File

@@ -980,10 +980,10 @@ namespace FlaxEditor.Surface
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split1"), out value1))
if (float.TryParse(node.GetAttribute("Split1"), out float value1))
_split1.SplitterValue = value1;
if (float.TryParse(node.GetAttribute("Split2"), out value1))
_split2.SplitterValue = value1;
}

View File

@@ -56,8 +56,10 @@ namespace FlaxEditor.Tools.Foliage
if (!_staticModel)
{
_staticModel = new StaticModel();
_staticModel.StaticFlags = StaticFlags.None;
_staticModel = new StaticModel
{
StaticFlags = StaticFlags.None
};
}
_staticModel.Model = model;

View File

@@ -179,9 +179,11 @@ namespace FlaxEditor.Tools.Foliage
private void OnCreateNewFoliageClicked()
{
// Create
var actor = new FlaxEngine.Foliage();
actor.StaticFlags = StaticFlags.FullyStatic;
actor.Name = "Foliage";
var actor = new FlaxEngine.Foliage
{
StaticFlags = StaticFlags.FullyStatic,
Name = "Foliage"
};
// Spawn and select
Editor.SceneEditing.Spawn(actor);

View File

@@ -282,8 +282,7 @@ namespace FlaxEditor.Tools.Foliage
};
// Try restore painting with the given model ID
bool itemChecked;
if (!Tab.FoliageTypeModelIdsToPaint.TryGetValue(model.ID, out itemChecked))
if (!Tab.FoliageTypeModelIdsToPaint.TryGetValue(model.ID, out bool itemChecked))
{
// Enable by default
itemChecked = true;

View File

@@ -179,8 +179,10 @@ namespace FlaxEditor.Tools.Terrain
// Start async work
_terrain = terrain;
var thread = new System.Threading.Thread(Generate);
thread.Name = "Terrain Generator";
var thread = new System.Threading.Thread(Generate)
{
Name = "Terrain Generator"
};
thread.Start();
}

View File

@@ -310,10 +310,9 @@ namespace FlaxEditor.Tools.Terrain
throw new InvalidOperationException("Cannot set cursor then no terrain is selected.");
var brushBounds = CursorBrushBounds;
var patchesCount = terrain.PatchesCount;
BoundingBox tmp;
for (int patchIndex = 0; patchIndex < patchesCount; patchIndex++)
{
terrain.GetPatchBounds(patchIndex, out tmp);
terrain.GetPatchBounds(patchIndex, out BoundingBox tmp);
if (!tmp.Intersects(ref brushBounds))
continue;

View File

@@ -329,10 +329,9 @@ namespace FlaxEditor.Tools.Terrain
throw new InvalidOperationException("Cannot set cursor then no terrain is selected.");
var brushBounds = CursorBrushBounds;
var patchesCount = terrain.PatchesCount;
BoundingBox tmp;
for (int patchIndex = 0; patchIndex < patchesCount; patchIndex++)
{
terrain.GetPatchBounds(patchIndex, out tmp);
terrain.GetPatchBounds(patchIndex, out BoundingBox tmp);
if (!tmp.Intersects(ref brushBounds))
continue;

View File

@@ -85,7 +85,7 @@ namespace FlaxEditor.Utilities
while (bytes >= 1024 && order < MemorySizePostfixes.Length - 1)
{
order++;
bytes = bytes / 1024;
bytes /= 1024;
}
return string.Format("{0:0.##} {1}", bytes, MemorySizePostfixes[order]);
@@ -102,7 +102,7 @@ namespace FlaxEditor.Utilities
while (bytes >= 1024 && order < MemorySizePostfixes.Length - 1)
{
order++;
bytes = bytes / 1024;
bytes /= 1024;
}
return string.Format("{0:0.##} {1}", bytes, MemorySizePostfixes[order]);
@@ -1694,8 +1694,7 @@ namespace FlaxEditor.Utilities
orientation = Quaternion.LookRotation(dir, Vector3.Cross(Vector3.Cross(dir, Vector3.Up), dir));
Vector3 up = Vector3.Up * orientation;
box.Transformation = Matrix.CreateWorld(min + vec * 0.5f, dir, up);
Matrix inv;
Matrix.Invert(ref box.Transformation, out inv);
Matrix.Invert(ref box.Transformation, out Matrix inv);
Vector3 vecLocal = Vector3.TransformNormal(vec * 0.5f, inv);
box.Extents.X = margin;
box.Extents.Y = margin;

View File

@@ -99,8 +99,7 @@ namespace FlaxEditor.Viewport.Cameras
{
centerMouse = true;
EditorViewport.Input input;
Viewport.GetInput(out input);
Viewport.GetInput(out EditorViewport.Input input);
// Rotate
Viewport.YawPitch += mouseDelta;

View File

@@ -85,8 +85,7 @@ namespace FlaxEditor.Viewport.Cameras
/// <param name="actor">The actor to preview.</param>
public void ShowActor(Actor actor)
{
BoundingSphere sphere;
Editor.GetActorEditorSphere(actor, out sphere);
Editor.GetActorEditorSphere(actor, out BoundingSphere sphere);
ShowSphere(ref sphere);
}
@@ -104,8 +103,7 @@ namespace FlaxEditor.Viewport.Cameras
{
if (actors[i] is ActorNode actor)
{
BoundingSphere sphere;
Editor.GetActorEditorSphere(actor.Actor, out sphere);
Editor.GetActorEditorSphere(actor.Actor, out BoundingSphere sphere);
BoundingSphere.Merge(ref mergesSphere, ref sphere, out mergesSphere);
}
}
@@ -163,7 +161,7 @@ namespace FlaxEditor.Viewport.Cameras
Viewport.GetInput(out var input);
Viewport.GetPrevInput(out var prevInput);
var mainViewport = Viewport as MainEditorGizmoViewport;
bool isUsingGizmo = mainViewport != null && mainViewport.TransformGizmo.ActiveAxis != TransformGizmo.Axis.None;
bool isUsingGizmo = mainViewport != null && mainViewport.TransformGizmo.ActiveAxis != TransformGizmoBase.Axis.None;
// Get current view properties
float yaw = Viewport.Yaw;
@@ -179,8 +177,7 @@ namespace FlaxEditor.Viewport.Cameras
// Dolly
if (input.IsPanning || input.IsMoving || input.IsRotating)
{
Vector3 move;
Vector3.Transform(ref moveDelta, ref rotation, out move);
Vector3.Transform(ref moveDelta, ref rotation, out Vector3 move);
position += move;
}

View File

@@ -453,9 +453,11 @@ namespace FlaxEditor.Viewport
// Camera speed widget
var camSpeed = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);
var camSpeedCM = new ContextMenu();
var camSpeedButton = new ViewportWidgetButton(_movementSpeed.ToString(), Editor.Instance.Icons.ArrowRightBorder16, camSpeedCM);
camSpeedButton.Tag = this;
camSpeedButton.TooltipText = "Camera speed scale";
var camSpeedButton = new ViewportWidgetButton(_movementSpeed.ToString(), Editor.Instance.Icons.ArrowRightBorder16, camSpeedCM)
{
Tag = this,
TooltipText = "Camera speed scale"
};
_speedWidget = camSpeedButton;
for (int i = 0; i < EditorViewportCameraSpeedValues.Length; i++)
{
@@ -471,9 +473,11 @@ namespace FlaxEditor.Viewport
// View mode widget
var viewMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperLeft);
ViewWidgetButtonMenu = new ContextMenu();
var viewModeButton = new ViewportWidgetButton("View", SpriteHandle.Invalid, ViewWidgetButtonMenu);
viewModeButton.TooltipText = "View properties";
viewModeButton.Parent = viewMode;
var viewModeButton = new ViewportWidgetButton("View", SpriteHandle.Invalid, ViewWidgetButtonMenu)
{
TooltipText = "View properties",
Parent = viewMode
};
viewMode.Parent = this;
// Show
@@ -524,8 +528,10 @@ namespace FlaxEditor.Viewport
// Orthographic
{
var ortho = ViewWidgetButtonMenu.AddButton("Orthographic");
var orthoValue = new CheckBox(90, 2, _isOrtho);
orthoValue.Parent = ortho;
var orthoValue = new CheckBox(90, 2, _isOrtho)
{
Parent = ortho
};
orthoValue.StateChanged += checkBox =>
{
if (checkBox.Checked != _isOrtho)
@@ -552,8 +558,11 @@ namespace FlaxEditor.Viewport
// Field of View
{
var fov = ViewWidgetButtonMenu.AddButton("Field Of View");
var fovValue = new FloatValueBox(1, 90, 2, 70.0f, 35.0f, 160.0f, 0.1f);
fovValue.Parent = fov;
var fovValue = new FloatValueBox(1, 90, 2, 70.0f, 35.0f, 160.0f, 0.1f)
{
Parent = fov
};
fovValue.ValueChanged += () => _fieldOfView = fovValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control =>
{
@@ -565,8 +574,11 @@ namespace FlaxEditor.Viewport
// Ortho Scale
{
var orthoSize = ViewWidgetButtonMenu.AddButton("Ortho Scale");
var orthoSizeValue = new FloatValueBox(_orthoSize, 90, 2, 70.0f, 0.001f, 100000.0f, 0.01f);
orthoSizeValue.Parent = orthoSize;
var orthoSizeValue = new FloatValueBox(_orthoSize, 90, 2, 70.0f, 0.001f, 100000.0f, 0.01f)
{
Parent = orthoSize
};
orthoSizeValue.ValueChanged += () => _orthoSize = orthoSizeValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control =>
{
@@ -578,8 +590,10 @@ namespace FlaxEditor.Viewport
// Near Plane
{
var nearPlane = ViewWidgetButtonMenu.AddButton("Near Plane");
var nearPlaneValue = new FloatValueBox(2.0f, 90, 2, 70.0f, 0.001f, 1000.0f);
nearPlaneValue.Parent = nearPlane;
var nearPlaneValue = new FloatValueBox(2.0f, 90, 2, 70.0f, 0.001f, 1000.0f)
{
Parent = nearPlane
};
nearPlaneValue.ValueChanged += () => _nearPlane = nearPlaneValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => nearPlaneValue.Value = _nearPlane;
}
@@ -587,8 +601,10 @@ namespace FlaxEditor.Viewport
// Far Plane
{
var farPlane = ViewWidgetButtonMenu.AddButton("Far Plane");
var farPlaneValue = new FloatValueBox(1000, 90, 2, 70.0f, 10.0f);
farPlaneValue.Parent = farPlane;
var farPlaneValue = new FloatValueBox(1000, 90, 2, 70.0f, 10.0f)
{
Parent = farPlane
};
farPlaneValue.ValueChanged += () => _farPlane = farPlaneValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => farPlaneValue.Value = _farPlane;
}
@@ -596,8 +612,10 @@ namespace FlaxEditor.Viewport
// Brightness
{
var brightness = ViewWidgetButtonMenu.AddButton("Brightness");
var brightnessValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.001f, 10.0f, 0.001f);
brightnessValue.Parent = brightness;
var brightnessValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.001f, 10.0f, 0.001f)
{
Parent = brightness
};
brightnessValue.ValueChanged += () => Brightness = brightnessValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => brightnessValue.Value = Brightness;
}
@@ -605,8 +623,10 @@ namespace FlaxEditor.Viewport
// Resolution
{
var resolution = ViewWidgetButtonMenu.AddButton("Resolution");
var resolutionValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.1f, 4.0f, 0.001f);
resolutionValue.Parent = resolution;
var resolutionValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.1f, 4.0f, 0.001f)
{
Parent = resolution
};
resolutionValue.ValueChanged += () => ResolutionScale = resolutionValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => resolutionValue.Value = ResolutionScale;
}
@@ -614,8 +634,11 @@ namespace FlaxEditor.Viewport
// Invert Panning
{
var invert = ViewWidgetButtonMenu.AddButton("Invert Panning");
var invertValue = new CheckBox(90, 2, _invertPanning);
invertValue.Parent = invert;
var invertValue = new CheckBox(90, 2, _invertPanning)
{
Parent = invert
};
invertValue.StateChanged += checkBox =>
{
if (checkBox.Checked != _invertPanning)
@@ -690,10 +713,12 @@ namespace FlaxEditor.Viewport
private void InitFpsCounter()
{
_fpsCounter = new FpsCounter(10, ViewportWidgetsContainer.WidgetsHeight + 14);
_fpsCounter.Visible = false;
_fpsCounter.Enabled = false;
_fpsCounter.Parent = this;
_fpsCounter = new FpsCounter(10, ViewportWidgetsContainer.WidgetsHeight + 14)
{
Visible = false,
Enabled = false,
Parent = this
};
}
#endregion
@@ -1085,7 +1110,7 @@ namespace FlaxEditor.Viewport
{
// Accelerate the delta
var currentDelta = mouseDelta;
mouseDelta = mouseDelta + _mouseDeltaRightLast * _mouseAccelerationScale;
mouseDelta += _mouseDeltaRightLast * _mouseAccelerationScale;
_mouseDeltaRightLast = currentDelta;
}

View File

@@ -228,9 +228,13 @@ namespace FlaxEditor.Viewport
Parent = scaleSnappingWidget
};
enableScaleSnapping.Toggled += OnScaleSnappingToggle;
var scaleSnappingCM = new ContextMenu();
_scaleSnapping = new ViewportWidgetButton(TransformGizmo.ScaleSnapValue.ToString(), SpriteHandle.Invalid, scaleSnappingCM);
_scaleSnapping.TooltipText = "Scale snapping values";
_scaleSnapping = new ViewportWidgetButton(TransformGizmo.ScaleSnapValue.ToString(), SpriteHandle.Invalid, scaleSnappingCM)
{
TooltipText = "Scale snapping values"
};
for (int i = 0; i < EditorViewportScaleSnapValues.Length; i++)
{
var v = EditorViewportScaleSnapValues[i];
@@ -251,9 +255,13 @@ namespace FlaxEditor.Viewport
Parent = rotateSnappingWidget
};
enableRotateSnapping.Toggled += OnRotateSnappingToggle;
var rotateSnappingCM = new ContextMenu();
_rotateSnapping = new ViewportWidgetButton(TransformGizmo.RotationSnapValue.ToString(), SpriteHandle.Invalid, rotateSnappingCM);
_rotateSnapping.TooltipText = "Rotation snapping values";
_rotateSnapping = new ViewportWidgetButton(TransformGizmo.RotationSnapValue.ToString(), SpriteHandle.Invalid, rotateSnappingCM)
{
TooltipText = "Rotation snapping values"
};
for (int i = 0; i < EditorViewportRotateSnapValues.Length; i++)
{
var v = EditorViewportRotateSnapValues[i];
@@ -274,9 +282,13 @@ namespace FlaxEditor.Viewport
Parent = translateSnappingWidget
};
enableTranslateSnapping.Toggled += OnTranslateSnappingToggle;
var translateSnappingCM = new ContextMenu();
_translateSnapping = new ViewportWidgetButton(TransformGizmo.TranslationSnapValue.ToString(), SpriteHandle.Invalid, translateSnappingCM);
_translateSnapping.TooltipText = "Position snapping values";
_translateSnapping = new ViewportWidgetButton(TransformGizmo.TranslationSnapValue.ToString(), SpriteHandle.Invalid, translateSnappingCM)
{
TooltipText = "Position snapping values"
};
for (int i = 0; i < EditorViewportTranslateSnapValues.Length; i++)
{
var v = EditorViewportTranslateSnapValues[i];
@@ -368,15 +380,17 @@ namespace FlaxEditor.Viewport
return;
// Create actor
var actor = new Camera();
actor.StaticFlags = StaticFlags.None;
actor.Name = "Camera";
actor.Transform = ViewTransform;
actor.NearPlane = NearPlane;
actor.FarPlane = FarPlane;
actor.OrthographicScale = OrthographicScale;
actor.UsePerspective = !UseOrthographicProjection;
actor.FieldOfView = FieldOfView;
var actor = new Camera
{
StaticFlags = StaticFlags.None,
Name = "Camera",
Transform = ViewTransform,
NearPlane = NearPlane,
FarPlane = FarPlane,
OrthographicScale = OrthographicScale,
UsePerspective = !UseOrthographicProjection,
FieldOfView = FieldOfView
};
// Spawn
Editor.Instance.SceneEditing.Spawn(actor);
@@ -819,8 +833,7 @@ namespace FlaxEditor.Viewport
private Vector3 PostProcessSpawnedActorLocation(Actor actor, ref Vector3 hitLocation)
{
BoundingBox box;
Editor.GetActorEditorBox(actor, out box);
Editor.GetActorEditorBox(actor, out _);
// Place the object
//var location = hitLocation - (box.Size.Length * 0.5f) * ViewDirection;
@@ -846,9 +859,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<ParticleSystem>())
{
var asset = FlaxEngine.Content.LoadAsync<ParticleSystem>(item.ID);
var actor = new ParticleEffect();
actor.Name = item.ShortName;
actor.ParticleSystem = asset;
var actor = new ParticleEffect
{
Name = item.ShortName,
ParticleSystem = asset
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor);
return;
@@ -856,9 +871,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<SceneAnimation>())
{
var asset = FlaxEngine.Content.LoadAsync<SceneAnimation>(item.ID);
var actor = new SceneAnimationPlayer();
actor.Name = item.ShortName;
actor.Animation = asset;
var actor = new SceneAnimationPlayer
{
Name = item.ShortName,
Animation = asset
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor);
return;
@@ -891,9 +908,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<SkinnedModel>())
{
var model = FlaxEngine.Content.LoadAsync<SkinnedModel>(item.ID);
var actor = new AnimatedModel();
actor.Name = item.ShortName;
actor.SkinnedModel = model;
var actor = new AnimatedModel
{
Name = item.ShortName,
SkinnedModel = model
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor);
return;
@@ -901,9 +920,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<Model>())
{
var model = FlaxEngine.Content.LoadAsync<Model>(item.ID);
var actor = new StaticModel();
actor.Name = item.ShortName;
actor.Model = model;
var actor = new StaticModel
{
Name = item.ShortName,
Model = model
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor);
return;
@@ -911,9 +932,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<AudioClip>())
{
var clip = FlaxEngine.Content.LoadAsync<AudioClip>(item.ID);
var actor = new AudioSource();
actor.Name = item.ShortName;
actor.Clip = clip;
var actor = new AudioSource
{
Name = item.ShortName,
Clip = clip
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor);
return;

View File

@@ -3,7 +3,7 @@
namespace FlaxEditor.Viewport.Modes
{
/// <summary>
/// The default editor mode that uses <see cref="FlaxEditor.Gizmo.TransformGizmo"/> for objects transforming.
/// The default editor mode that uses <see cref="FlaxEditor.Gizmo.TransformGizmoBase"/> for objects transforming.
/// </summary>
/// <seealso cref="FlaxEditor.Viewport.Modes.EditorGizmoMode" />
public class TransformGizmoMode : EditorGizmoMode

View File

@@ -92,7 +92,7 @@ namespace FlaxEditor.Viewport
var transformSpaceWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);
var transformSpaceToggle = new ViewportWidgetButton(string.Empty, window.Editor.Icons.World16, null, true)
{
Checked = TransformGizmo.ActiveTransformSpace == TransformGizmo.TransformSpace.World,
Checked = TransformGizmo.ActiveTransformSpace == TransformGizmoBase.TransformSpace.World,
TooltipText = "Gizmo transform space (world or local)",
Parent = transformSpaceWidget
};
@@ -108,9 +108,13 @@ namespace FlaxEditor.Viewport
Parent = scaleSnappingWidget
};
enableScaleSnapping.Toggled += OnScaleSnappingToggle;
var scaleSnappingCM = new ContextMenu();
_scaleSnapping = new ViewportWidgetButton(TransformGizmo.ScaleSnapValue.ToString(), SpriteHandle.Invalid, scaleSnappingCM);
_scaleSnapping.TooltipText = "Scale snapping values";
_scaleSnapping = new ViewportWidgetButton(TransformGizmo.ScaleSnapValue.ToString(), SpriteHandle.Invalid, scaleSnappingCM)
{
TooltipText = "Scale snapping values"
};
for (int i = 0; i < EditorViewportScaleSnapValues.Length; i++)
{
var v = EditorViewportScaleSnapValues[i];
@@ -131,9 +135,13 @@ namespace FlaxEditor.Viewport
Parent = rotateSnappingWidget
};
enableRotateSnapping.Toggled += OnRotateSnappingToggle;
var rotateSnappingCM = new ContextMenu();
_rotateSnapping = new ViewportWidgetButton(TransformGizmo.RotationSnapValue.ToString(), SpriteHandle.Invalid, rotateSnappingCM);
_rotateSnapping.TooltipText = "Rotation snapping values";
_rotateSnapping = new ViewportWidgetButton(TransformGizmo.RotationSnapValue.ToString(), SpriteHandle.Invalid, rotateSnappingCM)
{
TooltipText = "Rotation snapping values"
};
for (int i = 0; i < EditorViewportRotateSnapValues.Length; i++)
{
var v = EditorViewportRotateSnapValues[i];
@@ -154,9 +162,13 @@ namespace FlaxEditor.Viewport
Parent = translateSnappingWidget
};
enableTranslateSnapping.Toggled += OnTranslateSnappingToggle;
var translateSnappingCM = new ContextMenu();
_translateSnappng = new ViewportWidgetButton(TransformGizmo.TranslationSnapValue.ToString(), SpriteHandle.Invalid, translateSnappingCM);
_translateSnappng.TooltipText = "Position snapping values";
_translateSnappng = new ViewportWidgetButton(TransformGizmo.TranslationSnapValue.ToString(), SpriteHandle.Invalid, translateSnappingCM)
{
TooltipText = "Position snapping values"
};
for (int i = 0; i < EditorViewportTranslateSnapValues.Length; i++)
{
var v = EditorViewportTranslateSnapValues[i];
@@ -172,7 +184,7 @@ namespace FlaxEditor.Viewport
var gizmoMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);
_gizmoModeTranslate = new ViewportWidgetButton(string.Empty, window.Editor.Icons.Translate16, null, true)
{
Tag = TransformGizmo.Mode.Translate,
Tag = TransformGizmoBase.Mode.Translate,
TooltipText = "Translate gizmo mode",
Checked = true,
Parent = gizmoMode
@@ -180,14 +192,14 @@ namespace FlaxEditor.Viewport
_gizmoModeTranslate.Toggled += OnGizmoModeToggle;
_gizmoModeRotate = new ViewportWidgetButton(string.Empty, window.Editor.Icons.Rotate16, null, true)
{
Tag = TransformGizmo.Mode.Rotate,
Tag = TransformGizmoBase.Mode.Rotate,
TooltipText = "Rotate gizmo mode",
Parent = gizmoMode
};
_gizmoModeRotate.Toggled += OnGizmoModeToggle;
_gizmoModeScale = new ViewportWidgetButton(string.Empty, window.Editor.Icons.Scale16, null, true)
{
Tag = TransformGizmo.Mode.Scale,
Tag = TransformGizmoBase.Mode.Scale,
TooltipText = "Scale gizmo mode",
Parent = gizmoMode
};
@@ -288,7 +300,7 @@ namespace FlaxEditor.Viewport
private void OnGizmoModeToggle(ViewportWidgetButton button)
{
TransformGizmo.ActiveMode = (TransformGizmo.Mode)(int)button.Tag;
TransformGizmo.ActiveMode = (TransformGizmoBase.Mode)(int)button.Tag;
}
private void OnTranslateSnappingToggle(ViewportWidgetButton button)
@@ -315,9 +327,9 @@ namespace FlaxEditor.Viewport
{
// Update all viewport widgets status
var mode = TransformGizmo.ActiveMode;
_gizmoModeTranslate.Checked = mode == TransformGizmo.Mode.Translate;
_gizmoModeRotate.Checked = mode == TransformGizmo.Mode.Rotate;
_gizmoModeScale.Checked = mode == TransformGizmo.Mode.Scale;
_gizmoModeTranslate.Checked = mode == TransformGizmoBase.Mode.Translate;
_gizmoModeRotate.Checked = mode == TransformGizmoBase.Mode.Rotate;
_gizmoModeScale.Checked = mode == TransformGizmoBase.Mode.Scale;
}
private static readonly float[] EditorViewportScaleSnapValues =
@@ -446,7 +458,7 @@ namespace FlaxEditor.Viewport
public void ApplyTransform(List<SceneGraphNode> selection, ref Vector3 translationDelta, ref Quaternion rotationDelta, ref Vector3 scaleDelta)
{
bool applyRotation = !rotationDelta.IsIdentity;
bool useObjCenter = TransformGizmo.ActivePivot == TransformGizmo.PivotType.ObjectCenter;
bool useObjCenter = TransformGizmo.ActivePivot == TransformGizmoBase.PivotType.ObjectCenter;
Vector3 gizmoPosition = TransformGizmo.Position;
// Transform selected objects
@@ -512,7 +524,7 @@ namespace FlaxEditor.Viewport
if (TransformGizmo.IsActive)
{
// Ensure player is not moving objects
if (TransformGizmo.ActiveAxis != TransformGizmo.Axis.None)
if (TransformGizmo.ActiveAxis != TransformGizmoBase.Axis.None)
return;
}
else
@@ -633,8 +645,7 @@ namespace FlaxEditor.Viewport
private Vector3 PostProcessSpawnedActorLocation(Actor actor, ref Vector3 hitLocation)
{
BoundingBox box;
Editor.GetActorEditorBox(actor, out box);
Editor.GetActorEditorBox(actor, out BoundingBox box);
// Place the object
var location = hitLocation - (box.Size.Length * 0.5f) * ViewDirection;
@@ -659,9 +670,11 @@ namespace FlaxEditor.Viewport
if (binaryAssetItem.Type == typeof(ParticleSystem))
{
var particleSystem = FlaxEngine.Content.LoadAsync<ParticleSystem>(item.ID);
var actor = new ParticleEffect();
actor.Name = item.ShortName;
actor.ParticleSystem = particleSystem;
var actor = new ParticleEffect
{
Name = item.ShortName,
ParticleSystem = particleSystem
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Spawn(actor);
return;
@@ -684,9 +697,11 @@ namespace FlaxEditor.Viewport
if (typeof(SkinnedModel).IsAssignableFrom(binaryAssetItem.Type))
{
var model = FlaxEngine.Content.LoadAsync<SkinnedModel>(item.ID);
var actor = new AnimatedModel();
actor.Name = item.ShortName;
actor.SkinnedModel = model;
var actor = new AnimatedModel
{
Name = item.ShortName,
SkinnedModel = model
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Spawn(actor);
return;
@@ -694,9 +709,11 @@ namespace FlaxEditor.Viewport
if (typeof(Model).IsAssignableFrom(binaryAssetItem.Type))
{
var model = FlaxEngine.Content.LoadAsync<Model>(item.ID);
var actor = new StaticModel();
actor.Name = item.ShortName;
actor.Model = model;
var actor = new StaticModel
{
Name = item.ShortName,
Model = model
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Spawn(actor);
return;
@@ -704,9 +721,11 @@ namespace FlaxEditor.Viewport
if (typeof(AudioClip).IsAssignableFrom(binaryAssetItem.Type))
{
var clip = FlaxEngine.Content.LoadAsync<AudioClip>(item.ID);
var actor = new AudioSource();
actor.Name = item.ShortName;
actor.Clip = clip;
var actor = new AudioSource
{
Name = item.ShortName,
Clip = clip
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Spawn(actor);
return;

View File

@@ -64,15 +64,20 @@ namespace FlaxEditor.Viewport.Previews
Task.Begin += OnBegin;
// Setup preview scene
_previewModel = new AnimatedModel();
_previewModel.UseTimeScale = false;
_previewModel.UpdateWhenOffscreen = true;
//_previewModel.BoundsScale = 1000.0f;
_previewModel.UpdateMode = AnimatedModel.AnimationUpdateMode.Manual;
_previewModel = new AnimatedModel
{
UseTimeScale = false,
UpdateWhenOffscreen = true,
//_previewModel.BoundsScale = 1000.0f;
UpdateMode = AnimatedModel.AnimationUpdateMode.Manual
};
_previewNodesModel = FlaxEngine.Content.CreateVirtualAsset<Model>();
_previewNodesModel.SetupLODs(new[] { 1 });
_previewNodesActor = new StaticModel();
_previewNodesActor.Model = _previewNodesModel;
_previewNodesActor = new StaticModel
{
Model = _previewNodesModel
};
_previewNodesActor.SetMaterial(0, FlaxEngine.Content.LoadAsyncInternal<MaterialBase>(EditorAssets.WiresDebugMaterial));
// Link actors for rendering
@@ -84,8 +89,10 @@ namespace FlaxEditor.Viewport.Previews
// Preview LOD
{
var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD");
var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f);
previewLODValue.Parent = previewLOD;
var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f)
{
Parent = previewLOD
};
previewLODValue.ValueChanged += () => _previewModel.ForcedLOD = previewLODValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => previewLODValue.Value = _previewModel.ForcedLOD;
}

View File

@@ -95,26 +95,36 @@ namespace FlaxEditor.Viewport.Previews
}
// Setup preview scene
PreviewLight = new DirectionalLight();
PreviewLight.Brightness = 8.0f;
PreviewLight.ShadowsMode = ShadowsCastingMode.None;
PreviewLight.Orientation = Quaternion.Euler(new Vector3(52.1477f, -109.109f, -111.739f));
PreviewLight = new DirectionalLight
{
Brightness = 8.0f,
ShadowsMode = ShadowsCastingMode.None,
Orientation = Quaternion.Euler(new Vector3(52.1477f, -109.109f, -111.739f))
};
//
EnvProbe = new EnvironmentProbe();
EnvProbe.AutoUpdate = false;
EnvProbe.CustomProbe = FlaxEngine.Content.LoadAsyncInternal<CubeTexture>(EditorAssets.DefaultSkyCubeTexture);
EnvProbe = new EnvironmentProbe
{
AutoUpdate = false,
CustomProbe = FlaxEngine.Content.LoadAsyncInternal<CubeTexture>(EditorAssets.DefaultSkyCubeTexture)
};
//
Sky = new Sky();
Sky.SunLight = PreviewLight;
Sky.SunPower = 9.0f;
Sky = new Sky
{
SunLight = PreviewLight,
SunPower = 9.0f
};
//
SkyLight = new SkyLight();
SkyLight.Mode = SkyLight.Modes.CustomTexture;
SkyLight.Brightness = 2.1f;
SkyLight.CustomTexture = EnvProbe.CustomProbe;
SkyLight = new SkyLight()
{
Mode = SkyLight.Modes.CustomTexture,
Brightness = 2.1f,
CustomTexture = EnvProbe.CustomProbe
};
//
PostFxVolume = new PostFxVolume();
PostFxVolume.IsBounded = false;
PostFxVolume = new PostFxVolume
{
IsBounded = false
};
// Link actors for rendering
Task.ActorsSource = ActorsSources.CustomActors;

View File

@@ -202,9 +202,11 @@ namespace FlaxEditor.Viewport.Previews
// Decal
if (decalMaterial && _decal == null)
{
_decal = new Decal();
_decal.Size = new Vector3(100.0f);
_decal.LocalOrientation = Quaternion.RotationZ(Mathf.PiOverTwo);
_decal = new Decal
{
Size = new Vector3(100.0f),
LocalOrientation = Quaternion.RotationZ(Mathf.PiOverTwo)
};
Task.AddCustomActor(_decal);
}
if (_decal)
@@ -254,9 +256,11 @@ namespace FlaxEditor.Viewport.Previews
// Particle
if (particleMaterial && _particleEffect == null)
{
_particleEffect = new ParticleEffect();
_particleEffect.IsLooping = true;
_particleEffect.UseTimeScale = false;
_particleEffect = new ParticleEffect
{
IsLooping = true,
UseTimeScale = false
};
Task.AddCustomActor(_particleEffect);
}
if (_particleEffect != null)

View File

@@ -53,8 +53,10 @@ namespace FlaxEditor.Viewport.Previews
// Preview LOD
{
var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD");
var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f);
previewLODValue.Parent = previewLOD;
var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f)
{
Parent = previewLOD
};
previewLODValue.ValueChanged += () => _previewModel.ForcedLOD = previewLODValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => previewLODValue.Value = _previewModel.ForcedLOD;
}

View File

@@ -67,8 +67,10 @@ namespace FlaxEditor.Viewport.Previews
if (useWidgets)
{
var playbackDuration = ViewWidgetButtonMenu.AddButton("Duration");
var playbackDurationValue = new FloatValueBox(_playbackDuration, 90, 2, 70.0f, 0.1f, 1000000.0f, 0.1f);
playbackDurationValue.Parent = playbackDuration;
var playbackDurationValue = new FloatValueBox(_playbackDuration, 90, 2, 70.0f, 0.1f, 1000000.0f, 0.1f)
{
Parent = playbackDuration
};
playbackDurationValue.ValueChanged += () => PlaybackDuration = playbackDurationValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => playbackDurationValue.Value = PlaybackDuration;
}

View File

@@ -56,8 +56,10 @@ namespace FlaxEditor.Viewport.Previews
{
if (!_boundsModel)
{
_boundsModel = new StaticModel();
_boundsModel.Model = FlaxEngine.Content.LoadAsyncInternal<Model>("Editor/Gizmo/WireBox");
_boundsModel = new StaticModel
{
Model = FlaxEngine.Content.LoadAsyncInternal<Model>("Editor/Gizmo/WireBox")
};
_boundsModel.Model.WaitForLoaded();
_boundsModel.SetMaterial(0, FlaxEngine.Content.LoadAsyncInternal<MaterialBase>("Editor/Gizmo/MaterialWireFocus"));
Task.AddCustomActor(_boundsModel);
@@ -96,12 +98,14 @@ namespace FlaxEditor.Viewport.Previews
{
if (!_originModel)
{
_originModel = new StaticModel();
_originModel.Model = FlaxEngine.Content.LoadAsyncInternal<Model>("Editor/Primitives/Sphere");
_originModel = new StaticModel
{
Model = FlaxEngine.Content.LoadAsyncInternal<Model>("Editor/Primitives/Sphere"),
Position = _previewEffect.Position,
Scale = new Vector3(0.1f)
};
_originModel.Model.WaitForLoaded();
_originModel.SetMaterial(0, FlaxEngine.Content.LoadAsyncInternal<MaterialBase>("Editor/Gizmo/MaterialAxisFocus"));
_originModel.Position = _previewEffect.Position;
_originModel.Scale = new Vector3(0.1f);
Task.AddCustomActor(_originModel);
}
else if (!_originModel.IsActive)
@@ -147,10 +151,12 @@ namespace FlaxEditor.Viewport.Previews
: base(useWidgets, new FPSCamera())
{
// Setup preview scene
_previewEffect = new ParticleEffect();
_previewEffect.UseTimeScale = false;
_previewEffect.IsLooping = true;
_previewEffect.CustomViewRenderTask = Task;
_previewEffect = new ParticleEffect
{
UseTimeScale = false,
IsLooping = true,
CustomViewRenderTask = Task
};
// Link actors for rendering
Task.AddCustomActor(_previewEffect);

View File

@@ -62,10 +62,12 @@ namespace FlaxEditor.Windows.Assets
_showFloorButton.IndexInParent = 1;
// Floor model
_floorModel = new StaticModel();
_floorModel.Position = new Vector3(0, -25, 0);
_floorModel.Scale = new Vector3(5, 0.5f, 5);
_floorModel.Model = FlaxEngine.Content.LoadAsync<Model>(StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Primitives/Cube.flax"));
_floorModel = new StaticModel
{
Position = new Vector3(0, -25, 0),
Scale = new Vector3(5, 0.5f, 5),
Model = FlaxEngine.Content.LoadAsync<Model>(StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Primitives/Cube.flax"))
};
Task.AddCustomActor(_floorModel);
// Enable shadows

View File

@@ -260,15 +260,13 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
Timeline.TimeShowModes value2;
bool value3;
if (float.TryParse(node.GetAttribute("TimelineSplitter"), out value1))
if (float.TryParse(node.GetAttribute("TimelineSplitter"), out float value1))
_timeline.Splitter.SplitterValue = value1;
if (Enum.TryParse(node.GetAttribute("TimeShowMode"), out value2))
if (Enum.TryParse(node.GetAttribute("TimeShowMode"), out Timeline.TimeShowModes value2))
_timeline.TimeShowMode = value2;
if (bool.TryParse(node.GetAttribute("ShowPreviewValues"), out value3))
if (bool.TryParse(node.GetAttribute("ShowPreviewValues"), out bool value3))
_timeline.ShowPreviewValues = value3;
}

View File

@@ -44,8 +44,7 @@ namespace FlaxEditor.Windows.Assets
{
var audio = window.Asset;
AudioDataInfo info = audio.Info;
int originalSize, importedSize;
Editor.Internal_GetAudioClipMetadata(FlaxEngine.Object.GetUnmanagedPtr(audio), out originalSize, out importedSize);
Editor.Internal_GetAudioClipMetadata(FlaxEngine.Object.GetUnmanagedPtr(audio), out int originalSize, out int importedSize);
var group = layout.Group("General");
group.Label("Format: " + audio.Format);
@@ -220,9 +219,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -305,9 +305,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -212,9 +212,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -39,8 +39,10 @@ namespace FlaxEditor.Windows.Assets
public void Get(out FontOptions options)
{
options = new FontOptions();
options.Hinting = Hinting;
options = new FontOptions
{
Hinting = Hinting
};
if (AntiAliasing)
options.Flags |= FontFlags.AntiAliasing;
if (Bold)

View File

@@ -509,9 +509,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -193,9 +193,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -59,11 +59,13 @@ namespace FlaxEditor.Windows.Assets
_showCurrentLODButton.IndexInParent = 2;
// Floor model
_floorModel = new StaticModel();
_floorModel.Position = new Vector3(0, -25, 0);
_floorModel.Scale = new Vector3(5, 0.5f, 5);
_floorModel.Model = FlaxEngine.Content.LoadAsync<Model>(StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Primitives/Cube.flax"));
_floorModel.IsActive = false;
_floorModel = new StaticModel
{
Position = new Vector3(0, -25, 0),
Scale = new Vector3(5, 0.5f, 5),
Model = FlaxEngine.Content.LoadAsync<Model>(StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Primitives/Cube.flax")),
IsActive = false
};
Task.AddCustomActor(_floorModel);
// Enable shadows
@@ -831,8 +833,10 @@ namespace FlaxEditor.Windows.Assets
_tabs.AddTab(new ImportTab(this));
// Highlight actor (used to highlight selected material slot, see UpdateEffectsOnAsset)
_highlightActor = new StaticModel();
_highlightActor.IsActive = false;
_highlightActor = new StaticModel
{
IsActive = false
};
_preview.Task.AddCustomActor(_highlightActor);
}

View File

@@ -557,12 +557,12 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split1"), out value1))
if (float.TryParse(node.GetAttribute("Split1"), out float value1))
_split1.SplitterValue = value1;
if (float.TryParse(node.GetAttribute("Split2"), out value1))
_split2.SplitterValue = value1;
if (float.TryParse(node.GetAttribute("Split3"), out value1))
_timeline.Splitter.SplitterValue = value1;
}

View File

@@ -73,8 +73,10 @@ namespace FlaxEditor.Windows.Assets
// Create popup
var contextMenu = new ContextMenu();
contextMenu.MinimumWidth = 120;
var contextMenu = new ContextMenu
{
MinimumWidth = 120
};
// Basic editing options
@@ -213,20 +215,17 @@ namespace FlaxEditor.Windows.Assets
{
if (actor == null)
throw new ArgumentNullException(nameof(actor));
if (parent == null)
throw new ArgumentNullException(nameof(parent));
// Link it
actor.Parent = parent;
actor.Parent = parent ?? throw new ArgumentNullException(nameof(parent));
// Peek spawned node
var actorNode = SceneGraphFactory.FindNode(actor.ID) as ActorNode ?? SceneGraphFactory.BuildActorNode(actor);
if (actorNode == null)
throw new InvalidOperationException("Failed to create scene node for the spawned actor.");
var parentNode = SceneGraphFactory.FindNode(parent.ID) as ActorNode;
if (parentNode == null)
throw new InvalidOperationException("Missing scene graph node for the spawned parent actor.");
actorNode.ParentNode = parentNode;
actorNode.ParentNode = parentNode ?? throw new InvalidOperationException("Missing scene graph node for the spawned parent actor.");
// Call post spawn action (can possibly setup custom default values)
actorNode.PostSpawn();

View File

@@ -158,9 +158,9 @@ namespace FlaxEditor.Windows.Assets
_toolStripUndo = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo32, _undo.PerformUndo).LinkTooltip("Undo (Ctrl+Z)");
_toolStripRedo = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo32, _undo.PerformRedo).LinkTooltip("Redo (Ctrl+Y)");
_toolstrip.AddSeparator();
_toolStripTranslate = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Translate32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmo.Mode.Translate).LinkTooltip("Change Gizmo tool mode to Translate (1)");
_toolStripRotate = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Rotate32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmo.Mode.Rotate).LinkTooltip("Change Gizmo tool mode to Rotate (2)");
_toolStripScale = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Scale32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmo.Mode.Scale).LinkTooltip("Change Gizmo tool mode to Scale (3)");
_toolStripTranslate = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Translate32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Translate).LinkTooltip("Change Gizmo tool mode to Translate (1)");
_toolStripRotate = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Rotate32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate).LinkTooltip("Change Gizmo tool mode to Rotate (2)");
_toolStripScale = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Scale32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale).LinkTooltip("Change Gizmo tool mode to Scale (3)");
_toolstrip.AddSeparator();
_toolStripLiveReload = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Reload32, () => LiveReload = !LiveReload).SetChecked(true).SetAutoCheck(true).LinkTooltip("Live changes preview (applies prefab changes on modification by auto)");
@@ -311,9 +311,9 @@ namespace FlaxEditor.Windows.Assets
_toolStripRedo.Enabled = undoRedo.CanRedo;
//
var gizmoMode = gizmo.ActiveMode;
_toolStripTranslate.Checked = gizmoMode == TransformGizmo.Mode.Translate;
_toolStripRotate.Checked = gizmoMode == TransformGizmo.Mode.Rotate;
_toolStripScale.Checked = gizmoMode == TransformGizmo.Mode.Scale;
_toolStripTranslate.Checked = gizmoMode == TransformGizmoBase.Mode.Translate;
_toolStripRotate.Checked = gizmoMode == TransformGizmoBase.Mode.Rotate;
_toolStripScale.Checked = gizmoMode == TransformGizmoBase.Mode.Scale;
//
_toolStripLiveReload.Checked = _liveReload;
@@ -401,8 +401,7 @@ namespace FlaxEditor.Windows.Assets
{
_focusCamera = false;
BoundingSphere bounds;
Editor.GetActorEditorSphere(_viewport.Instance, out bounds);
Editor.GetActorEditorSphere(_viewport.Instance, out BoundingSphere bounds);
_viewport.ViewPosition = bounds.Center - _viewport.ViewDirection * (bounds.Radius * 1.2f);
}
@@ -428,20 +427,17 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split1"), out value1))
if (float.TryParse(node.GetAttribute("Split1"), out float value1))
_split1.SplitterValue = value1;
if (float.TryParse(node.GetAttribute("Split2"), out value1))
_split2.SplitterValue = value1;
bool value2;
if (bool.TryParse(node.GetAttribute("LiveReload"), out value2))
if (bool.TryParse(node.GetAttribute("LiveReload"), out bool value2))
LiveReload = value2;
TransformGizmo.Mode value3;
if (Enum.TryParse(node.GetAttribute("GizmoMode"), out value3))
if (Enum.TryParse(node.GetAttribute("GizmoMode"), out TransformGizmoBase.Mode value3))
Viewport.TransformGizmo.ActiveMode = value3;
}

View File

@@ -890,19 +890,18 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
Guid value2;
Timeline.TimeShowModes value3;
bool value4;
if (float.TryParse(node.GetAttribute("TimelineSplitter"), out value1))
if (float.TryParse(node.GetAttribute("TimelineSplitter"), out float value1))
_timeline.Splitter.SplitterValue = value1;
if (Guid.TryParse(node.GetAttribute("SelectedPlayer"), out value2))
if (Guid.TryParse(node.GetAttribute("SelectedPlayer"), out Guid value2))
_cachedPlayerId = value2;
if (Enum.TryParse(node.GetAttribute("TimeShowMode"), out value3))
if (Enum.TryParse(node.GetAttribute("TimeShowMode"), out Timeline.TimeShowModes value3))
_timeline.TimeShowMode = value3;
if (bool.TryParse(node.GetAttribute("ShowPreviewValues"), out value4))
if (bool.TryParse(node.GetAttribute("ShowPreviewValues"), out bool value4))
_timeline.ShowPreviewValues = value4;
if (bool.TryParse(node.GetAttribute("ShowSelected3dTrack"), out value4))
_timeline.ShowSelected3dTrack = value4;
}

View File

@@ -296,9 +296,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -59,11 +59,13 @@ namespace FlaxEditor.Windows.Assets
_showCurrentLODButton.IndexInParent = 2;
// Floor model
_floorModel = new StaticModel();
_floorModel.Position = new Vector3(0, -25, 0);
_floorModel.Scale = new Vector3(5, 0.5f, 5);
_floorModel.Model = FlaxEngine.Content.LoadAsync<Model>(StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Primitives/Cube.flax"));
_floorModel.IsActive = false;
_floorModel = new StaticModel
{
Position = new Vector3(0, -25, 0),
Scale = new Vector3(5, 0.5f, 5),
Model = FlaxEngine.Content.LoadAsync<Model>(StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Primitives/Cube.flax")),
IsActive = false
};
Task.AddCustomActor(_floorModel);
// Enable shadows
@@ -929,8 +931,10 @@ namespace FlaxEditor.Windows.Assets
_tabs.AddTab(new ImportTab(this));
// Highlight actor (used to highlight selected material slot, see UpdateEffectsOnAsset)
_highlightActor = new AnimatedModel();
_highlightActor.IsActive = false;
_highlightActor = new AnimatedModel
{
IsActive = false
};
_preview.Task.AddCustomActor(_highlightActor);
}

View File

@@ -163,8 +163,7 @@ namespace FlaxEditor.Windows.Assets
UpdateSprites();
// Try to restore target asset texture import options (useful for fast reimport)
TextureImportSettings.InternalOptions options;
if (TextureImportEntry.Internal_GetTextureImportOptions(win.Item.Path, out options))
if (TextureImportEntry.Internal_GetTextureImportOptions(win.Item.Path, out TextureImportSettings.InternalOptions options))
{
// Restore settings
ImportSettings.FromInternal(ref options);
@@ -352,9 +351,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -214,9 +214,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -1107,9 +1107,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -40,8 +40,11 @@ namespace FlaxEditor.Windows
// Create context menu
ContextMenuButton b;
ContextMenuChildMenu c;
ContextMenu cm = new ContextMenu();
cm.Tag = item;
ContextMenu cm = new ContextMenu
{
Tag = item
};
if (isTreeNode)
{
b = cm.AddButton("Expand All", OnExpandAllClicked);
@@ -52,6 +55,7 @@ namespace FlaxEditor.Windows
cm.AddSeparator();
}
if (item is ContentFolder contentFolder && contentFolder.Node is ProjectTreeNode)
{
cm.AddButton("Show in explorer", () => FileSystem.ShowFileExplorer(CurrentViewFolder.Path));
@@ -75,8 +79,7 @@ namespace FlaxEditor.Windows
if (item is BinaryAssetItem binaryAsset)
{
string importPath;
if (!binaryAsset.GetImportPath(out importPath))
if (!binaryAsset.GetImportPath(out string importPath))
{
string importLocation = System.IO.Path.GetDirectoryName(importPath);
if (!string.IsNullOrEmpty(importLocation) && System.IO.Directory.Exists(importLocation))

View File

@@ -177,8 +177,10 @@ namespace FlaxEditor.Windows
showFileExtensionsButton.AutoCheck = true;
var viewScale = menu.AddButton("View Scale");
var scaleValue = new FloatValueBox(1, 75, 2, 50.0f, 0.3f, 3.0f, 0.01f);
scaleValue.Parent = viewScale;
var scaleValue = new FloatValueBox(1, 75, 2, 50.0f, 0.3f, 3.0f, 0.01f)
{
Parent = viewScale
};
scaleValue.ValueChanged += () => View.ViewScale = scaleValue.Value;
menu.VisibleChanged += control => { scaleValue.Value = View.ViewScale; };
@@ -742,11 +744,15 @@ namespace FlaxEditor.Windows
public override void OnInit()
{
// Setup content root node
_root = new RootContentTreeNode();
_root.ChildrenIndent = 0;
_root = new RootContentTreeNode
{
ChildrenIndent = 0
};
_root.Expand(true);
foreach (var project in Editor.ContentDatabase.Projects)
AddFolder2Root(project);
Editor.ContentDatabase.Game?.Expand(true);
_tree.Margin = new Margin(0.0f, 0.0f, -16.0f, 2.0f); // Hide root node
_tree.AddChild(_root);
@@ -856,15 +862,15 @@ namespace FlaxEditor.Windows
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
bool value2;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
if (float.TryParse(node.GetAttribute("Scale"), out value1))
_view.ViewScale = value1;
if (bool.TryParse(node.GetAttribute("ShowFileExtensions"), out value2))
if (bool.TryParse(node.GetAttribute("ShowFileExtensions"), out bool value2))
_view.ShowFileExtensions = value2;
if (Enum.TryParse(node.GetAttribute("ViewType"), out ContentViewType viewType))
_view.ViewType = viewType;
}

View File

@@ -592,9 +592,7 @@ namespace FlaxEditor.Windows
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split"), out value1))
if (float.TryParse(node.GetAttribute("Split"), out float value1))
_split.SplitterValue = value1;
}

View File

@@ -434,29 +434,34 @@ namespace FlaxEditor.Windows
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
bool value1;
float value2;
long value3;
if (bool.TryParse(node.GetAttribute("GridEnabled"), out value1))
if (bool.TryParse(node.GetAttribute("GridEnabled"), out bool value1))
Viewport.Grid.Enabled = value1;
if (bool.TryParse(node.GetAttribute("ShowFpsCounter"), out value1))
Viewport.ShowFpsCounter = value1;
if (bool.TryParse(node.GetAttribute("ShowNavigation"), out value1))
Viewport.ShowNavigation = value1;
if (float.TryParse(node.GetAttribute("NearPlane"), out value2))
if (float.TryParse(node.GetAttribute("NearPlane"), out float value2))
Viewport.NearPlane = value2;
if (float.TryParse(node.GetAttribute("FarPlane"), out value2))
Viewport.FarPlane = value2;
if (float.TryParse(node.GetAttribute("FieldOfView"), out value2))
Viewport.FieldOfView = value2;
if (float.TryParse(node.GetAttribute("MovementSpeed"), out value2))
Viewport.MovementSpeed = value2;
if (float.TryParse(node.GetAttribute("OrthographicScale"), out value2))
Viewport.OrthographicScale = value2;
if (bool.TryParse(node.GetAttribute("UseOrthographicProjection"), out value1))
Viewport.UseOrthographicProjection = value1;
if (long.TryParse(node.GetAttribute("ViewFlags"), out value3))
if (long.TryParse(node.GetAttribute("ViewFlags"), out long value3))
Viewport.Task.ViewFlags = (ViewFlags)value3;
// Reset view flags if opening with different engine version (ViewFlags enum could be modified)

View File

@@ -255,16 +255,20 @@ namespace FlaxEditor.Windows
// Viewport Brightness
{
var brightness = menu.AddButton("Viewport Brightness");
var brightnessValue = new FloatValueBox(_viewport.Brightness, 140, 2, 50.0f, 0.001f, 10.0f, 0.001f);
brightnessValue.Parent = brightness;
var brightnessValue = new FloatValueBox(_viewport.Brightness, 140, 2, 50.0f, 0.001f, 10.0f, 0.001f)
{
Parent = brightness
};
brightnessValue.ValueChanged += () => _viewport.Brightness = brightnessValue.Value;
}
// Viewport Resolution
{
var resolution = menu.AddButton("Viewport Resolution");
var resolutionValue = new FloatValueBox(_viewport.ResolutionScale, 140, 2, 50.0f, 0.1f, 4.0f, 0.001f);
resolutionValue.Parent = resolution;
var resolutionValue = new FloatValueBox(_viewport.ResolutionScale, 140, 2, 50.0f, 0.1f, 4.0f, 0.001f)
{
Parent = resolution
};
resolutionValue.ValueChanged += () => _viewport.ResolutionScale = resolutionValue.Value;
}

View File

@@ -615,9 +615,7 @@ namespace FlaxEditor.Windows
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
int value1;
if (int.TryParse(node.GetAttribute("LogTypeShowMask"), out value1))
if (int.TryParse(node.GetAttribute("LogTypeShowMask"), out int value1))
_logTypeShowMask = value1;
}

View File

@@ -157,7 +157,7 @@ namespace FlaxEditor.Windows.Profiler
float width = (float)(e.Time * scale);
string name = new string(e.Name);
var control = new Timeline.Event(x, e.Depth, width)
new Timeline.Event(x, e.Depth, width)
{
Name = name,
TooltipText = string.Format("{0}, {1} ms", name, ((int)(e.Time * 10000.0) / 10000.0f)),

View File

@@ -30,8 +30,10 @@ namespace FlaxEditor.Windows
// Create popup
var contextMenu = new ContextMenu();
contextMenu.MinimumWidth = 120;
var contextMenu = new ContextMenu
{
MinimumWidth = 120
};
// Expand/collapse

View File

@@ -199,8 +199,7 @@ namespace FlaxEditor.Windows
{
var text = actorType.Name;
QueryFilterHelper.Range[] ranges;
if (!QueryFilterHelper.Match(filterText, text, out ranges))
if (!QueryFilterHelper.Match(filterText, text, out QueryFilterHelper.Range[] ranges))
continue;
var item = _groupSearch.AddChild(CreateActorItem(CustomEditors.CustomEditorsUtil.GetPropertyNameUI(text), actorType));

View File

@@ -119,8 +119,11 @@ namespace FlaxEditor.Windows
private void OnTreeRightClick(TreeNode treeNode, Vector2 location)
{
var menu = new ContextMenu();
menu.Tag = treeNode.Tag;
var menu = new ContextMenu
{
Tag = treeNode.Tag
};
menu.AddButton("Show node", button =>
{
var node = Node.GetNode(button.ParentContextMenu.Tag);

Some files were not shown because too many files have changed in this diff Show More