Merge remote-tracking branch 'origin/1.5' into dotnet7

This commit is contained in:
2023-01-02 10:37:04 +01:00
29 changed files with 543 additions and 143 deletions
+4 -1
View File
@@ -11,7 +11,10 @@ namespace FlaxEditor.Content
/// <seealso cref="FlaxEditor.Content.AssetItem" />
public class JsonAssetItem : AssetItem
{
private readonly SpriteHandle _thumbnail;
/// <summary>
/// Asset icon.
/// </summary>
protected SpriteHandle _thumbnail;
/// <summary>
/// Initializes a new instance of the <see cref="JsonAssetItem"/> class.
@@ -127,7 +127,7 @@ namespace FlaxEditor.Content
/// Generic Json assets proxy (supports all json assets that don't have dedicated proxy).
/// </summary>
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
public sealed class GenericJsonAssetProxy : JsonAssetProxy
public class GenericJsonAssetProxy : JsonAssetProxy
{
/// <inheritdoc />
public override string TypeName => typeof(JsonAsset).FullName;
@@ -161,7 +161,7 @@ namespace FlaxEditor.Content
/// Content proxy for a json assets of the given type that can be spawned in the editor.
/// </summary>
/// <seealso cref="FlaxEditor.Content.JsonAssetProxy" />
public sealed class SpawnableJsonAssetProxy<T> : JsonAssetProxy where T : new()
public class SpawnableJsonAssetProxy<T> : JsonAssetProxy where T : new()
{
/// <inheritdoc />
public override string Name { get; } = Utilities.Utils.GetPropertyNameUI(typeof(T).Name);
@@ -55,8 +55,8 @@ namespace FlaxEditor.CustomEditors.Editors
{
if (Values[0] is Tag asTag)
return asTag;
if (Values[0] is int asInt)
return new Tag(asInt);
if (Values[0] is uint asUInt)
return new Tag(asUInt);
if (Values[0] is string asString)
return Tags.Get(asString);
return Tag.Default;
@@ -65,7 +65,7 @@ namespace FlaxEditor.CustomEditors.Editors
{
if (Values[0] is Tag)
SetValue(value);
if (Values[0] is int)
if (Values[0] is uint)
SetValue(value.Index);
else if (Values[0] is string)
SetValue(value.ToString());
@@ -114,7 +114,7 @@ namespace FlaxEditor.CustomEditors.Editors
private static void GetTags(TreeNode n, PickerData pickerData)
{
if (n is TreeNodeWithAddons a && a.Addons.Count != 0 && a.Addons[0] is CheckBox c && c.Checked)
pickerData.CachedTags.Add(new Tag((int)n.Tag));
pickerData.CachedTags.Add((Tag)n.Tag);
foreach (var child in n.Children)
{
if (child is TreeNode treeNode)
@@ -139,7 +139,7 @@ namespace FlaxEditor.CustomEditors.Editors
if (pickerData.IsSingle)
{
UncheckAll(node.ParentTree, node);
var value = new Tag(c.Checked ? (int)node.Tag : -1);
var value = c.Checked ? (Tag)node.Tag : Tag.Default;
pickerData.SetValue?.Invoke(value);
pickerData.SetValues?.Invoke(new[] { value });
}
@@ -166,8 +166,8 @@ namespace FlaxEditor.CustomEditors.Editors
if (parentNode.CustomArrowRect.HasValue)
{
indentation = (int)((parentNode.CustomArrowRect.Value.Location.X - 18) / nodeIndent) + 1;
var parentIndex = (int)parentNode.Tag;
parentTag = Tags.List[parentIndex];
var parentTagValue = (Tag)parentNode.Tag;
parentTag = parentTagValue.ToString();
}
var node = new TreeNodeWithAddons
{
@@ -244,7 +244,7 @@ namespace FlaxEditor.CustomEditors.Editors
// Add tag
var tag = Tags.Get(tagName);
node.Text = name;
node.Tag = tag.Index;
node.Tag = tag;
var settingsAsset = GameSettings.LoadAsset<LayersAndTagsSettings>();
if (settingsAsset && !settingsAsset.WaitForLoaded())
{
@@ -283,7 +283,8 @@ namespace FlaxEditor.CustomEditors.Editors
for (var i = 0; i < tags.Length; i++)
{
var tag = tags[i];
bool isSelected = pickerData.IsSingle ? value.Index == i : values.Contains(new Tag(i));
var tagValue = new Tag((uint)(i + 1));
bool isSelected = pickerData.IsSingle ? value == tagValue : values.Contains(tagValue);
// Count parent tags count
int indentation = 0;
@@ -296,7 +297,7 @@ namespace FlaxEditor.CustomEditors.Editors
// Create node
var node = new TreeNodeWithAddons
{
Tag = i,
Tag = tagValue,
Text = tag,
ChildrenIndent = nodeIndent,
CullChildren = false,
+1
View File
@@ -1205,6 +1205,7 @@ namespace FlaxEditor
{
public byte AutoReloadScriptsOnMainWindowFocus;
public byte ForceScriptCompilationOnStartup;
public byte UseAssetImportPathRelative;
public byte AutoRebuildCSG;
public float AutoRebuildCSGTimeoutMs;
public byte AutoRebuildNavMesh;
@@ -356,10 +356,15 @@ namespace FlaxEditor.GUI.ContextMenu
private void OnWindowGotFocus()
{
if (_childCM != null && _window && _window.IsForegroundWindow)
var child = _childCM;
if (child != null && _window && _window.IsForegroundWindow)
{
// Hide child if user clicked over parent (do it next frame to process other events before - eg. child windows focus loss)
FlaxEngine.Scripting.InvokeOnUpdate(HideChild);
FlaxEngine.Scripting.InvokeOnUpdate(() =>
{
if (child == _childCM)
HideChild();
});
}
}
@@ -830,6 +830,9 @@ public:
{
SCRIPTING_EXPORT("FlaxEditor.Editor::Internal_SetOptions")
ManagedEditor::ManagedEditorOptions = *options;
// Apply options
AssetsImportingManager::UseImportPathRelative = ManagedEditor::ManagedEditorOptions.UseAssetImportPathRelative != 0;
}
static void DrawNavMesh()
+1
View File
@@ -26,6 +26,7 @@ public:
{
byte AutoReloadScriptsOnMainWindowFocus = 1;
byte ForceScriptCompilationOnStartup = 1;
byte UseAssetImportPathRelative = 1;
byte AutoRebuildCSG = 1;
float AutoRebuildCSGTimeoutMs = 50;
byte AutoRebuildNavMesh = 1;
+7
View File
@@ -148,6 +148,13 @@ namespace FlaxEditor.Options
[EditorDisplay("Scripting", "Auto Save Visual Script On Play Start"), EditorOrder(505), Tooltip("Determines whether automatically save the Visual Script asset editors when starting the play mode in editor.")]
public bool AutoSaveVisualScriptOnPlayStart { get; set; } = true;
/// <summary>
/// If checked, imported file path will be stored relative to the project folder within imported asset metadata. Otherwise will use absolute path.
/// </summary>
[DefaultValue(true)]
[EditorDisplay("Content"), EditorOrder(550)]
public bool UseAssetImportPathRelative { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether perform automatic CSG rebuild on brush change.
/// </summary>
+1
View File
@@ -186,6 +186,7 @@ namespace FlaxEditor.Options
Editor.InternalOptions internalOptions;
internalOptions.AutoReloadScriptsOnMainWindowFocus = (byte)(Options.General.AutoReloadScriptsOnMainWindowFocus ? 1 : 0);
internalOptions.ForceScriptCompilationOnStartup = (byte)(Options.General.ForceScriptCompilationOnStartup ? 1 : 0);
internalOptions.UseAssetImportPathRelative = (byte)(Options.General.UseAssetImportPathRelative ? 1 : 0);
internalOptions.AutoRebuildCSG = (byte)(Options.General.AutoRebuildCSG ? 1 : 0);
internalOptions.AutoRebuildCSGTimeoutMs = Options.General.AutoRebuildCSGTimeoutMs;
internalOptions.AutoRebuildNavMesh = (byte)(Options.General.AutoRebuildNavMesh ? 1 : 0);
+57 -44
View File
@@ -119,7 +119,8 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = IntegerValue.Get(box.ParentNode, box.Archetype, box.Value);
var control = new IntValueBox(value, bounds.X, bounds.Y, 40, int.MinValue, int.MaxValue, 0.01f)
var width = 40;
var control = new IntValueBox(value, bounds.X, bounds.Y, width + 12, int.MinValue, int.MaxValue, 0.01f)
{
Height = bounds.Height,
Parent = box.Parent,
@@ -164,7 +165,8 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = UnsignedIntegerValue.Get(box.ParentNode, box.Archetype, box.Value);
var control = new UIntValueBox(value, bounds.X, bounds.Y, 40, uint.MinValue, uint.MaxValue, 0.01f)
var width = 40;
var control = new UIntValueBox(value, bounds.X, bounds.Y, width + 12, uint.MinValue, uint.MaxValue, 0.01f)
{
Height = bounds.Height,
Parent = box.Parent,
@@ -209,7 +211,8 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = FloatValue.Get(box.ParentNode, box.Archetype, box.Value);
var control = new FloatValueBox(value, bounds.X, bounds.Y, 40, float.MinValue, float.MaxValue, 0.01f)
var width = 40;
var control = new FloatValueBox(value, bounds.X, bounds.Y, width + 12, float.MinValue, float.MaxValue, 0.01f)
{
Height = bounds.Height,
Parent = box.Parent,
@@ -254,7 +257,7 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = box.Value as string;
var control = new TextBox(false, bounds.X, bounds.Y, 40)
var control = new TextBox(false, bounds.X, bounds.Y, 50)
{
Text = value,
Height = bounds.Height,
@@ -299,20 +302,21 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 2 - 2, bounds.Height)
var width = 30;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 2 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new RealValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new RealValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new RealValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new RealValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -372,26 +376,27 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 3 - 2, bounds.Height)
var width = 30;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 3 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new RealValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new RealValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new RealValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new RealValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatY.BoxValueChanged += OnValueChanged;
var floatZ = new RealValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatZ = new RealValueBox(value.Z, width * 2 + 4, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -454,32 +459,33 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 4 - 2, bounds.Height)
var width = 20;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 4 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new RealValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new RealValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new RealValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new RealValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatY.BoxValueChanged += OnValueChanged;
var floatZ = new RealValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatZ = new RealValueBox(value.Z, width * 2 + 4, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatZ.BoxValueChanged += OnValueChanged;
var floatW = new RealValueBox(value.W, 66, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatW = new RealValueBox(value.W, width * 3 + 6, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -546,20 +552,21 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 2 - 2, bounds.Height)
var width = 30;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 2 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new FloatValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new FloatValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -619,26 +626,27 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 3 - 2, bounds.Height)
var width = 30;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 3 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new FloatValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new FloatValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatY.BoxValueChanged += OnValueChanged;
var floatZ = new FloatValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatZ = new FloatValueBox(value.Z, width * 2 + 4, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -701,32 +709,33 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 4 - 2, bounds.Height)
var width = 20;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 4 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new FloatValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new FloatValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatY.BoxValueChanged += OnValueChanged;
var floatZ = new FloatValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatZ = new FloatValueBox(value.Z, width * 2 + 4, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatZ.BoxValueChanged += OnValueChanged;
var floatW = new FloatValueBox(value.W, 66, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatW = new FloatValueBox(value.W, width * 3 + 6, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -793,20 +802,21 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 2 - 2, bounds.Height)
var width = 30;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 2 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new DoubleValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new DoubleValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new DoubleValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new DoubleValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -866,26 +876,27 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 3 - 2, bounds.Height)
var width = 30;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 3 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new DoubleValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new DoubleValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new DoubleValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new DoubleValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatY.BoxValueChanged += OnValueChanged;
var floatZ = new DoubleValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatZ = new DoubleValueBox(value.Z, width * 2 + 4, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -948,32 +959,33 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box);
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 4 - 2, bounds.Height)
var width = 20;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 4 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new DoubleValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new DoubleValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new DoubleValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new DoubleValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatY.BoxValueChanged += OnValueChanged;
var floatZ = new DoubleValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatZ = new DoubleValueBox(value.Z, width * 2 + 4, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatZ.BoxValueChanged += OnValueChanged;
var floatW = new DoubleValueBox(value.W, 66, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatW = new DoubleValueBox(value.W, width * 3 + 6, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
@@ -1040,26 +1052,27 @@ namespace FlaxEditor.Surface.Elements
public Control Create(InputBox box, ref Rectangle bounds)
{
var value = GetValue(box).EulerAngles;
var control = new ContainerControl(bounds.X, bounds.Y, 22 * 3 - 2, bounds.Height)
var width = 20;
var control = new ContainerControl(bounds.X, bounds.Y, (width + 2) * 3 - 2, bounds.Height)
{
ClipChildren = false,
AutoFocus = false,
Parent = box.Parent,
Tag = box,
};
var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatX = new FloatValueBox(value.X, 0, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatX.BoxValueChanged += OnValueChanged;
var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatY = new FloatValueBox(value.Y, width + 2, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
};
floatY.BoxValueChanged += OnValueChanged;
var floatZ = new FloatValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
var floatZ = new FloatValueBox(value.Z, width * 2 + 4, 0, width, float.MinValue, float.MaxValue, 0.0f)
{
Height = bounds.Height,
Parent = control,
+1 -10
View File
@@ -147,17 +147,8 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
Apply(ref p);
}
var editorOptions = Editor.Instance.Options.Options;
bool isPlayMode = Editor.Instance.StateMachine.IsPlayMode;
// Auto NavMesh rebuild
if (!isPlayMode && editorOptions.General.AutoRebuildNavMesh)
{
if (terrain.Scene && terrain.HasStaticFlag(StaticFlags.Navigation))
{
Navigation.BuildNavMesh(terrain.Scene, brushBounds, editorOptions.General.AutoRebuildNavMeshTimeoutMs);
}
}
gizmo.CurrentEditUndoAction.AddDirtyBounds(ref brushBounds);
}
/// <summary>
@@ -41,33 +41,24 @@ namespace FlaxEditor.Tools.Terrain.Undo
public object Tag;
}
/// <summary>
/// The terrain (actor Id).
/// </summary>
[Serialize]
protected readonly Guid _terrain;
/// <summary>
/// The heightmap length (vertex count).
/// </summary>
[Serialize]
protected readonly int _heightmapLength;
/// <summary>
/// The heightmap data size (in bytes).
/// </summary>
[Serialize]
protected readonly int _heightmapDataSize;
/// <summary>
/// The terrain patches
/// </summary>
[Serialize]
protected readonly List<PatchData> _patches;
/// <summary>
/// Gets a value indicating whether this action has any modification to the terrain (recorded patches changes).
/// </summary>
[Serialize]
protected readonly List<BoundingBox> _navmeshBoundsModifications;
[Serialize]
protected readonly float _dirtyNavMeshTimeoutMs;
[NoSerialize]
public bool HasAnyModification => _patches.Count > 0;
@@ -98,6 +89,27 @@ namespace FlaxEditor.Tools.Terrain.Undo
var heightmapSize = chunkSize * FlaxEngine.Terrain.PatchEdgeChunksCount + 1;
_heightmapLength = heightmapSize * heightmapSize;
_heightmapDataSize = _heightmapLength * stride;
// Auto NavMesh rebuild
var editorOptions = Editor.Instance.Options.Options;
bool isPlayMode = Editor.Instance.StateMachine.IsPlayMode;
if (!isPlayMode && editorOptions.General.AutoRebuildNavMesh)
{
if (terrain.Scene && terrain.HasStaticFlag(StaticFlags.Navigation))
{
_navmeshBoundsModifications = new List<BoundingBox>();
_dirtyNavMeshTimeoutMs = editorOptions.General.AutoRebuildNavMeshTimeoutMs;
}
}
}
/// <summary>
/// Adds modified bounds to the undo actor modifications list.
/// </summary>
/// <param name="bounds">The world-space bounds.</param>
public void AddDirtyBounds(ref BoundingBox bounds)
{
_navmeshBoundsModifications?.Add(bounds);
}
/// <summary>
@@ -155,7 +167,15 @@ namespace FlaxEditor.Tools.Terrain.Undo
_patches[i] = patch;
}
Editor.Instance.Scene.MarkSceneEdited(Terrain.Scene);
// Update navmesh
var scene = Terrain.Scene;
if (_navmeshBoundsModifications != null)
{
foreach (var bounds in _navmeshBoundsModifications)
Navigation.BuildNavMesh(scene, bounds, _dirtyNavMeshTimeoutMs);
}
Editor.Instance.Scene.MarkSceneEdited(scene);
}
/// <inheritdoc />
@@ -183,10 +203,12 @@ namespace FlaxEditor.Tools.Terrain.Undo
Marshal.FreeHGlobal(_patches[i].After);
}
_patches.Clear();
_navmeshBoundsModifications?.Clear();
}
private void Set(Func<PatchData, IntPtr> dataGetter)
{
// Update patches
for (int i = 0; i < _patches.Count; i++)
{
var patch = _patches[i];
@@ -194,6 +216,14 @@ namespace FlaxEditor.Tools.Terrain.Undo
SetData(ref patch.PatchCoord, data, patch.Tag);
}
// Update navmesh
var scene = Terrain.Scene;
if (_navmeshBoundsModifications != null)
{
foreach (var bounds in _navmeshBoundsModifications)
Navigation.BuildNavMesh(scene, bounds, _dirtyNavMeshTimeoutMs);
}
Editor.Instance.Scene.MarkSceneEdited(Terrain.Scene);
}
@@ -155,7 +155,7 @@ namespace FlaxEditor.Windows
var scriptType = new ScriptType(typeof(Script));
foreach (var type in Editor.CodeEditing.All.Get())
{
if (type.IsAbstract)
if (type.IsAbstract || type.Type == null)
continue;
if (actorType.IsAssignableFrom(type) || scriptType.IsAssignableFrom(type))
continue;