diff --git a/Source/Editor/Content/Proxy/MaterialProxy.cs b/Source/Editor/Content/Proxy/MaterialProxy.cs index 9cbd54975..cf7c8b77e 100644 --- a/Source/Editor/Content/Proxy/MaterialProxy.cs +++ b/Source/Editor/Content/Proxy/MaterialProxy.cs @@ -72,11 +72,9 @@ 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.ShortName + " 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) diff --git a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs index 08b8b37e0..8922e2d25 100644 --- a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs +++ b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs @@ -146,7 +146,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 6f1b95bb8..f26bf25a4 100644 --- a/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs +++ b/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs @@ -191,7 +191,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 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 diff --git a/Source/Editor/CustomEditors/Values/ValueContainer.cs b/Source/Editor/CustomEditors/Values/ValueContainer.cs index b1fd54e3b..574e73564 100644 --- a/Source/Editor/CustomEditors/Values/ValueContainer.cs +++ b/Source/Editor/CustomEditors/Values/ValueContainer.cs @@ -188,7 +188,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/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: diff --git a/Source/Editor/Modules/ContentDatabaseModule.cs b/Source/Editor/Modules/ContentDatabaseModule.cs index 146ea9dc1..07acabc8d 100644 --- a/Source/Editor/Modules/ContentDatabaseModule.cs +++ b/Source/Editor/Modules/ContentDatabaseModule.cs @@ -656,7 +656,7 @@ namespace FlaxEditor.Modules var children = folder.Children.ToArray(); for (int i = 0; i < children.Length; i++) { - Delete(children[0]); + Delete(children[i]); } } 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); + } } } 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 }, diff --git a/Source/Editor/Windows/Assets/ParticleSystemWindow.cs b/Source/Editor/Windows/Assets/ParticleSystemWindow.cs index 53ff9e439..328369680 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; 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 a2f1a6806..d605c6ad3 100644 --- a/Source/Engine/Level/Types.h +++ b/Source/Engine/Level/Types.h @@ -98,7 +98,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, diff --git a/Source/Engine/Scripting/Object.cs b/Source/Engine/Scripting/Object.cs index 1ddffaf66..b1421eeec 100644 --- a/Source/Engine/Scripting/Object.cs +++ b/Source/Engine/Scripting/Object.cs @@ -208,6 +208,42 @@ namespace FlaxEngine return obj != null && obj.__unmanagedPtr != IntPtr.Zero; } + /// + /// Checks whether the two objects are equal. + /// + /// + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool operator ==(Object left, Object right) + { + IntPtr leftPtr = (object)left != null ? left.__unmanagedPtr : IntPtr.Zero; + IntPtr rightPtr = (object)right != null ? right.__unmanagedPtr : IntPtr.Zero; + return leftPtr == rightPtr; + } + + /// + /// Checks whether the two objects are not equal. + /// + /// + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool operator !=(Object left, Object 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; + } + /// /// Gets the pointer to the native object. Handles null object reference (returns zero). ///