From ce1b47979eac7f37218f491cc29b7a350671e4b5 Mon Sep 17 00:00:00 2001 From: Wiktor Kocielski Date: Sun, 23 Apr 2023 14:31:05 +0300 Subject: [PATCH 01/16] Typo fixes --- Source/Engine/Level/Actor.h | 2 +- Source/Engine/Level/Types.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h index c1d038783..53427ab52 100644 --- a/Source/Engine/Level/Actor.h +++ b/Source/Engine/Level/Actor.h @@ -379,7 +379,7 @@ public: } /// - /// Gets the actor static fags. + /// Gets the actor static flags. /// API_PROPERTY(Attributes="NoAnimate, EditorDisplay(\"General\"), EditorOrder(-80), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.ActorStaticFlagsEditor\")") FORCE_INLINE StaticFlags GetStaticFlags() const diff --git a/Source/Engine/Level/Types.h b/Source/Engine/Level/Types.h index 9a29fde6e..a9938658b 100644 --- a/Source/Engine/Level/Types.h +++ b/Source/Engine/Level/Types.h @@ -100,7 +100,7 @@ API_ENUM(Attributes="Flags") enum class StaticFlags Navigation = 1 << 3, /// - /// Objects is fully static on the scene. + /// Object is fully static in the scene. /// FullyStatic = Transform | ReflectionProbe | Lightmap | Navigation, From 309302c212a0beba54fbe7a86ad07ffbcba6421d Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:00:26 -0400 Subject: [PATCH 02/16] improv: set new material instance name to parent material name --- Source/Editor/Content/Proxy/MaterialProxy.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Content/Proxy/MaterialProxy.cs b/Source/Editor/Content/Proxy/MaterialProxy.cs index 9cbd54975..c6a9755fc 100644 --- a/Source/Editor/Content/Proxy/MaterialProxy.cs +++ b/Source/Editor/Content/Proxy/MaterialProxy.cs @@ -75,8 +75,9 @@ namespace FlaxEditor.Content if (materialItem == null) throw new ArgumentNullException(); + var materialInstanceName = materialItem.FileName.Replace(".flax", " Instance"); var materialInstanceProxy = Editor.Instance.ContentDatabase.GetProxy(); - Editor.Instance.Windows.ContentWin.NewItem(materialInstanceProxy, null, item => OnMaterialInstanceCreated(item, materialItem)); + Editor.Instance.Windows.ContentWin.NewItem(materialInstanceProxy, null, item => OnMaterialInstanceCreated(item, materialItem), materialInstanceName); } private static void OnMaterialInstanceCreated(ContentItem item, BinaryAssetItem materialItem) From 0b3259fcc34bd423b1eb9b0c954ed0027761077d Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 24 Apr 2023 11:02:44 -0500 Subject: [PATCH 03/16] Increase size of add node so that vector3 fits correctly --- Source/Editor/Surface/Archetypes/Math.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Surface/Archetypes/Math.cs b/Source/Editor/Surface/Archetypes/Math.cs index d2aef9ae5..1b8f62e62 100644 --- a/Source/Editor/Surface/Archetypes/Math.cs +++ b/Source/Editor/Surface/Archetypes/Math.cs @@ -47,7 +47,7 @@ namespace FlaxEditor.Surface.Archetypes Description = desc, Flags = NodeFlags.AllGraphs, AlternativeTitles = altTitles, - Size = new Float2(140, 40), + Size = new Float2(150, 40), DefaultType = new ScriptType(inputType), ConnectionsHints = hints, IndependentBoxes = new[] { 0, 1 }, From 6aaa5832a826f292f48d54eec4221966d1acb728 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 26 Apr 2023 14:59:36 +0200 Subject: [PATCH 04/16] Fix crash when updating GPU texture residency to 0 --- Source/Engine/GraphicsDevice/DirectX/DX11/GPUTextureDX11.cpp | 5 +++-- Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUTextureDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUTextureDX11.cpp index 19b42074f..73be91108 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUTextureDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUTextureDX11.cpp @@ -133,8 +133,9 @@ void GPUTextureDX11::OnResidentMipsChanged() srDesc.Texture2D.MostDetailedMip = firstMipIndex; srDesc.Texture2D.MipLevels = mipLevels; } - ID3D11ShaderResourceView* srView; - VALIDATE_DIRECTX_RESULT(_device->GetDevice()->CreateShaderResourceView(_resource, &srDesc, &srView)); + ID3D11ShaderResourceView* srView = nullptr; + if (mipLevels != 0) + VALIDATE_DIRECTX_RESULT(_device->GetDevice()->CreateShaderResourceView(_resource, &srDesc, &srView)); GPUTextureViewDX11& view = IsVolume() ? _handleVolume : _handlesPerSlice[0]; if (view.GetParent() == nullptr) view.Init(this, nullptr, srView, nullptr, nullptr, Format(), MultiSampleLevel()); diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp index fb8642c86..dd7402097 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp @@ -240,7 +240,8 @@ void GPUTextureDX12::OnResidentMipsChanged() GPUTextureViewDX12& view = IsVolume() ? _handleVolume : _handlesPerSlice[0]; if (view.GetParent() == nullptr) view.Init(this, _device, this, Format(), MultiSampleLevel()); - view.SetSRV(srDesc); + if (mipLevels != 0) + view.SetSRV(srDesc); } void GPUTextureDX12::OnReleaseGPU() From 1978cb6df96029da6162c8eba3ee1b0845d6c1e6 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 28 Apr 2023 08:48:13 -0500 Subject: [PATCH 05/16] Fix bug with not deleting all children on folder delete --- Source/Editor/Modules/ContentDatabaseModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Modules/ContentDatabaseModule.cs b/Source/Editor/Modules/ContentDatabaseModule.cs index e5b2efee3..5e3b722b9 100644 --- a/Source/Editor/Modules/ContentDatabaseModule.cs +++ b/Source/Editor/Modules/ContentDatabaseModule.cs @@ -655,7 +655,7 @@ namespace FlaxEditor.Modules var children = folder.Children.ToArray(); for (int i = 0; i < children.Length; i++) { - Delete(children[0]); + Delete(children[i]); } } From 6d7e23f25480a9cb90ac3836d6605285eeb5f140 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 29 Apr 2023 13:05:06 +0200 Subject: [PATCH 06/16] Fix text wrapping regression --- Source/Engine/Render2D/Font.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Source/Engine/Render2D/Font.cpp b/Source/Engine/Render2D/Font.cpp index 45798dec4..b026e2d80 100644 --- a/Source/Engine/Render2D/Font.cpp +++ b/Source/Engine/Render2D/Font.cpp @@ -201,25 +201,29 @@ void Font::ProcessText(const StringView& text, Array& outputLines moveLine = true; if (lastWhitespaceIndex != INVALID_INDEX) { - // Back cursorX = lastWhitespaceX; tmpLine.LastCharIndex = lastWhitespaceIndex - 1; - currentIndex = lastWhitespaceIndex + 1; - nextCharIndex = currentIndex; + nextCharIndex = currentIndex = lastWhitespaceIndex + 1; } else if (lastUpperIndex != INVALID_INDEX) { + // Skip moving twice for the same character + if (outputLines.HasItems() && outputLines.Last().LastCharIndex == lastUpperIndex - 1) + { + currentIndex = nextCharIndex; + lastMoveLine = moveLine; + continue; + } + cursorX = lastUpperX; tmpLine.LastCharIndex = lastUpperIndex - 1; - currentIndex = lastUpperIndex + 1; - nextCharIndex = currentIndex; + nextCharIndex = currentIndex = lastUpperIndex; } else if (lastUnderscoreIndex != INVALID_INDEX) { cursorX = lastUnderscoreX; - tmpLine.LastCharIndex = lastUnderscoreIndex; - currentIndex = lastUnderscoreIndex + 1; - nextCharIndex = currentIndex; + tmpLine.LastCharIndex = lastUnderscoreIndex - 2; + nextCharIndex = currentIndex = lastUnderscoreIndex + 1; } else { From 299ca398fa0a187972340ec545e56b17405ff220 Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:44:54 -0400 Subject: [PATCH 07/16] small change in particle window --- Source/Editor/Windows/Assets/ParticleSystemWindow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Windows/Assets/ParticleSystemWindow.cs b/Source/Editor/Windows/Assets/ParticleSystemWindow.cs index 814978858..0b59dc86c 100644 --- a/Source/Editor/Windows/Assets/ParticleSystemWindow.cs +++ b/Source/Editor/Windows/Assets/ParticleSystemWindow.cs @@ -156,14 +156,14 @@ namespace FlaxEditor.Windows.Assets private bool HasEmitter => _track.Asset != null; - [EditorDisplay("Particle Emitter"), VisibleIf("HasEmitter"), EditorOrder(200), Tooltip("The start frame of the media event.")] + [EditorDisplay("Particle Emitter"), VisibleIf(nameof(HasEmitter)), EditorOrder(200), Tooltip("The start frame of the media event.")] public int StartFrame { get => _track.Media.Count > 0 ? _track.TrackMedia.StartFrame : 0; set => _track.TrackMedia.StartFrame = value; } - [EditorDisplay("Particle Emitter"), Limit(1), VisibleIf("HasEmitter"), EditorOrder(300), Tooltip("The total duration of the media event in the timeline sequence frames amount.")] + [EditorDisplay("Particle Emitter"), Limit(1), VisibleIf(nameof(HasEmitter)), EditorOrder(300), Tooltip("The total duration of the media event in the timeline sequence frames amount.")] public int DurationFrames { get => _track.Media.Count > 0 ? _track.TrackMedia.DurationFrames : 0; From cfefe7a24c9326da2e34f6759309319612851c9f Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Sun, 30 Apr 2023 11:06:58 -0400 Subject: [PATCH 08/16] add == operator on Actors --- Source/Engine/Level/Actor.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Source/Engine/Level/Actor.cs b/Source/Engine/Level/Actor.cs index bd005d415..7ff6622b3 100644 --- a/Source/Engine/Level/Actor.cs +++ b/Source/Engine/Level/Actor.cs @@ -357,5 +357,27 @@ namespace FlaxEngine { return $"{Name} ({GetType().Name})"; } + + /// + /// Check if Actors are equals + /// + /// + /// + /// + public static bool operator ==(Actor left, Actor right) + { + return Object.Equals(left, right); + } + + /// + /// Check if Actors aren't equals + /// + /// + /// + /// + public static bool operator !=(Actor left, Actor right) + { + return !Object.Equals(left, right); + } } } From 176f95fbbc569fe75133cf1a181c22b5caf3087f Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Sun, 30 Apr 2023 14:25:41 -0400 Subject: [PATCH 09/16] move == operator from Actor class to Object class --- Source/Engine/Level/Actor.cs | 22 ---------------------- Source/Engine/Scripting/Object.cs | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Source/Engine/Level/Actor.cs b/Source/Engine/Level/Actor.cs index 7ff6622b3..bd005d415 100644 --- a/Source/Engine/Level/Actor.cs +++ b/Source/Engine/Level/Actor.cs @@ -357,27 +357,5 @@ namespace FlaxEngine { return $"{Name} ({GetType().Name})"; } - - /// - /// Check if Actors are equals - /// - /// - /// - /// - public static bool operator ==(Actor left, Actor right) - { - return Object.Equals(left, right); - } - - /// - /// Check if Actors aren't equals - /// - /// - /// - /// - public static bool operator !=(Actor left, Actor right) - { - return !Object.Equals(left, right); - } } } diff --git a/Source/Engine/Scripting/Object.cs b/Source/Engine/Scripting/Object.cs index 227fe99e6..e895b8199 100644 --- a/Source/Engine/Scripting/Object.cs +++ b/Source/Engine/Scripting/Object.cs @@ -205,6 +205,30 @@ namespace FlaxEngine return obj != null && obj.__unmanagedPtr != IntPtr.Zero; } + /// + /// + /// + /// + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool operator == (Object left, Object right) + { + return Object.Equals(left, right); + } + + /// + /// + /// + /// + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool operator !=(Object left, Object right) + { + return !Object.Equals(left, right); + } + /// /// Gets the pointer to the native object. Handles null object reference (returns zero). /// From c900b6525db3434bcfbaeb957732f15eac437ec5 Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Sun, 30 Apr 2023 14:30:08 -0400 Subject: [PATCH 10/16] forgot to save the XD file --- Source/Engine/Scripting/Object.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Scripting/Object.cs b/Source/Engine/Scripting/Object.cs index e895b8199..ce7846d73 100644 --- a/Source/Engine/Scripting/Object.cs +++ b/Source/Engine/Scripting/Object.cs @@ -206,7 +206,7 @@ namespace FlaxEngine } /// - /// + /// Checks whether the two objects are equal. /// /// /// @@ -218,7 +218,7 @@ namespace FlaxEngine } /// - /// + /// Checks whether the two objects are not equal. /// /// /// From 518ce457dff817d080cdca14fe93e3aa72fa8b86 Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Tue, 2 May 2023 08:56:18 -0400 Subject: [PATCH 11/16] fix doc --- Source/Editor/CustomEditors/Elements/ComboBoxElement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/Elements/ComboBoxElement.cs b/Source/Editor/CustomEditors/Elements/ComboBoxElement.cs index b9bda5985..3e3f34e07 100644 --- a/Source/Editor/CustomEditors/Elements/ComboBoxElement.cs +++ b/Source/Editor/CustomEditors/Elements/ComboBoxElement.cs @@ -6,7 +6,7 @@ using FlaxEngine.GUI; namespace FlaxEditor.CustomEditors.Elements { /// - /// The combobx element. + /// The combobox element. /// /// public class ComboBoxElement : LayoutElement From f0da221621fc531483a5d37f3bf816cf421c5e00 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 2 May 2023 21:44:00 -0500 Subject: [PATCH 12/16] Make the drag indicator between tree nodes a little brighter. --- Source/Editor/GUI/Tree/TreeNode.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Editor/GUI/Tree/TreeNode.cs b/Source/Editor/GUI/Tree/TreeNode.cs index 8691cd14d..ced70a281 100644 --- a/Source/Editor/GUI/Tree/TreeNode.cs +++ b/Source/Editor/GUI/Tree/TreeNode.cs @@ -661,17 +661,20 @@ namespace FlaxEditor.GUI.Tree // Draw drag and drop effect if (IsDragOver && _tree.DraggedOverNode == this) { - Color dragOverColor = style.BackgroundSelected * 0.6f; + Color dragOverColor = style.BackgroundSelected; Rectangle rect; switch (_dragOverMode) { case DragItemPositioning.At: + dragOverColor *= 0.6f; rect = textRect; break; case DragItemPositioning.Above: + dragOverColor *= 1.2f; rect = new Rectangle(textRect.X, textRect.Top - DefaultDragInsertPositionMargin - DefaultNodeOffsetY - _margin.Top, textRect.Width, DefaultDragInsertPositionMargin * 2.0f); break; case DragItemPositioning.Below: + dragOverColor *= 1.2f; rect = new Rectangle(textRect.X, textRect.Bottom + _margin.Bottom - DefaultDragInsertPositionMargin, textRect.Width, DefaultDragInsertPositionMargin * 2.0f); break; default: From 144287ba1c4ea1c222eeae29e9dc2c02191cf943 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 3 May 2023 20:38:55 -0500 Subject: [PATCH 13/16] Add `Unload all but this scene` option to scene context menu to unload all of the active scenes except for the selected one. --- Source/Editor/Modules/SceneModule.cs | 36 ++++++++++++++++++++ Source/Editor/SceneGraph/Actors/SceneNode.cs | 7 ++++ 2 files changed, 43 insertions(+) diff --git a/Source/Editor/Modules/SceneModule.cs b/Source/Editor/Modules/SceneModule.cs index 4d1aee93e..0a51038ac 100644 --- a/Source/Editor/Modules/SceneModule.cs +++ b/Source/Editor/Modules/SceneModule.cs @@ -315,6 +315,42 @@ namespace FlaxEditor.Modules Editor.StateMachine.ChangingScenesState.UnloadScene(Level.Scenes); } + /// + /// Closes all of the scenes except for the specified scene (async). + /// + /// The scene to not close. + public void CloseAllScenesExcept(Scene scene) + { + // Check if cannot change scene now + if (!Editor.StateMachine.CurrentState.CanChangeScene) + return; + + var scenes = new List(); + foreach (var s in Level.Scenes) + { + if (s == scene) + continue; + scenes.Add(s); + } + + // In play-mode Editor mocks the level streaming script + if (Editor.IsPlayMode) + { + foreach (var s in scenes) + { + Level.UnloadSceneAsync(s); + } + return; + } + + // Ensure to save all pending changes + if (CheckSaveBeforeClose()) + return; + + // Unload scenes + Editor.StateMachine.ChangingScenesState.UnloadScene(scenes); + } + /// /// Show save before scene load/unload action. /// diff --git a/Source/Editor/SceneGraph/Actors/SceneNode.cs b/Source/Editor/SceneGraph/Actors/SceneNode.cs index df7a11b1a..0405e4fdf 100644 --- a/Source/Editor/SceneGraph/Actors/SceneNode.cs +++ b/Source/Editor/SceneGraph/Actors/SceneNode.cs @@ -77,6 +77,8 @@ namespace FlaxEditor.SceneGraph.Actors } contextMenu.AddButton("Save scene", OnSave).LinkTooltip("Saves this scene.").Enabled = IsEdited && !Editor.IsPlayMode; contextMenu.AddButton("Unload scene", OnUnload).LinkTooltip("Unloads this scene.").Enabled = Editor.Instance.StateMachine.CurrentState.CanChangeScene; + if (Level.ScenesCount > 1) + contextMenu.AddButton("Unload all but this scene", OnUnloadAllButSelectedScene).LinkTooltip("Unloads all of the active scenes except for the selected scene.").Enabled = Editor.Instance.StateMachine.CurrentState.CanChangeScene; base.OnContextMenu(contextMenu); } @@ -95,5 +97,10 @@ namespace FlaxEditor.SceneGraph.Actors { Editor.Instance.Scene.CloseScene(Scene); } + + private void OnUnloadAllButSelectedScene() + { + Editor.Instance.Scene.CloseAllScenesExcept(Scene); + } } } From 98a5985ce94764422ca040945e2e4ca33fa5e8f7 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 4 May 2023 11:03:39 -0500 Subject: [PATCH 14/16] Fix bug of the collection size changing while still editing or sliding the size box. --- Source/Editor/CustomEditors/Editors/CollectionEditor.cs | 2 +- Source/Editor/CustomEditors/Editors/DictionaryEditor.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs index 318dafcc6..8fe5fd5f2 100644 --- a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs +++ b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs @@ -145,7 +145,7 @@ namespace FlaxEditor.CustomEditors.Editors _size.IntValue.MinValue = 0; _size.IntValue.MaxValue = ushort.MaxValue; _size.IntValue.Value = size; - _size.IntValue.ValueChanged += OnSizeChanged; + _size.IntValue.EditEnd += OnSizeChanged; } // Elements diff --git a/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs b/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs index 7dd590576..1b9a7cca1 100644 --- a/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs +++ b/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs @@ -190,7 +190,7 @@ namespace FlaxEditor.CustomEditors.Editors _size.IntValue.MinValue = 0; _size.IntValue.MaxValue = _notNullItems ? size : ushort.MaxValue; _size.IntValue.Value = size; - _size.IntValue.ValueChanged += OnSizeChanged; + _size.IntValue.EditEnd += OnSizeChanged; } // Elements From 5e31a678bd678def61c3c9db527f157c719c7fbb Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 5 May 2023 10:49:07 +0200 Subject: [PATCH 15/16] Improve C# Object comparison by using native pointer compare #1061 #713 #795 --- .../CustomEditors/Values/ValueContainer.cs | 2 +- .../Editor/GUI/Timeline/Tracks/ActorTrack.cs | 2 +- Source/Engine/Scripting/Object.cs | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/Editor/CustomEditors/Values/ValueContainer.cs b/Source/Editor/CustomEditors/Values/ValueContainer.cs index 61c223835..53af4387f 100644 --- a/Source/Editor/CustomEditors/Values/ValueContainer.cs +++ b/Source/Editor/CustomEditors/Values/ValueContainer.cs @@ -187,7 +187,7 @@ namespace FlaxEditor.CustomEditors { for (int i = 0; i < Count; i++) { - if (this[i] == referenceSceneObject) + if ((SceneObject)this[i] == referenceSceneObject) continue; if (this[i] == null || (this[i] is SceneObject valueSceneObject && valueSceneObject && valueSceneObject.PrefabObjectID != referenceSceneObject.PrefabObjectID)) diff --git a/Source/Editor/GUI/Timeline/Tracks/ActorTrack.cs b/Source/Editor/GUI/Timeline/Tracks/ActorTrack.cs index 9e51cc21a..eb3fa39b6 100644 --- a/Source/Editor/GUI/Timeline/Tracks/ActorTrack.cs +++ b/Source/Editor/GUI/Timeline/Tracks/ActorTrack.cs @@ -174,7 +174,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks continue; // Prevent from adding the same track twice - if (SubTracks.Any(x => x is IObjectTrack y && y.Object == script)) + if (SubTracks.Any(x => x is IObjectTrack y && y.Object as SceneObject == script)) continue; var name = Utilities.Utils.GetPropertyNameUI(script.GetType().Name); diff --git a/Source/Engine/Scripting/Object.cs b/Source/Engine/Scripting/Object.cs index ce7846d73..bc1a4b1b5 100644 --- a/Source/Engine/Scripting/Object.cs +++ b/Source/Engine/Scripting/Object.cs @@ -212,9 +212,11 @@ namespace FlaxEngine /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator == (Object left, Object right) + public static bool operator ==(Object left, Object right) { - return Object.Equals(left, right); + IntPtr leftPtr = (object)left != null ? left.__unmanagedPtr : IntPtr.Zero; + IntPtr rightPtr = (object)right != null ? right.__unmanagedPtr : IntPtr.Zero; + return leftPtr == rightPtr; } /// @@ -226,7 +228,17 @@ namespace FlaxEngine [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(Object left, Object right) { - return !Object.Equals(left, right); + IntPtr leftPtr = (object)left != null ? left.__unmanagedPtr : IntPtr.Zero; + IntPtr rightPtr = (object)right != null ? right.__unmanagedPtr : IntPtr.Zero; + return leftPtr != rightPtr; + } + + /// + public override bool Equals(object obj) + { + if (obj is FlaxEngine.Object o) + return o.__unmanagedPtr == __unmanagedPtr; + return false; } /// From 65a68131cc405f03750c5232df038fc168ad394e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 5 May 2023 11:38:28 +0200 Subject: [PATCH 16/16] Improve name construction in #1038 --- Source/Editor/Content/Proxy/MaterialProxy.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/Editor/Content/Proxy/MaterialProxy.cs b/Source/Editor/Content/Proxy/MaterialProxy.cs index c6a9755fc..cf7c8b77e 100644 --- a/Source/Editor/Content/Proxy/MaterialProxy.cs +++ b/Source/Editor/Content/Proxy/MaterialProxy.cs @@ -72,10 +72,7 @@ namespace FlaxEditor.Content /// The material item to use as a base material. public static void CreateMaterialInstance(BinaryAssetItem materialItem) { - if (materialItem == null) - throw new ArgumentNullException(); - - var materialInstanceName = materialItem.FileName.Replace(".flax", " Instance"); + var materialInstanceName = materialItem.ShortName + " Instance"; var materialInstanceProxy = Editor.Instance.ContentDatabase.GetProxy(); Editor.Instance.Windows.ContentWin.NewItem(materialInstanceProxy, null, item => OnMaterialInstanceCreated(item, materialItem), materialInstanceName); }