Ver Fonte

[Unity] Use AssetDatabase for locating editor base directory (#1207)

The current method assumes the Spine Runtime exists in a sub-directory of the project's "Assets" folder.

With the package manager, and the support of local packages in Unity 2018, the runtime could be located elsewhere. The AssetDatabase would be a more reliable option for finding this path.
Jhett Black há 6 anos atrás
pai
commit
c36e0a93ed

+ 3 - 3
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs

@@ -188,9 +188,9 @@ namespace Spine.Unity.Editor {
 			
 			Preferences.Load();
 
-			var rootDir = new DirectoryInfo(Application.dataPath);
-			FileInfo[] files = rootDir.GetFiles("SpineEditorUtilities.cs", SearchOption.AllDirectories);
-			editorPath = Path.GetDirectoryName(files[0].FullName.Replace("\\", "/").Replace(Application.dataPath, "Assets"));
+			var assets = AssetDatabase.FindAssets("t:script SpineEditorUtilities");
+			var assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
+			editorPath = Path.GetDirectoryName(assetPath).Replace("\\", "/");
 			editorGUIPath = editorPath + "/GUI";
 
 			Icons.Initialize();