Skip to content

Commit ffa0bcc

Browse files
authored
Update AssetsContainerEditor.cs
1 parent 67ecfb0 commit ffa0bcc

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

DataSerializer/AssetsContainerEditor.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if UNITY_EDITOR
1+
#if UNITY_EDITOR
22
using UnityEditor;
33
using UnityEngine;
44

@@ -13,17 +13,15 @@ internal class AssetsContainerEditor : EditorWindow
1313
static void ShowWindow() =>
1414
GetWindow<AssetsContainerEditor>("Assets Container").Show();
1515

16-
private void OnEnable()
17-
{
16+
private void OnEnable() =>
1817
_provider = Resources.Load<AssetsContainer>("ToolBoxAssetsContainer");
19-
}
2018

2119
private void OnGUI()
2220
{
2321
var obj = new SerializedObject(_provider);
2422
obj.Update();
25-
var pathsProperty = obj.FindProperty("_paths");
2623
var objectsProperty = obj.FindProperty("_savedAssets");
24+
var pathsProperty = obj.FindProperty("_paths");
2725

2826
DrawPaths(pathsProperty);
2927
DrawButtons();
@@ -42,17 +40,19 @@ private void DrawPaths(SerializedProperty pathsProperty)
4240
EditorGUILayout.BeginHorizontal();
4341

4442
var element = pathsProperty.GetArrayElementAtIndex(i);
45-
EditorGUILayout.PropertyField(element);
43+
EditorGUILayout.PropertyField(element, new GUIContent($"Path {i}"));
4644

4745
if (GUILayout.Button(selectContent, EditorStyles.miniButtonLeft, GUILayout.Width(75f)))
4846
{
4947
string path = EditorUtility.OpenFolderPanel("Select path", "Assets", "");
5048

51-
if (path != "Assets")
49+
if (path != "Assets" || path.Length != 0)
5250
path = path.Substring(path.IndexOf("Assets"));
5351

5452
if (AssetDatabase.IsValidFolder(path))
5553
element.stringValue = path;
54+
else
55+
pathsProperty.DeleteArrayElementAtIndex(i);
5656
}
5757

5858
if (GUILayout.Button(removeContent, EditorStyles.miniButtonLeft, GUILayout.Width(30f)))
@@ -71,14 +71,12 @@ private void DrawButtons()
7171
{
7272
EditorGUILayout.BeginHorizontal();
7373

74-
if (GUILayout.Button("Load assets from paths"))
75-
{
74+
if (GUILayout.Button("Load assets at paths"))
7675
_provider.LoadAssets();
77-
}
7876

7977
if (GUILayout.Button("Remove assets from container"))
8078
{
81-
if (EditorUtility.DisplayDialog("Clear", "Do you really want to clear all referenced assets?", "Yes", "No"))
79+
if (EditorUtility.DisplayDialog("Clear", "Do you really want to remove all referenced assets?", "Yes", "No"))
8280
_provider.Clear();
8381
}
8482

@@ -98,4 +96,4 @@ private void DrawAssets(SerializedProperty objectsProperty)
9896
}
9997
}
10098
}
101-
#endif
99+
#endif

0 commit comments

Comments
 (0)