瀏覽代碼

[unity] Fixed IndexOutOfRangeException on Unity 2022.2 upon first project import or upgrade. Closes #2241.

Harald Csaszar 2 年之前
父節點
當前提交
bf5d445fa7
共有 1 個文件被更改,包括 11 次插入6 次删除
  1. 11 6
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs

+ 11 - 6
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs

@@ -173,17 +173,22 @@ namespace Spine.Unity.Editor {
 			if (EditorApplication.isPlayingOrWillChangePlaymode) return;
 			if (EditorApplication.isPlayingOrWillChangePlaymode) return;
 
 
 			string[] folders = { "Assets", "Packages" };
 			string[] folders = { "Assets", "Packages" };
-			string[] assets = AssetDatabase.FindAssets("t:script SpineEditorUtilities", folders);
-			string assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
-			editorPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
-
+			string[] assets;
+			string assetPath;
 			assets = AssetDatabase.FindAssets("t:texture icon-subMeshRenderer", folders);
 			assets = AssetDatabase.FindAssets("t:texture icon-subMeshRenderer", folders);
 			if (assets.Length > 0) {
 			if (assets.Length > 0) {
 				assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
 				assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
 				editorGUIPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
 				editorGUIPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
-			} else {
-				editorGUIPath = editorPath.Replace("/Utility", "/GUI");
 			}
 			}
+			assets = AssetDatabase.FindAssets("t:script SpineEditorUtilities", folders);
+			if (assets.Length > 0) {
+				assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
+				editorPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
+				if (string.IsNullOrEmpty(editorGUIPath))
+					editorGUIPath = editorPath.Replace("/Utility", "/GUI");
+			}
+			if (string.IsNullOrEmpty(editorGUIPath))
+				return;
 			Icons.Initialize();
 			Icons.Initialize();
 
 
 			// Drag and Drop
 			// Drag and Drop