diff --git a/Assets/LDtkUnity/Editor/CustomEditor/SectionDrawers/LDtkSectionDependencies.cs b/Assets/LDtkUnity/Editor/CustomEditor/SectionDrawers/LDtkSectionDependencies.cs index d9d38b1c..45c8acd0 100644 --- a/Assets/LDtkUnity/Editor/CustomEditor/SectionDrawers/LDtkSectionDependencies.cs +++ b/Assets/LDtkUnity/Editor/CustomEditor/SectionDrawers/LDtkSectionDependencies.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using UnityEditor; using UnityEngine; using Object = UnityEngine.Object; @@ -47,7 +46,20 @@ public LDtkSectionDependencies(LDtkImporterEditor editor, SerializedObject seria for (int i = 0; i < _dependencies.Length; i++) { + //can be null! _dependencyAssets[i] = AssetDatabase.LoadAssetAtPath(_dependencies[i]); + + if (_dependencyAssets[i] == null) + { + _dependencyContent[i] = new GUIContent + { + text = _dependencies[i] + " (missing)", + tooltip = _dependencies[i], + image = null + }; + continue; + } + _dependencyContent[i] = new GUIContent { text = _dependencyAssets[i].name, @@ -71,12 +83,6 @@ Texture2D GetIconForDependency(Type type, string assetPath) public override void Draw() { - //don't draw this section at all if there are no dependencies - if (_dependencyAssets.All(p => p == null)) - { - return; - } - LDtkEditorGUIUtility.DrawDivider(); base.Draw(); } @@ -84,18 +90,11 @@ public override void Draw() protected override void DrawDropdownContent() { EditorGUIUtility.SetIconSize(Vector2.one * 16f); - for (int i = 0; i < _dependencies.Length; i++) + using (new LDtkGUIEnabledScope(false)) { - Object dependencyAsset = _dependencyAssets[i]; - - if (dependencyAsset == null) - { - continue; - } - - using (new LDtkGUIEnabledScope(false)) + for (int i = 0; i < _dependencies.Length; i++) { - EditorGUILayout.ObjectField(_dependencyContent[i], dependencyAsset, typeof(Object), false); + EditorGUILayout.ObjectField(_dependencyContent[i], _dependencyAssets[i], typeof(Object), false); } } }