mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Merge branch '4.0' into 4.1-beta
This commit is contained in:
commit
135d9819a7
@ -956,7 +956,8 @@ namespace Spine.Unity.Editor {
|
|||||||
skeletonDataAsset.Clear();
|
skeletonDataAsset.Clear();
|
||||||
}
|
}
|
||||||
var skeletonData = skeletonDataAsset.GetSkeletonData(true);
|
var skeletonData = skeletonDataAsset.GetSkeletonData(true);
|
||||||
BlendModeMaterialsUtility.UpdateBlendModeMaterials(skeletonDataAsset, ref skeletonData);
|
if (skeletonData != null)
|
||||||
|
BlendModeMaterialsUtility.UpdateBlendModeMaterials(skeletonDataAsset, ref skeletonData);
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
|
||||||
return skeletonDataAsset;
|
return skeletonDataAsset;
|
||||||
@ -1006,9 +1007,9 @@ namespace Spine.Unity.Editor {
|
|||||||
);
|
);
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case -1:
|
case -1: { // Select Atlas
|
||||||
//Debug.Log("Select Atlas");
|
string pathForwardSlash = Path.GetDirectoryName(skeletonPath).Replace('\\', '/');
|
||||||
AtlasAssetBase selectedAtlas = BrowseAtlasDialog(Path.GetDirectoryName(skeletonPath).Replace('\\', '/'));
|
AtlasAssetBase selectedAtlas = BrowseAtlasDialog(pathForwardSlash, localAtlases);
|
||||||
if (selectedAtlas != null) {
|
if (selectedAtlas != null) {
|
||||||
localAtlases.Clear();
|
localAtlases.Clear();
|
||||||
localAtlases.Add(selectedAtlas);
|
localAtlases.Add(selectedAtlas);
|
||||||
@ -1019,14 +1020,17 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0: // Resolve AtlasAssets...
|
}
|
||||||
var atlasList = MultiAtlasDialog(requiredPaths, Path.GetDirectoryName(skeletonPath).Replace('\\', '/'),
|
case 0: { // Resolve AtlasAssets...
|
||||||
Path.GetFileNameWithoutExtension(skeletonPath));
|
string pathForwardSlash = Path.GetDirectoryName(skeletonPath).Replace('\\', '/');
|
||||||
|
var atlasList = MultiAtlasDialog(requiredPaths, pathForwardSlash,
|
||||||
|
localAtlases, filename);
|
||||||
if (atlasList != null)
|
if (atlasList != null)
|
||||||
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), atlasList.ToArray());
|
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), atlasList.ToArray());
|
||||||
|
|
||||||
resolved = true;
|
resolved = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 1: // Import without atlas
|
case 1: // Import without atlas
|
||||||
Debug.LogWarning("Imported with missing atlases. Skeleton will not render: " + Path.GetFileName(skeletonPath));
|
Debug.LogWarning("Imported with missing atlases. Skeleton will not render: " + Path.GetFileName(skeletonPath));
|
||||||
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), new AtlasAssetBase[] { });
|
AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonPath), new AtlasAssetBase[] { });
|
||||||
@ -1040,7 +1044,9 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<AtlasAssetBase> MultiAtlasDialog (List<string> requiredPaths, string initialDirectory, string filename = "") {
|
public static List<AtlasAssetBase> MultiAtlasDialog (List<string> requiredPaths, string initialDirectory,
|
||||||
|
List<AtlasAssetBase> localAtlases, string filename = "") {
|
||||||
|
|
||||||
List<AtlasAssetBase> atlasAssets = new List<AtlasAssetBase>();
|
List<AtlasAssetBase> atlasAssets = new List<AtlasAssetBase>();
|
||||||
bool resolved = false;
|
bool resolved = false;
|
||||||
string lastAtlasPath = initialDirectory;
|
string lastAtlasPath = initialDirectory;
|
||||||
@ -1095,7 +1101,7 @@ namespace Spine.Unity.Editor {
|
|||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case 0: // Browse...
|
case 0: // Browse...
|
||||||
AtlasAssetBase selectedAtlasAsset = BrowseAtlasDialog(lastAtlasPath);
|
AtlasAssetBase selectedAtlasAsset = BrowseAtlasDialog(lastAtlasPath, localAtlases);
|
||||||
if (selectedAtlasAsset != null) {
|
if (selectedAtlasAsset != null) {
|
||||||
if (!atlasAssets.Contains(selectedAtlasAsset)) {
|
if (!atlasAssets.Contains(selectedAtlasAsset)) {
|
||||||
var atlas = selectedAtlasAsset.GetAtlas();
|
var atlas = selectedAtlasAsset.GetAtlas();
|
||||||
@ -1123,7 +1129,7 @@ namespace Spine.Unity.Editor {
|
|||||||
return atlasAssets;
|
return atlasAssets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AtlasAssetBase BrowseAtlasDialog (string dirPath) {
|
public static AtlasAssetBase BrowseAtlasDialog (string dirPath, List<AtlasAssetBase> localAtlases) {
|
||||||
string path = EditorUtility.OpenFilePanel("Select AtlasAsset...", dirPath, "asset");
|
string path = EditorUtility.OpenFilePanel("Select AtlasAsset...", dirPath, "asset");
|
||||||
if (path == "")
|
if (path == "")
|
||||||
return null; // Canceled or closed by user.
|
return null; // Canceled or closed by user.
|
||||||
@ -1131,12 +1137,20 @@ namespace Spine.Unity.Editor {
|
|||||||
int subLen = Application.dataPath.Length - 6;
|
int subLen = Application.dataPath.Length - 6;
|
||||||
string assetRelativePath = path.Substring(subLen, path.Length - subLen).Replace("\\", "/");
|
string assetRelativePath = path.Substring(subLen, path.Length - subLen).Replace("\\", "/");
|
||||||
|
|
||||||
var obj = AssetDatabase.LoadAssetAtPath(assetRelativePath, typeof(AtlasAssetBase));
|
UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetRelativePath, typeof(AtlasAssetBase));
|
||||||
|
if (obj == null) {
|
||||||
|
// atlas assets that were just created fail to load, search localAtlases
|
||||||
|
foreach (AtlasAssetBase localAtlas in localAtlases) {
|
||||||
|
string newAtlasPath = AssetDatabase.GetAssetPath(localAtlas);
|
||||||
|
if (newAtlasPath == assetRelativePath)
|
||||||
|
return localAtlas;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (obj == null || !(obj is AtlasAssetBase)) {
|
if (obj == null || !(obj is AtlasAssetBase)) {
|
||||||
Debug.Log("Chosen asset was not of type AtlasAssetBase");
|
Debug.Log("Chosen asset was not of type AtlasAssetBase");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (AtlasAssetBase)obj;
|
return (AtlasAssetBase)obj;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user