[unity] Disable baking in 2018.3

This commit is contained in:
pharan 2018-12-11 04:44:19 +08:00 committed by GitHub
parent 987d074152
commit bda6c58dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/ *****************************************************************************/
// Contributed by: Mitch Thompson #if UNITY_2018_3 || UNITY_2019
#define NEW_PREFAB_SYSTEM
#endif
#define SPINE_SKELETONMECANIM #define SPINE_SKELETONMECANIM
@ -184,6 +186,8 @@ 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);
@ -275,8 +279,8 @@ namespace Spine.Unity.Editor {
string prefabPath = outputPath + "/" + skeletonDataAsset.skeletonJSON.name + " (" + skin.Name + ").prefab"; string prefabPath = outputPath + "/" + skeletonDataAsset.skeletonJSON.name + " (" + skin.Name + ").prefab";
Object prefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)); Object prefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));
if (prefab == null) { if (prefab == null) {
prefab = PrefabUtility.CreateEmptyPrefab(prefabPath); prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);
newPrefab = true; newPrefab = true;
@ -430,7 +434,6 @@ namespace Spine.Unity.Editor {
EditorGUIUtility.PingObject(controller); EditorGUIUtility.PingObject(controller);
} }
if (newPrefab) { if (newPrefab) {
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ConnectToPrefab); PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ConnectToPrefab);
} else { } else {
@ -441,6 +444,7 @@ namespace Spine.Unity.Editor {
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ReplaceNameBased); PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ReplaceNameBased);
} }
EditorGUIUtility.PingObject(prefab); EditorGUIUtility.PingObject(prefab);
@ -448,7 +452,9 @@ namespace Spine.Unity.Editor {
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
GameObject.DestroyImmediate(prefabRoot); GameObject.DestroyImmediate(prefabRoot);
} }
#endif
} }
@ -731,9 +737,9 @@ namespace Spine.Unity.Editor {
return arr; return arr;
} }
#endregion #endregion
#region Animation Baking #region Animation Baking
static AnimationClip ExtractAnimation (string name, SkeletonData skeletonData, Dictionary<int, List<string>> slotLookup, bool bakeIK, SendMessageOptions eventOptions, AnimationClip clip = null) { static AnimationClip ExtractAnimation (string name, SkeletonData skeletonData, Dictionary<int, List<string>> slotLookup, bool bakeIK, SendMessageOptions eventOptions, AnimationClip clip = null) {
var animation = skeletonData.FindAnimation(name); var animation = skeletonData.FindAnimation(name);
@ -1402,10 +1408,10 @@ namespace Spine.Unity.Editor {
return angle; return angle;
} }
#endregion #endregion
#endregion #endregion
#region Region Baking #region Region Baking
public static GameObject BakeRegion (SpineAtlasAsset atlasAsset, AtlasRegion region, bool autoSave = true) { public static GameObject BakeRegion (SpineAtlasAsset atlasAsset, AtlasRegion region, bool autoSave = true) {
atlasAsset.GetAtlas(); // Initializes atlasAsset. atlasAsset.GetAtlas(); // Initializes atlasAsset.
@ -1424,7 +1430,12 @@ namespace Spine.Unity.Editor {
if (prefab == null) { if (prefab == null) {
root = new GameObject("temp", typeof(MeshFilter), typeof(MeshRenderer)); root = new GameObject("temp", typeof(MeshFilter), typeof(MeshRenderer));
#if NEW_PREFAB_SYSTEM
prefab = PrefabUtility.SaveAsPrefabAsset(root, bakedPrefabPath);
#else
prefab = PrefabUtility.CreatePrefab(bakedPrefabPath, root); prefab = PrefabUtility.CreatePrefab(bakedPrefabPath, root);
#endif
isNewPrefab = true; isNewPrefab = true;
Object.DestroyImmediate(root); Object.DestroyImmediate(root);
} }
@ -1450,7 +1461,7 @@ namespace Spine.Unity.Editor {
return prefab; return prefab;
} }
#endregion #endregion
static string GetPath (BoneData b) { static string GetPath (BoneData b) {
return GetPathRecurse(b).Substring(1); return GetPathRecurse(b).Substring(1);