From 5a2831d0cbe7a66470fb8acd298f4f01814d7c20 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 29 Apr 2023 12:11:17 +0200 Subject: [PATCH] Various improvements --- Source/Editor/Content/Items/AssetItem.cs | 9 +++++++++ Source/Editor/GUI/AssetPicker.cs | 7 +++++++ Source/Engine/Animations/Graph/AnimGraph.cpp | 4 ---- Source/Engine/Content/Upgraders/ModelAssetUpgrader.h | 8 ++++---- Source/Engine/Serialization/ReadStream.h | 11 ++++------- Source/Engine/Serialization/WriteStream.h | 9 +++------ 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Source/Editor/Content/Items/AssetItem.cs b/Source/Editor/Content/Items/AssetItem.cs index 6697ed27c..8ececa278 100644 --- a/Source/Editor/Content/Items/AssetItem.cs +++ b/Source/Editor/Content/Items/AssetItem.cs @@ -88,6 +88,15 @@ namespace FlaxEditor.Content /// public override ContentItemType ItemType => ContentItemType.Asset; + /// + /// Loads the asset. + /// + /// The asset object. + public Asset LoadAsync() + { + return FlaxEngine.Content.LoadAsync(ID); + } + /// /// Determines whether asset is of the specified type (included inheritance checks). /// diff --git a/Source/Editor/GUI/AssetPicker.cs b/Source/Editor/GUI/AssetPicker.cs index 41f360195..bfded5380 100644 --- a/Source/Editor/GUI/AssetPicker.cs +++ b/Source/Editor/GUI/AssetPicker.cs @@ -206,6 +206,11 @@ namespace FlaxEditor.GUI /// public event Action SelectedItemChanged; + /// + /// The custom callback for assets validation. Cane be used to implement a rule for assets to pick. + /// + public Func CheckValid; + /// /// False if changing selected item is disabled. /// @@ -215,6 +220,8 @@ namespace FlaxEditor.GUI { if (_fileExtension != null && !item.Path.EndsWith(_fileExtension)) return false; + if (CheckValid != null && !CheckValid(item)) + return false; if (_type == ScriptType.Null) return true; diff --git a/Source/Engine/Animations/Graph/AnimGraph.cpp b/Source/Engine/Animations/Graph/AnimGraph.cpp index 43c9e10b9..3314aecab 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.cpp @@ -336,10 +336,6 @@ void AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt) //value.Orientation.Normalize(); targetNodes[i] = value; } - else - { - int a = 10; - } } } diff --git a/Source/Engine/Content/Upgraders/ModelAssetUpgrader.h b/Source/Engine/Content/Upgraders/ModelAssetUpgrader.h index eb8b2ca2b..977f27349 100644 --- a/Source/Engine/Content/Upgraders/ModelAssetUpgrader.h +++ b/Source/Engine/Content/Upgraders/ModelAssetUpgrader.h @@ -26,10 +26,10 @@ public: { static const Upgrader upgraders[] = { - { 24, 25, &Upgrade_With_Repack }, - { 23, 24, &Upgrade_22OrNewer_To_Newest }, - { 22, 24, &Upgrade_22OrNewer_To_Newest }, - { 1, 24, &Upgrade_Old_To_Newest }, + { 24, 25, &Upgrade_With_Repack }, // [Deprecated on 28.04.2023, expires on 01.01.2024] + { 23, 24, &Upgrade_22OrNewer_To_Newest }, // [Deprecated on 28.04.2023, expires on 01.01.2024] + { 22, 24, &Upgrade_22OrNewer_To_Newest }, // [Deprecated on 28.04.2023, expires on 01.01.2024] + { 1, 24, &Upgrade_Old_To_Newest }, // [Deprecated on 28.04.2023, expires on 01.01.2024] }; setup(upgraders, ARRAY_COUNT(upgraders)); } diff --git a/Source/Engine/Serialization/ReadStream.h b/Source/Engine/Serialization/ReadStream.h index 69e86fa4b..9d3215442 100644 --- a/Source/Engine/Serialization/ReadStream.h +++ b/Source/Engine/Serialization/ReadStream.h @@ -193,14 +193,11 @@ public: ReadInt32(&count); data.Clear(); data.EnsureCapacity(count); - if (count > 0) + for (int32 i = 0; i < count; i++) { - for (int32 i = 0; i < count; i++) - { - KeyType key; - Read(key); - Read(data[key]); - } + KeyType key; + Read(key); + Read(data[key]); } } diff --git a/Source/Engine/Serialization/WriteStream.h b/Source/Engine/Serialization/WriteStream.h index 49573bf8d..92ac211ca 100644 --- a/Source/Engine/Serialization/WriteStream.h +++ b/Source/Engine/Serialization/WriteStream.h @@ -199,13 +199,10 @@ public: { const int32 count = data.Count(); WriteInt32(count); - if (count > 0) + for (const auto& e : data) { - for (const auto& e : data) - { - Write(e.Key); - Write(e.Value); - } + Write(e.Key); + Write(e.Value); } }