Skip to content

Commit

Permalink
[unity] Fix unneeded Unity 5 compiler condition.
Browse files Browse the repository at this point in the history
Also fixes compatibility with Unity 2017
  • Loading branch information
pharan committed Apr 15, 2017
1 parent e4f4e61 commit b0a25f5
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs
Expand Up @@ -86,10 +86,7 @@ public static class SkeletonBaker {

string dataPath = AssetDatabase.GetAssetPath(skeletonDataAsset);
string controllerPath = dataPath.Replace("_SkeletonData", "_Controller").Replace(".asset", ".controller");

#if UNITY_5
UnityEditor.Animations.AnimatorController controller;

if (skeletonDataAsset.controller != null) {
controller = (UnityEditor.Animations.AnimatorController)skeletonDataAsset.controller;
controllerPath = AssetDatabase.GetAssetPath(controller);
Expand All @@ -105,24 +102,6 @@ public static class SkeletonBaker {
}

}
#else
UnityEditorInternal.AnimatorController controller;

if (skeletonDataAsset.controller != null) {
controller = (UnityEditorInternal.AnimatorController)skeletonDataAsset.controller;
controllerPath = AssetDatabase.GetAssetPath(controller);
} else {
if (File.Exists(controllerPath)) {
if (EditorUtility.DisplayDialog("Controller Overwrite Warning", "Unknown Controller already exists at: " + controllerPath, "Update", "Overwrite")) {
controller = (UnityEditorInternal.AnimatorController)AssetDatabase.LoadAssetAtPath(controllerPath, typeof(RuntimeAnimatorController));
} else {
controller = (UnityEditorInternal.AnimatorController)UnityEditorInternal.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
}
} else {
controller = (UnityEditorInternal.AnimatorController)UnityEditorInternal.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
}
}
#endif

skeletonDataAsset.controller = controller;
EditorUtility.SetDirty(skeletonDataAsset);
Expand Down Expand Up @@ -218,32 +197,19 @@ public static class SkeletonBaker {

var skeletonData = skeletonDataAsset.GetSkeletonData(true);
bool hasAnimations = bakeAnimations && skeletonData.Animations.Count > 0;
#if UNITY_5
UnityEditor.Animations.AnimatorController controller = null;
#else
UnityEditorInternal.AnimatorController controller = null;
#endif
if (hasAnimations) {
string controllerPath = outputPath + "/" + skeletonDataAsset.skeletonJSON.name + " Controller.controller";
bool newAnimContainer = false;

var runtimeController = AssetDatabase.LoadAssetAtPath(controllerPath, typeof(RuntimeAnimatorController));

#if UNITY_5
if (runtimeController != null) {
controller = (UnityEditor.Animations.AnimatorController)runtimeController;
} else {
controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
newAnimContainer = true;
}
#else
if (runtimeController != null) {
controller = (UnityEditorInternal.AnimatorController)runtimeController;
} else {
controller = UnityEditorInternal.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
newAnimContainer = true;
}
#endif

var existingClipTable = new Dictionary<string, AnimationClip>();
var unusedClipNames = new List<string>();
Expand Down Expand Up @@ -288,12 +254,7 @@ public static class SkeletonBaker {
unusedClipNames.Remove(clip.name);
} else {
AssetDatabase.AddObjectToAsset(clip, controller);
#if UNITY_5
controller.AddMotion(clip);
#else
UnityEditorInternal.AnimatorController.AddAnimationClipToController(controller, clip);
#endif

}
}

Expand Down Expand Up @@ -783,12 +744,6 @@ public struct Pair {
AnimationUtility.SetAnimationEvents(clip, new AnimationEvent[0]);
}

#if UNITY_5

#else
AnimationUtility.SetAnimationType(clip, ModelImporterAnimationType.Generic);
#endif

clip.name = name;

Skeleton skeleton = new Skeleton(skeletonData);
Expand Down Expand Up @@ -1477,14 +1432,7 @@ public struct Pair {
#endregion

static void SetAnimationSettings (AnimationClip clip, AnimationClipSettings settings) {
#if UNITY_5
AnimationUtility.SetAnimationClipSettings(clip, settings);
#else
MethodInfo methodInfo = typeof(AnimationUtility).GetMethod("SetAnimationClipSettings", BindingFlags.Static | BindingFlags.NonPublic);
methodInfo.Invoke(null, new object[] { clip, settings });

EditorUtility.SetDirty(clip);
#endif
}


Expand Down

0 comments on commit b0a25f5

Please sign in to comment.