mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-10 17:18:44 +08:00
[unity] Adapted skeleton baking window to Unity 2018.3 prefab API and added it to context menu again. Closes #1471.
This commit is contained in:
parent
19bbd5519f
commit
9c11431988
@ -184,9 +184,7 @@ namespace Spine.Unity.Editor {
|
||||
Debug.LogError("Could not export Spine Skeleton because SkeletonDataAsset is null or invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
|
||||
|
||||
if (outputPath == "") {
|
||||
outputPath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(skeletonDataAsset)) + "/Baked";
|
||||
System.IO.Directory.CreateDirectory(outputPath);
|
||||
@ -281,7 +279,13 @@ namespace Spine.Unity.Editor {
|
||||
Object prefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));
|
||||
|
||||
if (prefab == null) {
|
||||
#if NEW_PREFAB_SYSTEM
|
||||
GameObject emptyGameObject = new GameObject();
|
||||
prefab = PrefabUtility.SaveAsPrefabAssetAndConnect(emptyGameObject, prefabPath, InteractionMode.AutomatedAction);
|
||||
GameObject.DestroyImmediate(emptyGameObject);
|
||||
#else
|
||||
prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);
|
||||
#endif
|
||||
newPrefab = true;
|
||||
}
|
||||
|
||||
@ -428,14 +432,22 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
if (newPrefab) {
|
||||
#if NEW_PREFAB_SYSTEM
|
||||
PrefabUtility.SaveAsPrefabAssetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction);
|
||||
#else
|
||||
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ConnectToPrefab);
|
||||
#endif
|
||||
} else {
|
||||
|
||||
foreach (string str in unusedMeshNames) {
|
||||
Mesh.DestroyImmediate(meshTable[str], true);
|
||||
}
|
||||
|
||||
#if NEW_PREFAB_SYSTEM
|
||||
PrefabUtility.SaveAsPrefabAssetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction);
|
||||
#else
|
||||
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ReplaceNameBased);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -447,8 +459,6 @@ namespace Spine.Unity.Editor {
|
||||
GameObject.DestroyImmediate(prefabRoot);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#region Attachment Baking
|
||||
|
||||
@ -27,10 +27,6 @@
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -44,7 +40,6 @@ namespace Spine.Unity.Editor {
|
||||
public class SkeletonBakingWindow : EditorWindow {
|
||||
const bool IsUtilityWindow = true;
|
||||
|
||||
#if !NEW_PREFAB_SYSTEM
|
||||
[MenuItem("CONTEXT/SkeletonDataAsset/Skeleton Baking", false, 5000)]
|
||||
public static void Init (MenuCommand command) {
|
||||
var window = EditorWindow.GetWindow<SkeletonBakingWindow>(IsUtilityWindow);
|
||||
@ -54,7 +49,6 @@ namespace Spine.Unity.Editor {
|
||||
window.skeletonDataAsset = command.context as SkeletonDataAsset;
|
||||
window.Show();
|
||||
}
|
||||
#endif
|
||||
|
||||
public SkeletonDataAsset skeletonDataAsset;
|
||||
[SpineSkin(dataField:"skeletonDataAsset")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user