From 8cbe5aa1451942bfb294a4de013ca02984140a52 Mon Sep 17 00:00:00 2001 From: Hiroki Omae Date: Wed, 17 Jun 2020 15:11:47 +0900 Subject: [PATCH] Fixing potential issue that fails to create AssetReference when asset type of asset on given path is null. --- Editor/System/Core/AssetGraphPostprocessor.cs | 5 +++-- Editor/System/Model/AssetReferenceDatabase.cs | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Editor/System/Core/AssetGraphPostprocessor.cs b/Editor/System/Core/AssetGraphPostprocessor.cs index 7b44eb9f..fa7d9260 100644 --- a/Editor/System/Core/AssetGraphPostprocessor.cs +++ b/Editor/System/Core/AssetGraphPostprocessor.cs @@ -105,8 +105,9 @@ namespace UnityEngine.AssetGraph { } } - foreach (string str in importedAssets) { - AssetReferenceDatabase.GetReference (str).InvalidateTypeCache(); + foreach (string str in importedAssets) + { + AssetReferenceDatabase.GetReference(str)?.InvalidateTypeCache(); } foreach (string str in deletedAssets) diff --git a/Editor/System/Model/AssetReferenceDatabase.cs b/Editor/System/Model/AssetReferenceDatabase.cs index 03a046e2..1107a87c 100644 --- a/Editor/System/Model/AssetReferenceDatabase.cs +++ b/Editor/System/Model/AssetReferenceDatabase.cs @@ -133,7 +133,9 @@ namespace UnityEngine.AssetGraph { db.m_dictionary.Add(relativePath, r); AssetReferenceDatabase.SetDBDirty(); return r; - } catch(AssetReferenceException ) { + } catch(AssetReferenceException e) { + LogUtility.Logger.LogWarning (LogUtility.kTag, + $"AssetReference could not be created: Asset:{e.importFrom} Message:{e.Message}"); // if give asset is invalid, return null return null; }