diff --git a/Source/Editor/GUI/MainMenu.cs b/Source/Editor/GUI/MainMenu.cs index bf375a358..650f7737a 100644 --- a/Source/Editor/GUI/MainMenu.cs +++ b/Source/Editor/GUI/MainMenu.cs @@ -19,6 +19,7 @@ namespace FlaxEditor.GUI private Button _closeButton; private Button _minimizeButton; private Button _maximizeButton; + private LocalizedString _charChromeRestore, _charChromeMaximize; private Window _window; #endif private MainMenuButton _selected; @@ -151,14 +152,12 @@ namespace FlaxEditor.GUI _maximizeButton.Clicked += () => { if (_window.IsMaximized) - { _window.Restore(); - } else - { _window.Maximize(); - } }; + _charChromeRestore = ((char)EditorAssets.SegMDL2Icons.ChromeRestore).ToString(); + _charChromeMaximize = ((char)EditorAssets.SegMDL2Icons.ChromeMaximize).ToString(); } else #endif @@ -175,7 +174,7 @@ namespace FlaxEditor.GUI if (_maximizeButton != null) { - _maximizeButton.Text = ((char)(_window.IsMaximized ? EditorAssets.SegMDL2Icons.ChromeRestore : EditorAssets.SegMDL2Icons.ChromeMaximize)).ToString(); + _maximizeButton.Text = _window.IsMaximized ? _charChromeRestore : _charChromeMaximize; } } diff --git a/Source/Engine/Engine/Engine.cpp b/Source/Engine/Engine/Engine.cpp index 0bc79573e..a5fd460fb 100644 --- a/Source/Engine/Engine/Engine.cpp +++ b/Source/Engine/Engine/Engine.cpp @@ -10,18 +10,11 @@ #include "FlaxEngine.Gen.h" #include "Engine/Core/Core.h" #include "Engine/Core/Log.h" -#include "Engine/Core/Utilities.h" #include "Engine/Core/ObjectsRemovalService.h" #include "Engine/Core/Types/String.h" #include "Engine/Platform/Platform.h" -#include "Engine/Platform/CPUInfo.h" -#include "Engine/Platform/MemoryStats.h" #include "Engine/Platform/Window.h" #include "Engine/Platform/FileSystem.h" -#include "Engine/Serialization/FileWriteStream.h" -#include "Engine/Serialization/FileReadStream.h" -#include "Engine/Level/Level.h" -#include "Engine/Renderer/Renderer.h" #include "Engine/Physics/Physics.h" #include "Engine/Threading/Threading.h" #include "Engine/Threading/MainThreadTask.h" diff --git a/Source/Engine/Graphics/RenderTask.cs b/Source/Engine/Graphics/RenderTask.cs index 5b6e2a1a7..11517c097 100644 --- a/Source/Engine/Graphics/RenderTask.cs +++ b/Source/Engine/Graphics/RenderTask.cs @@ -60,15 +60,7 @@ namespace FlaxEngine private static List _postFx; private static IntPtr[] _postFxPtr; - private static readonly PostFxComparer _postFxComparer = new PostFxComparer(); - - internal sealed class PostFxComparer : IComparer - { - public int Compare(PostProcessEffect x, PostProcessEffect y) - { - return x.Order - y.Order; - } - } + private static Comparison _postFxComparison = (x, y) => x.Order - y.Order; internal IntPtr[] GetPostFx(out int count) { @@ -103,7 +95,7 @@ namespace FlaxEngine } // Sort postFx - _postFx.Sort(_postFxComparer); + _postFx.Sort(_postFxComparison); // Convert into unmanaged objects count = _postFx.Count; diff --git a/Source/Engine/Scripting/InternalCalls/EngineInternalCalls.cpp b/Source/Engine/Scripting/InternalCalls/EngineInternalCalls.cpp index 144eb6c86..050fbca3a 100644 --- a/Source/Engine/Scripting/InternalCalls/EngineInternalCalls.cpp +++ b/Source/Engine/Scripting/InternalCalls/EngineInternalCalls.cpp @@ -12,6 +12,15 @@ namespace UtilsInternal { Platform::MemoryCopy(destination, source, length); } + + MonoObject* ExtractArrayFromList(MonoObject* obj) + { + auto klass = mono_object_get_class(obj); + auto field = mono_class_get_field_from_name(klass, "_items"); + MonoObject* o; + mono_field_get_value(obj, field, &o); + return o; + } } namespace DebugLogHandlerInternal @@ -70,6 +79,7 @@ void registerFlaxEngineInternalCalls() { AnimGraphExecutor::initRuntime(); ADD_INTERNAL_CALL("FlaxEngine.Utils::MemoryCopy", &UtilsInternal::MemoryCopy); + ADD_INTERNAL_CALL("FlaxEngine.Utils::Internal_ExtractArrayFromList", &UtilsInternal::ExtractArrayFromList); ADD_INTERNAL_CALL("FlaxEngine.DebugLogHandler::Internal_LogWrite", &DebugLogHandlerInternal::LogWrite); ADD_INTERNAL_CALL("FlaxEngine.DebugLogHandler::Internal_Log", &DebugLogHandlerInternal::Log); ADD_INTERNAL_CALL("FlaxEngine.DebugLogHandler::Internal_LogException", &DebugLogHandlerInternal::LogException); diff --git a/Source/Engine/Utilities/Utils.cs b/Source/Engine/Utilities/Utils.cs index ab4fdf17b..52b800f90 100644 --- a/Source/Engine/Utilities/Utils.cs +++ b/Source/Engine/Utilities/Utils.cs @@ -180,16 +180,12 @@ namespace FlaxEngine internal static T[] ExtractArrayFromList(List list) { - T[] result = null; - if (list != null) - { - // TODO: move it to the native code - var field = list.GetType().GetField("_items", BindingFlags.Instance | BindingFlags.NonPublic); - result = (T[])field.GetValue(list); - } - return result; + return list != null ? (T[])Internal_ExtractArrayFromList(list) : null; } + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern Array Internal_ExtractArrayFromList(object list); + /// /// Reads the color from the binary stream. /// @@ -249,7 +245,7 @@ namespace FlaxEngine { return new Int2(stream.ReadInt32(), stream.ReadInt32()); } - + /// /// Reads the Int3 from the binary stream. /// @@ -259,7 +255,7 @@ namespace FlaxEngine { return new Int3(stream.ReadInt32(), stream.ReadInt32(), stream.ReadInt32()); } - + /// /// Reads the Int4 from the binary stream. /// @@ -269,7 +265,7 @@ namespace FlaxEngine { return new Int4(stream.ReadInt32(), stream.ReadInt32(), stream.ReadInt32(), stream.ReadInt32()); } - + /// /// Reads the Quaternion from the binary stream. /// @@ -402,7 +398,7 @@ namespace FlaxEngine stream.Write(value.X); stream.Write(value.Y); } - + /// /// Writes the Int3 to the binary stream. ///