diff --git a/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs b/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs
index e341d4d4f..1d65ec71c 100644
--- a/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs
@@ -123,10 +123,10 @@ namespace FlaxEditor.CustomEditors.Editors
_linkButton.Clicked += ToggleLink;
ToggleEnabled();
SetLinkStyle();
- var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
- _linkButton.LocalX += textSize.X + 10;
if (LinkedLabel != null)
{
+ var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
+ _linkButton.LocalX += textSize.X + 10;
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
{
menu.AddSeparator();
diff --git a/Source/Editor/CustomEditors/Editors/IntegerEditor.cs b/Source/Editor/CustomEditors/Editors/IntegerEditor.cs
index 4f6c2a9e7..16bcde242 100644
--- a/Source/Editor/CustomEditors/Editors/IntegerEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/IntegerEditor.cs
@@ -50,7 +50,6 @@ namespace FlaxEditor.CustomEditors.Editors
return;
}
}
- if (_element == null)
{
// Use int value editor
var element = layout.IntegerValue();
diff --git a/Source/Editor/GUI/ContextMenu/ContextMenu.cs b/Source/Editor/GUI/ContextMenu/ContextMenu.cs
index cb197e141..80a2d7494 100644
--- a/Source/Editor/GUI/ContextMenu/ContextMenu.cs
+++ b/Source/Editor/GUI/ContextMenu/ContextMenu.cs
@@ -337,14 +337,12 @@ namespace FlaxEditor.GUI.ContextMenu
///
/// Adds the separator.
///
- /// Created context menu item control.
- public ContextMenuSeparator AddSeparator()
+ public void AddSeparator()
{
var item = new ContextMenuSeparator(this)
{
Parent = _panel
};
- return item;
}
///
diff --git a/Source/Editor/GUI/Timeline/AnimationTimeline.cs b/Source/Editor/GUI/Timeline/AnimationTimeline.cs
index 331cb6f44..63329bfc0 100644
--- a/Source/Editor/GUI/Timeline/AnimationTimeline.cs
+++ b/Source/Editor/GUI/Timeline/AnimationTimeline.cs
@@ -130,9 +130,9 @@ namespace FlaxEditor.GUI.Timeline
public override void OnPlay()
{
var time = CurrentTime;
- _preview.Play();
if (_preview != null)
{
+ _preview.Play();
Editor.Internal_SetAnimationTime(Object.GetUnmanagedPtr(_preview.PreviewActor), time);
}
diff --git a/Source/Editor/GUI/Timeline/Undo/EditTrackAction.cs b/Source/Editor/GUI/Timeline/Undo/EditTrackAction.cs
index 0714b02e2..b03dc3d76 100644
--- a/Source/Editor/GUI/Timeline/Undo/EditTrackAction.cs
+++ b/Source/Editor/GUI/Timeline/Undo/EditTrackAction.cs
@@ -34,6 +34,8 @@ namespace FlaxEditor.GUI.Timeline.Undo
private void Set(byte[] data)
{
+ if (_timeline == null)
+ return;
var track = _timeline.FindTrack(_name);
using (var memory = new MemoryStream(data))
using (var stream = new BinaryReader(memory))
@@ -42,11 +44,8 @@ namespace FlaxEditor.GUI.Timeline.Undo
track.Flags = (TrackFlags)stream.ReadByte();
track.Archetype.Load(Timeline.FormatVersion, track, stream);
}
- if (_timeline != null)
- {
- _timeline.ArrangeTracks();
- _timeline.MarkAsEdited();
- }
+ _timeline.ArrangeTracks();
+ _timeline.MarkAsEdited();
track.OnUndo();
}
diff --git a/Source/Editor/States/LoadingState.cs b/Source/Editor/States/LoadingState.cs
index 93495f750..bc7984af9 100644
--- a/Source/Editor/States/LoadingState.cs
+++ b/Source/Editor/States/LoadingState.cs
@@ -57,8 +57,9 @@ namespace FlaxEditor.States
{
// Generate project files when Cache is missing or was cleared previously
var projectFolderPath = Editor.GameProject?.ProjectFolderPath;
- if (!Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Intermediate")) ||
- !Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Projects")))
+ if (!string.IsNullOrEmpty(projectFolderPath) &&
+ (!Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Intermediate")) ||
+ !Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Projects"))))
{
var customArgs = Editor.CodeEditing.SelectedEditor?.GenerateProjectCustomArgs;
ScriptsBuilder.GenerateProject(customArgs);
diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs
index 10f079579..936b68f04 100644
--- a/Source/Editor/Surface/SurfaceNode.cs
+++ b/Source/Editor/Surface/SurfaceNode.cs
@@ -976,10 +976,12 @@ namespace FlaxEditor.Surface
else
Array.Copy(values, Values, values.Length);
OnValuesChanged();
- Surface.MarkAsEdited(graphEdited);
if (Surface != null)
+ {
+ Surface.MarkAsEdited(graphEdited);
Surface.AddBatchedUndoAction(new EditNodeValuesAction(this, before, graphEdited));
+ }
_isDuringValuesEditing = false;
}
diff --git a/Source/Editor/Surface/VisjectSurface.Serialization.cs b/Source/Editor/Surface/VisjectSurface.Serialization.cs
index cbfcf1b20..646e1add5 100644
--- a/Source/Editor/Surface/VisjectSurface.Serialization.cs
+++ b/Source/Editor/Surface/VisjectSurface.Serialization.cs
@@ -62,7 +62,8 @@ namespace FlaxEditor.Surface
///
/// The method calls the setter to assign the result bytes. Sets null value if failed.
///
- public virtual void Save()
+ /// True if failed, otherwise false.
+ public virtual bool Save()
{
var wasEdited = IsEdited;
@@ -71,19 +72,16 @@ namespace FlaxEditor.Surface
_context.CachedSurfaceMeta.Scale = ViewScale;
// Save context (and every modified child context)
- bool failed = RootContext.Save();
-
- if (failed)
- {
- // Error
- return;
- }
+ if (RootContext.Save())
+ return true;
// Clear flag
if (wasEdited)
{
Owner.OnSurfaceEditedChanged();
}
+
+ return false;
}
}
}
diff --git a/Source/Editor/Windows/Assets/BehaviorTreeWindow.cs b/Source/Editor/Windows/Assets/BehaviorTreeWindow.cs
index d443fc166..47d6f2840 100644
--- a/Source/Editor/Windows/Assets/BehaviorTreeWindow.cs
+++ b/Source/Editor/Windows/Assets/BehaviorTreeWindow.cs
@@ -430,8 +430,7 @@ namespace FlaxEditor.Windows.Assets
private bool SaveSurface()
{
- _surface.Save();
- return false;
+ return _surface.Save();
}
private void SetCanEdit(bool canEdit)
diff --git a/Source/Editor/Windows/Assets/VisualScriptWindow.cs b/Source/Editor/Windows/Assets/VisualScriptWindow.cs
index 4a2cb74cf..a7201e81c 100644
--- a/Source/Editor/Windows/Assets/VisualScriptWindow.cs
+++ b/Source/Editor/Windows/Assets/VisualScriptWindow.cs
@@ -1202,7 +1202,8 @@ namespace FlaxEditor.Windows.Assets
private bool SaveSurface()
{
- _surface.Save();
+ if (_surface.Save())
+ return true;
// Reselect actors to prevent issues after Visual Script properties were modified
Editor.Windows.PropertiesWin.Presenter.BuildLayoutOnUpdate();
diff --git a/Source/Engine/UI/GUI/ContainerControl.cs b/Source/Engine/UI/GUI/ContainerControl.cs
index c53307c65..530663761 100644
--- a/Source/Engine/UI/GUI/ContainerControl.cs
+++ b/Source/Engine/UI/GUI/ContainerControl.cs
@@ -750,7 +750,7 @@ namespace FlaxEngine.GUI
{
if (base.IsTouchOver)
return true;
- for (int i = 0; i < _children.Count && _children.Count > 0; i++)
+ for (int i = 0; i < _children.Count; i++)
{
if (_children[i].IsTouchOver)
return true;
@@ -960,7 +960,7 @@ namespace FlaxEngine.GUI
public override void OnMouseLeave()
{
// Check all children collisions with mouse and fire events for them
- for (int i = 0; i < _children.Count && _children.Count > 0; i++)
+ for (int i = 0; i < _children.Count; i++)
{
var child = _children[i];
if (child.Visible && child.Enabled && child.IsMouseOver)
@@ -1063,7 +1063,7 @@ namespace FlaxEngine.GUI
if (base.IsTouchPointerOver(pointerId))
return true;
- for (int i = 0; i < _children.Count && _children.Count > 0; i++)
+ for (int i = 0; i < _children.Count; i++)
{
if (_children[i].IsTouchPointerOver(pointerId))
return true;
@@ -1168,7 +1168,7 @@ namespace FlaxEngine.GUI
///
public override void OnTouchLeave(int pointerId)
{
- for (int i = 0; i < _children.Count && _children.Count > 0; i++)
+ for (int i = 0; i < _children.Count; i++)
{
var child = _children[i];
if (child.Visible && child.Enabled && child.IsTouchPointerOver(pointerId))
@@ -1183,7 +1183,7 @@ namespace FlaxEngine.GUI
///
public override bool OnCharInput(char c)
{
- for (int i = 0; i < _children.Count && _children.Count > 0; i++)
+ for (int i = 0; i < _children.Count; i++)
{
var child = _children[i];
if (child.Enabled && child.ContainsFocus)
@@ -1197,7 +1197,7 @@ namespace FlaxEngine.GUI
///
public override bool OnKeyDown(KeyboardKeys key)
{
- for (int i = 0; i < _children.Count && _children.Count > 0; i++)
+ for (int i = 0; i < _children.Count; i++)
{
var child = _children[i];
if (child.Enabled && child.ContainsFocus)
@@ -1211,7 +1211,7 @@ namespace FlaxEngine.GUI
///
public override void OnKeyUp(KeyboardKeys key)
{
- for (int i = 0; i < _children.Count && _children.Count > 0; i++)
+ for (int i = 0; i < _children.Count; i++)
{
var child = _children[i];
if (child.Enabled && child.ContainsFocus)
@@ -1294,7 +1294,7 @@ namespace FlaxEngine.GUI
base.OnDragLeave();
// Check all children collisions with mouse and fire events for them
- for (int i = 0; i < _children.Count && _children.Count > 0; i++)
+ for (int i = 0; i < _children.Count; i++)
{
var child = _children[i];
if (child.IsDragOver)