[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.
This commit is contained in:
Jhett Black 2018-12-11 06:46:34 +10:00 committed by pharan
parent 3b92f7cb79
commit c36e0a93ed

View File

@ -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();