mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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
3dfe37c67c
commit
89c50a09fd
@ -185,8 +185,6 @@ namespace Spine.Unity.Editor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !NEW_PREFAB_SYSTEM
|
|
||||||
|
|
||||||
if (outputPath == "") {
|
if (outputPath == "") {
|
||||||
outputPath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(skeletonDataAsset)) + "/Baked";
|
outputPath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(skeletonDataAsset)) + "/Baked";
|
||||||
System.IO.Directory.CreateDirectory(outputPath);
|
System.IO.Directory.CreateDirectory(outputPath);
|
||||||
@ -281,7 +279,13 @@ namespace Spine.Unity.Editor {
|
|||||||
Object prefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));
|
Object prefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));
|
||||||
|
|
||||||
if (prefab == null) {
|
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);
|
prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);
|
||||||
|
#endif
|
||||||
newPrefab = true;
|
newPrefab = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,14 +432,22 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newPrefab) {
|
if (newPrefab) {
|
||||||
|
#if NEW_PREFAB_SYSTEM
|
||||||
|
PrefabUtility.SaveAsPrefabAssetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction);
|
||||||
|
#else
|
||||||
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ConnectToPrefab);
|
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ConnectToPrefab);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
foreach (string str in unusedMeshNames) {
|
foreach (string str in unusedMeshNames) {
|
||||||
Mesh.DestroyImmediate(meshTable[str], true);
|
Mesh.DestroyImmediate(meshTable[str], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if NEW_PREFAB_SYSTEM
|
||||||
|
PrefabUtility.SaveAsPrefabAssetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction);
|
||||||
|
#else
|
||||||
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ReplaceNameBased);
|
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ReplaceNameBased);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -447,8 +459,6 @@ namespace Spine.Unity.Editor {
|
|||||||
GameObject.DestroyImmediate(prefabRoot);
|
GameObject.DestroyImmediate(prefabRoot);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Attachment Baking
|
#region Attachment Baking
|
||||||
|
|||||||
@ -27,10 +27,6 @@
|
|||||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -44,7 +40,6 @@ namespace Spine.Unity.Editor {
|
|||||||
public class SkeletonBakingWindow : EditorWindow {
|
public class SkeletonBakingWindow : EditorWindow {
|
||||||
const bool IsUtilityWindow = true;
|
const bool IsUtilityWindow = true;
|
||||||
|
|
||||||
#if !NEW_PREFAB_SYSTEM
|
|
||||||
[MenuItem("CONTEXT/SkeletonDataAsset/Skeleton Baking", false, 5000)]
|
[MenuItem("CONTEXT/SkeletonDataAsset/Skeleton Baking", false, 5000)]
|
||||||
public static void Init (MenuCommand command) {
|
public static void Init (MenuCommand command) {
|
||||||
var window = EditorWindow.GetWindow<SkeletonBakingWindow>(IsUtilityWindow);
|
var window = EditorWindow.GetWindow<SkeletonBakingWindow>(IsUtilityWindow);
|
||||||
@ -54,7 +49,6 @@ namespace Spine.Unity.Editor {
|
|||||||
window.skeletonDataAsset = command.context as SkeletonDataAsset;
|
window.skeletonDataAsset = command.context as SkeletonDataAsset;
|
||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
public SkeletonDataAsset skeletonDataAsset;
|
public SkeletonDataAsset skeletonDataAsset;
|
||||||
[SpineSkin(dataField:"skeletonDataAsset")]
|
[SpineSkin(dataField:"skeletonDataAsset")]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user