From c36e0a93eda1c0def9f80b5f11f6bad93c2904ec Mon Sep 17 00:00:00 2001 From: Jhett Black <10942655+jhett12321@users.noreply.github.com> Date: Tue, 11 Dec 2018 06:46:34 +1000 Subject: [PATCH] [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. --- .../Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs index 5b992313c..9904a9da9 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs +++ b/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();