diff --git a/Source/Editor/Modules/ContentDatabaseModule.cs b/Source/Editor/Modules/ContentDatabaseModule.cs
index 8c925930d..e6391d9b2 100644
--- a/Source/Editor/Modules/ContentDatabaseModule.cs
+++ b/Source/Editor/Modules/ContentDatabaseModule.cs
@@ -632,7 +632,8 @@ namespace FlaxEditor.Modules
/// Deletes the specified item.
///
/// The item.
- public void Delete(ContentItem item)
+ /// If the file was deleted by the user and not outside the editor.
+ public void Delete(ContentItem item, bool deletedByUser = false)
{
if (item == null)
throw new ArgumentNullException();
@@ -656,12 +657,12 @@ namespace FlaxEditor.Modules
var children = folder.Children.ToArray();
for (int i = 0; i < children.Length; i++)
{
- Delete(children[i]);
+ Delete(children[i], deletedByUser);
}
}
// Remove directory
- if (Directory.Exists(path))
+ if (deletedByUser && Directory.Exists(path))
{
try
{
@@ -689,7 +690,7 @@ namespace FlaxEditor.Modules
// Delete asset by using content pool
FlaxEngine.Content.DeleteAsset(path);
}
- else
+ else if (deletedByUser)
{
// Delete file
if (File.Exists(path))
@@ -835,7 +836,7 @@ namespace FlaxEditor.Modules
Editor.Log(string.Format($"Content item \'{child.Path}\' has been removed"));
// Destroy it
- Delete(child);
+ Delete(child, false);
i--;
}
diff --git a/Source/Editor/Modules/ContentEditingModule.cs b/Source/Editor/Modules/ContentEditingModule.cs
index f1bb81ce1..1a8920916 100644
--- a/Source/Editor/Modules/ContentEditingModule.cs
+++ b/Source/Editor/Modules/ContentEditingModule.cs
@@ -104,6 +104,12 @@ namespace FlaxEditor.Modules
hint = "Too long name.";
return false;
}
+
+ if (item.IsFolder && shortName.EndsWith("."))
+ {
+ hint = "Name cannot end with '.'";
+ return false;
+ }
// Find invalid characters
if (Utilities.Utils.HasInvalidPathChar(shortName))
@@ -134,7 +140,7 @@ namespace FlaxEditor.Modules
// Cache data
string sourcePath = item.Path;
string sourceFolder = System.IO.Path.GetDirectoryName(sourcePath);
- string extension = System.IO.Path.GetExtension(sourcePath);
+ string extension = item.IsFolder ? "" : System.IO.Path.GetExtension(sourcePath);
string destinationPath = StringUtils.CombinePaths(sourceFolder, shortName + extension);
if (item.IsFolder)
diff --git a/Source/Editor/Scripting/CodeEditors/RiderCodeEditor.cpp b/Source/Editor/Scripting/CodeEditors/RiderCodeEditor.cpp
index 3f285d159..05608d71e 100644
--- a/Source/Editor/Scripting/CodeEditors/RiderCodeEditor.cpp
+++ b/Source/Editor/Scripting/CodeEditors/RiderCodeEditor.cpp
@@ -24,7 +24,8 @@ namespace
String version;
RiderInstallation(const String& path_, const String& version_)
- : path(path_), version(version_)
+ : path(path_)
+ , version(version_)
{
}
};
@@ -145,14 +146,14 @@ bool sortInstallations(RiderInstallation* const& i1, RiderInstallation* const& i
int32 version2[3] = { 0 };
StringUtils::Parse(values1[0].Get(), &version1[0]);
StringUtils::Parse(values1[1].Get(), &version1[1]);
-
- if(values1.Count() > 2)
+
+ if (values1.Count() > 2)
StringUtils::Parse(values1[2].Get(), &version1[2]);
-
+
StringUtils::Parse(values2[0].Get(), &version2[0]);
StringUtils::Parse(values2[1].Get(), &version2[1]);
-
- if(values2.Count() > 2)
+
+ if (values2.Count() > 2)
StringUtils::Parse(values2[2].Get(), &version2[2]);
// Compare by MAJOR.MINOR.BUILD
@@ -178,7 +179,7 @@ void RiderCodeEditor::FindEditors(Array* output)
String localAppDataPath;
FileSystem::GetSpecialFolderPath(SpecialFolder::LocalAppData, localAppDataPath);
-
+
#if PLATFORM_WINDOWS
// Lookup from all known registry locations
SearchRegistry(&installations, HKEY_CURRENT_USER, TEXT("SOFTWARE\\WOW6432Node\\JetBrains\\Rider for Unreal Engine"));
@@ -216,7 +217,24 @@ void RiderCodeEditor::FindEditors(Array* output)
TEXT("flatpak run com.jetbrains.Rider"));
#endif
- for (auto directory : subDirectories)
+#if PLATFORM_MAC
+ String applicationSupportFolder;
+ FileSystem::GetSpecialFolderPath(SpecialFolder::ProgramData, applicationSupportFolder);
+
+ Array subMacDirectories;
+ FileSystem::GetChildDirectories(subMacDirectories, applicationSupportFolder / TEXT("JetBrains/Toolbox/apps/Rider/ch-0/"));
+ FileSystem::GetChildDirectories(subMacDirectories, applicationSupportFolder / TEXT("JetBrains/Toolbox/apps/Rider/ch-1/"));
+ for (const String& directory : subMacDirectories)
+ {
+ String riderAppDirectory = directory / TEXT("Rider.app/Contents/Resources");
+ SearchDirectory(&installations, riderAppDirectory);
+ }
+
+ // Check the local installer version
+ SearchDirectory(&installations, TEXT("/Applications/Rider.app/Contents/Resources"));
+#endif
+
+ for (const String& directory : subDirectories)
SearchDirectory(&installations, directory);
// Sort found installations by version number
diff --git a/Source/Editor/Surface/Archetypes/Math.cs b/Source/Editor/Surface/Archetypes/Math.cs
index 1b8f62e62..fe2f1e044 100644
--- a/Source/Editor/Surface/Archetypes/Math.cs
+++ b/Source/Editor/Surface/Archetypes/Math.cs
@@ -126,7 +126,7 @@ namespace FlaxEditor.Surface.Archetypes
Title = "Clamp",
Description = "Clamps value to the specified range",
Flags = NodeFlags.AllGraphs,
- Size = new Float2(110, 60),
+ Size = new Float2(140, 60),
ConnectionsHints = ConnectionsHint.Numeric,
IndependentBoxes = new[] { 0 },
DependentBoxes = new[] { 1, 2, 3 },
diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs
index 9390a4711..05a363abb 100644
--- a/Source/Editor/Windows/ContentWindow.cs
+++ b/Source/Editor/Windows/ContentWindow.cs
@@ -519,7 +519,7 @@ namespace FlaxEditor.Windows
}
// Cache data
- string extension = Path.GetExtension(item.Path);
+ string extension = item.IsFolder ? "" : Path.GetExtension(item.Path);
var newPath = StringUtils.CombinePaths(item.ParentFolder.Path, newShortName + extension);
// Check if was renaming mock element
@@ -625,7 +625,7 @@ namespace FlaxEditor.Windows
// Delete items
for (int i = 0; i < toDelete.Count; i++)
- Editor.ContentDatabase.Delete(toDelete[i]);
+ Editor.ContentDatabase.Delete(toDelete[i], true);
RefreshView();
}
diff --git a/Source/Engine/Content/Assets/MaterialInstance.cpp b/Source/Engine/Content/Assets/MaterialInstance.cpp
index 7581692e1..3bf0c54cd 100644
--- a/Source/Engine/Content/Assets/MaterialInstance.cpp
+++ b/Source/Engine/Content/Assets/MaterialInstance.cpp
@@ -205,8 +205,6 @@ void MaterialInstance::Bind(BindParameters& params)
Asset::LoadResult MaterialInstance::load()
{
- ASSERT(_baseMaterial == nullptr);
-
// Get main chunk
auto chunk0 = GetChunk(0);
if (chunk0 == nullptr || chunk0->IsMissing())
@@ -229,6 +227,7 @@ Asset::LoadResult MaterialInstance::load()
else
{
// Clear parameters if has no material loaded
+ _baseMaterial = nullptr;
Params.Dispose();
ParamsChanged();
}
diff --git a/Source/Engine/Core/Types/String.cpp b/Source/Engine/Core/Types/String.cpp
index e53f04af7..dab000873 100644
--- a/Source/Engine/Core/Types/String.cpp
+++ b/Source/Engine/Core/Types/String.cpp
@@ -72,7 +72,7 @@ void String::Set(const char* chars, int32 length)
}
_length = length;
}
- if (chars)
+ if (chars && length)
StringUtils::ConvertANSI2UTF16(chars, _data, length, _length);
}
@@ -298,8 +298,10 @@ String String::TrimTrailing() const
end--;
}
- ASSERT_LOW_LAYER(end >= start);
- return Substring(start, end - start + 1);
+ const int32 count = end - start + 1;
+ if (start >= 0 && start + count <= Length() && count >= 0)
+ return String(_data + start, count);
+ return Empty;
}
String& String::operator/=(const Char* str)
diff --git a/Source/Engine/Engine/NativeInterop.Marshallers.cs b/Source/Engine/Engine/NativeInterop.Marshallers.cs
index 74d6e6bad..a74299670 100644
--- a/Source/Engine/Engine/NativeInterop.Marshallers.cs
+++ b/Source/Engine/Engine/NativeInterop.Marshallers.cs
@@ -32,6 +32,7 @@ namespace FlaxEngine.Interop
public static class NativeToManaged
{
public static object ConvertToManaged(IntPtr unmanaged) => unmanaged == IntPtr.Zero ? null : ManagedHandle.FromIntPtr(unmanaged).Target;
+ public static IntPtr ConvertToUnmanaged(object managed) => managed != null ? ManagedHandle.ToIntPtr(managed, GCHandleType.Weak) : IntPtr.Zero;
public static void Free(IntPtr unmanaged)
{
@@ -44,6 +45,7 @@ namespace FlaxEngine.Interop
#endif
public static class ManagedToNative
{
+ public static object ConvertToManaged(IntPtr unmanaged) => unmanaged == IntPtr.Zero ? null : ManagedHandle.FromIntPtr(unmanaged).Target;
public static IntPtr ConvertToUnmanaged(object managed) => managed != null ? ManagedHandle.ToIntPtr(managed, GCHandleType.Weak) : IntPtr.Zero;
public static void Free(IntPtr unmanaged)
@@ -147,29 +149,16 @@ namespace FlaxEngine.Interop
#if FLAX_EDITOR
[HideInEditor]
#endif
- [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.ManagedToUnmanagedIn, typeof(ObjectMarshaller.ManagedToNative))]
- [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.UnmanagedToManagedOut, typeof(ObjectMarshaller.ManagedToNative))]
- [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.ElementIn, typeof(ObjectMarshaller.ManagedToNative))]
- [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.ManagedToUnmanagedOut, typeof(ObjectMarshaller.NativeToManaged))]
- [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.UnmanagedToManagedIn, typeof(ObjectMarshaller.NativeToManaged))]
- [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.ElementOut, typeof(ObjectMarshaller.NativeToManaged))]
+ [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.ManagedToUnmanagedIn, typeof(ObjectMarshaller))]
+ [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.UnmanagedToManagedOut, typeof(ObjectMarshaller))]
+ [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.ElementIn, typeof(ObjectMarshaller))]
+ [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.ManagedToUnmanagedOut, typeof(ObjectMarshaller))]
+ [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.UnmanagedToManagedIn, typeof(ObjectMarshaller))]
+ [CustomMarshaller(typeof(FlaxEngine.Object), MarshalMode.ElementOut, typeof(ObjectMarshaller))]
public static class ObjectMarshaller
{
-#if FLAX_EDITOR
- [HideInEditor]
-#endif
- public static class NativeToManaged
- {
- public static FlaxEngine.Object ConvertToManaged(IntPtr unmanaged) => unmanaged != IntPtr.Zero ? Unsafe.As(ManagedHandle.FromIntPtr(unmanaged).Target) : null;
- }
-
-#if FLAX_EDITOR
- [HideInEditor]
-#endif
- public static class ManagedToNative
- {
- public static IntPtr ConvertToUnmanaged(FlaxEngine.Object managed) => Unsafe.As