diff --git a/Source/Editor/Content/GUI/ContentView.cs b/Source/Editor/Content/GUI/ContentView.cs index 5e054e5c6..e1a3acdf6 100644 --- a/Source/Editor/Content/GUI/ContentView.cs +++ b/Source/Editor/Content/GUI/ContentView.cs @@ -520,8 +520,8 @@ namespace FlaxEditor.Content.GUI { int min = _selection.Min(x => x.IndexInParent); int max = _selection.Max(x => x.IndexInParent); - min = Mathf.Min(min, item.IndexInParent); - max = Mathf.Max(max, item.IndexInParent); + min = Mathf.Max(Mathf.Min(min, item.IndexInParent), 0); + max = Mathf.Min(Mathf.Max(max, item.IndexInParent), _children.Count - 1); var selection = new List(_selection); for (int i = min; i <= max; i++) { diff --git a/Source/Editor/Windows/Assets/JsonAssetWindow.cs b/Source/Editor/Windows/Assets/JsonAssetWindow.cs index 47ce09274..097d4992a 100644 --- a/Source/Editor/Windows/Assets/JsonAssetWindow.cs +++ b/Source/Editor/Windows/Assets/JsonAssetWindow.cs @@ -80,11 +80,8 @@ namespace FlaxEditor.Windows.Assets { if (!IsEdited) return; - if (_asset.WaitForLoaded()) - { return; - } if (Editor.SaveJsonAsset(_item.Path, _object)) { @@ -137,7 +134,7 @@ namespace FlaxEditor.Windows.Assets } } _presenter.Select(_object); - + if (_typeText != null) _typeText.Dispose(); var typeText = new ClickableLabel @@ -152,7 +149,7 @@ namespace FlaxEditor.Windows.Assets typeText.LocalY += (_toolstrip.Height - typeText.Height) * 0.5f; typeText.RightClick = () => Clipboard.Text = Asset.DataTypeName; _typeText = typeText; - + _undo.Clear(); ClearEditedFlag(); diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp index 6aecd1778..ea627f2c7 100644 --- a/Source/Engine/Content/Content.cpp +++ b/Source/Engine/Content/Content.cpp @@ -125,16 +125,12 @@ void ContentService::LateUpdate() if (timeNow - LastUnloadCheckTime < Content::AssetsUpdateInterval) return; LastUnloadCheckTime = timeNow; - - Asset* asset; - ScopeLock lock(AssetsLocker); - - // TODO: maybe it would be better to link for asset remove ref event and cache only assets with no references - test it with millions of assets? + AssetsLocker.Lock(); // Verify all assets for (auto i = Assets.Begin(); i.IsNotEnd(); ++i) { - asset = i->Value; + Asset* asset = i->Value; // Check if has no references and is not during unloading if (asset->GetReferencesCount() <= 0 && !UnloadQueue.ContainsKey(asset)) @@ -158,7 +154,7 @@ void ContentService::LateUpdate() // Unload marked assets for (int32 i = 0; i < ToUnload.Count(); i++) { - asset = ToUnload[i]; + Asset* asset = ToUnload[i]; // Check if has no references if (asset->GetReferencesCount() <= 0) @@ -170,6 +166,8 @@ void ContentService::LateUpdate() UnloadQueue.Remove(asset); } + AssetsLocker.Unlock(); + // Update cache (for longer sessions it will help to reduce cache misses) Cache.Save(); } @@ -212,7 +210,6 @@ bool FindAssets(const ProjectInfo* project, HashSet& project { if (projects.Contains(project)) return false; - projects.Add(project); bool found = findAsset(id, project->ProjectFolderPath / TEXT("Content"), tmpCache, info); for (const auto& reference : project->References) @@ -220,7 +217,6 @@ bool FindAssets(const ProjectInfo* project, HashSet& project if (reference.Project) found |= FindAssets(reference.Project, projects, id, tmpCache, info); } - return found; } @@ -232,7 +228,6 @@ bool Content::GetAssetInfo(const Guid& id, AssetInfo& info) return false; #if ENABLE_ASSETS_DISCOVERY - // Find asset in registry if (Cache.FindAsset(id, info)) return true; @@ -270,19 +265,15 @@ bool Content::GetAssetInfo(const Guid& id, AssetInfo& info) //LOG(Warning, "Cannot find {0}.", id); return false; - #else - // Find asset in registry return Cache.FindAsset(id, info); - #endif } bool Content::GetAssetInfo(const StringView& path, AssetInfo& info) { #if ENABLE_ASSETS_DISCOVERY - // Find asset in registry if (Cache.FindAsset(path, info)) return true; @@ -326,12 +317,9 @@ bool Content::GetAssetInfo(const StringView& path, AssetInfo& info) } return false; - #else - // Find asset in registry return Cache.FindAsset(path, info); - #endif }