[unity] Moved Timeline module to a separate Package com.esotericsoftware.spine.timeline. Activated asmdef files by default again in spine-unity, added asmdef files to timeline package. Fixed compile errors when asmdef files are active. Cleanup of no longer necessary asmdef file modifying code.

This commit is contained in:
Harald Csaszar 2019-07-18 13:53:33 +02:00
parent 08f1741e2b
commit d8808fb8ce
66 changed files with 213 additions and 384 deletions

View File

@ -43,7 +43,7 @@ namespace Spine.Unity.Examples {
public override void Apply (SkeletonData skeletonData) {
if (matchAllAnimations)
AnimationTools.MatchAnimationTimelines(skeletonData.animations, skeletonData);
AnimationTools.MatchAnimationTimelines(skeletonData.Animations, skeletonData);
}
public static class AnimationTools {
@ -63,7 +63,7 @@ namespace Spine.Unity.Examples {
// and a collection of dummy timelines that can be used to fill-in missing items.
var timelineDictionary = new Dictionary<int, Spine.Timeline>();
foreach (var animation in animations) {
foreach (var timeline in animation.timelines) {
foreach (var timeline in animation.Timelines) {
if (timeline is EventTimeline) continue;
int propertyID = timeline.PropertyId;
@ -78,12 +78,12 @@ namespace Spine.Unity.Examples {
var currentAnimationIDs = new HashSet<int>();
foreach (var animation in animations) {
currentAnimationIDs.Clear();
foreach (var timeline in animation.timelines) {
foreach (var timeline in animation.Timelines) {
if (timeline is EventTimeline) continue;
currentAnimationIDs.Add(timeline.PropertyId);
}
var animationTimelines = animation.timelines;
var animationTimelines = animation.Timelines;
foreach (int propertyID in idsToMatch) {
if (!currentAnimationIDs.Contains(propertyID))
animationTimelines.Add(timelineDictionary[propertyID]);
@ -100,116 +100,98 @@ namespace Spine.Unity.Examples {
}
static Timeline GetFillerTimeline (Timeline timeline, SkeletonData skeletonData) {
int propertyID = timeline.PropertyId;
int tt = propertyID >> 24;
var timelineType = (TimelineType)tt;
switch (timelineType) {
// Bone
case TimelineType.Rotate:
return GetFillerTimeline((RotateTimeline)timeline, skeletonData);
case TimelineType.Translate:
return GetFillerTimeline((TranslateTimeline)timeline, skeletonData);
case TimelineType.Scale:
return GetFillerTimeline((ScaleTimeline)timeline, skeletonData);
case TimelineType.Shear:
return GetFillerTimeline((ShearTimeline)timeline, skeletonData);
// Slot
case TimelineType.Attachment:
return GetFillerTimeline((AttachmentTimeline)timeline, skeletonData);
case TimelineType.Color:
return GetFillerTimeline((ColorTimeline)timeline, skeletonData);
case TimelineType.TwoColor:
return GetFillerTimeline((TwoColorTimeline)timeline, skeletonData);
case TimelineType.Deform:
return GetFillerTimeline((DeformTimeline)timeline, skeletonData);
// Skeleton
case TimelineType.DrawOrder:
return GetFillerTimeline((DrawOrderTimeline)timeline, skeletonData);
// IK Constraint
case TimelineType.IkConstraint:
return GetFillerTimeline((IkConstraintTimeline)timeline, skeletonData);
// TransformConstraint
case TimelineType.TransformConstraint:
return GetFillerTimeline((TransformConstraintTimeline)timeline, skeletonData);
// Path Constraint
case TimelineType.PathConstraintPosition:
return GetFillerTimeline((PathConstraintPositionTimeline)timeline, skeletonData);
case TimelineType.PathConstraintSpacing:
return GetFillerTimeline((PathConstraintSpacingTimeline)timeline, skeletonData);
case TimelineType.PathConstraintMix:
return GetFillerTimeline((PathConstraintMixTimeline)timeline, skeletonData);
}
if (timeline is RotateTimeline)
return GetFillerTimeline((RotateTimeline)timeline, skeletonData);
if (timeline is TranslateTimeline)
return GetFillerTimeline((TranslateTimeline)timeline, skeletonData);
if (timeline is ScaleTimeline)
return GetFillerTimeline((ScaleTimeline)timeline, skeletonData);
if (timeline is ShearTimeline)
return GetFillerTimeline((ShearTimeline)timeline, skeletonData);
if (timeline is AttachmentTimeline)
return GetFillerTimeline((AttachmentTimeline)timeline, skeletonData);
if (timeline is ColorTimeline)
return GetFillerTimeline((ColorTimeline)timeline, skeletonData);
if (timeline is TwoColorTimeline)
return GetFillerTimeline((TwoColorTimeline)timeline, skeletonData);
if (timeline is DeformTimeline)
return GetFillerTimeline((DeformTimeline)timeline, skeletonData);
if (timeline is DrawOrderTimeline)
return GetFillerTimeline((DrawOrderTimeline)timeline, skeletonData);
if (timeline is IkConstraintTimeline)
return GetFillerTimeline((IkConstraintTimeline)timeline, skeletonData);
if (timeline is TransformConstraintTimeline)
return GetFillerTimeline((TransformConstraintTimeline)timeline, skeletonData);
if (timeline is PathConstraintPositionTimeline)
return GetFillerTimeline((PathConstraintPositionTimeline)timeline, skeletonData);
if (timeline is PathConstraintSpacingTimeline)
return GetFillerTimeline((PathConstraintSpacingTimeline)timeline, skeletonData);
if (timeline is PathConstraintMixTimeline)
return GetFillerTimeline((PathConstraintMixTimeline)timeline, skeletonData);
return null;
}
static RotateTimeline GetFillerTimeline (RotateTimeline timeline, SkeletonData skeletonData) {
var t = new RotateTimeline(1);
t.boneIndex = timeline.boneIndex;
t.BoneIndex = timeline.BoneIndex;
t.SetFrame(0, 0, 0);
return t;
}
static TranslateTimeline GetFillerTimeline (TranslateTimeline timeline, SkeletonData skeletonData) {
var t = new TranslateTimeline(1);
t.boneIndex = timeline.boneIndex;
t.BoneIndex = timeline.BoneIndex;
t.SetFrame(0, 0, 0, 0);
return t;
}
static ScaleTimeline GetFillerTimeline (ScaleTimeline timeline, SkeletonData skeletonData) {
var t = new ScaleTimeline(1);
t.boneIndex = timeline.boneIndex;
t.BoneIndex = timeline.BoneIndex;
t.SetFrame(0, 0, 0, 0);
return t;
}
static ShearTimeline GetFillerTimeline (ShearTimeline timeline, SkeletonData skeletonData) {
var t = new ShearTimeline(1);
t.boneIndex = timeline.boneIndex;
t.BoneIndex = timeline.BoneIndex;
t.SetFrame(0, 0, 0, 0);
return t;
}
static AttachmentTimeline GetFillerTimeline (AttachmentTimeline timeline, SkeletonData skeletonData) {
var t = new AttachmentTimeline(1);
t.slotIndex = timeline.slotIndex;
var slotData = skeletonData.slots.Items[t.slotIndex];
t.SetFrame(0, 0, slotData.attachmentName);
t.SlotIndex = timeline.SlotIndex;
var slotData = skeletonData.Slots.Items[t.SlotIndex];
t.SetFrame(0, 0, slotData.AttachmentName);
return t;
}
static ColorTimeline GetFillerTimeline (ColorTimeline timeline, SkeletonData skeletonData) {
var t = new ColorTimeline(1);
t.slotIndex = timeline.slotIndex;
var slotData = skeletonData.slots.Items[t.slotIndex];
t.SetFrame(0, 0, slotData.r, slotData.g, slotData.b, slotData.a);
t.SlotIndex = timeline.SlotIndex;
var slotData = skeletonData.Slots.Items[t.SlotIndex];
t.SetFrame(0, 0, slotData.R, slotData.G, slotData.B, slotData.A);
return t;
}
static TwoColorTimeline GetFillerTimeline (TwoColorTimeline timeline, SkeletonData skeletonData) {
var t = new TwoColorTimeline(1);
t.slotIndex = timeline.slotIndex;
var slotData = skeletonData.slots.Items[t.slotIndex];
t.SetFrame(0, 0, slotData.r, slotData.g, slotData.b, slotData.a, slotData.r2, slotData.g2, slotData.b2);
t.SlotIndex = timeline.SlotIndex;
var slotData = skeletonData.Slots.Items[t.SlotIndex];
t.SetFrame(0, 0, slotData.R, slotData.G, slotData.B, slotData.A, slotData.R2, slotData.G2, slotData.B2);
return t;
}
static DeformTimeline GetFillerTimeline (DeformTimeline timeline, SkeletonData skeletonData) {
var t = new DeformTimeline(1);
t.slotIndex = timeline.slotIndex;
t.attachment = timeline.attachment;
t.SlotIndex = timeline.SlotIndex;
t.Attachment = timeline.Attachment;
if (t.attachment.IsWeighted()) {
t.SetFrame(0, 0, new float[t.attachment.vertices.Length]);
if (t.Attachment.IsWeighted()) {
t.SetFrame(0, 0, new float[t.Attachment.Vertices.Length]);
} else {
t.SetFrame(0, 0, t.attachment.vertices.Clone() as float[]);
t.SetFrame(0, 0, t.Attachment.Vertices.Clone() as float[]);
}
return t;
@ -223,36 +205,36 @@ namespace Spine.Unity.Examples {
static IkConstraintTimeline GetFillerTimeline (IkConstraintTimeline timeline, SkeletonData skeletonData) {
var t = new IkConstraintTimeline(1);
var ikConstraintData = skeletonData.ikConstraints.Items[timeline.ikConstraintIndex];
t.SetFrame(0, 0, ikConstraintData.mix, ikConstraintData.softness, ikConstraintData.bendDirection, ikConstraintData.compress, ikConstraintData.stretch);
var ikConstraintData = skeletonData.IkConstraints.Items[timeline.IkConstraintIndex];
t.SetFrame(0, 0, ikConstraintData.Mix, ikConstraintData.Softness, ikConstraintData.BendDirection, ikConstraintData.Compress, ikConstraintData.Stretch);
return t;
}
static TransformConstraintTimeline GetFillerTimeline (TransformConstraintTimeline timeline, SkeletonData skeletonData) {
var t = new TransformConstraintTimeline(1);
var data = skeletonData.transformConstraints.Items[timeline.transformConstraintIndex];
t.SetFrame(0, 0, data.rotateMix, data.translateMix, data.scaleMix, data.shearMix);
var data = skeletonData.TransformConstraints.Items[timeline.TransformConstraintIndex];
t.SetFrame(0, 0, data.RotateMix, data.TranslateMix, data.ScaleMix, data.ShearMix);
return t;
}
static PathConstraintPositionTimeline GetFillerTimeline (PathConstraintPositionTimeline timeline, SkeletonData skeletonData) {
var t = new PathConstraintPositionTimeline(1);
var data = skeletonData.pathConstraints.Items[timeline.pathConstraintIndex];
t.SetFrame(0, 0, data.position);
var data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex];
t.SetFrame(0, 0, data.Position);
return t;
}
static PathConstraintSpacingTimeline GetFillerTimeline (PathConstraintSpacingTimeline timeline, SkeletonData skeletonData) {
var t = new PathConstraintSpacingTimeline(1);
var data = skeletonData.pathConstraints.Items[timeline.pathConstraintIndex];
t.SetFrame(0, 0, data.spacing);
var data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex];
t.SetFrame(0, 0, data.Spacing);
return t;
}
static PathConstraintMixTimeline GetFillerTimeline (PathConstraintMixTimeline timeline, SkeletonData skeletonData) {
var t = new PathConstraintMixTimeline(1);
var data = skeletonData.pathConstraints.Items[timeline.pathConstraintIndex];
t.SetFrame(0, 0, data.rotateMix, data.translateMix);
var data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex];
t.SetFrame(0, 0, data.RotateMix, data.TranslateMix);
return t;
}
#endregion

View File

@ -110,7 +110,7 @@ namespace Spine.Unity.Examples {
if (e.Float > 0)
spawnInterval = e.Float;
if (!string.IsNullOrEmpty(e.stringValue))
if (!string.IsNullOrEmpty(e.String))
this.color = HexToColor(e.String);
}
}

View File

@ -205,22 +205,22 @@ namespace Spine.Unity.Examples {
if (disableIK) {
var ikConstraints = skeleton.IkConstraints;
for (int i = 0, n = ikConstraints.Count; i < n; i++)
ikConstraints.Items[i].mix = 0;
ikConstraints.Items[i].Mix = 0;
}
if (disableOtherConstraints) {
var transformConstraints = skeleton.transformConstraints;
var transformConstraints = skeleton.TransformConstraints;
for (int i = 0, n = transformConstraints.Count; i < n; i++) {
transformConstraints.Items[i].rotateMix = 0;
transformConstraints.Items[i].scaleMix = 0;
transformConstraints.Items[i].shearMix = 0;
transformConstraints.Items[i].translateMix = 0;
transformConstraints.Items[i].RotateMix = 0;
transformConstraints.Items[i].ScaleMix = 0;
transformConstraints.Items[i].ShearMix = 0;
transformConstraints.Items[i].TranslateMix = 0;
}
var pathConstraints = skeleton.pathConstraints;
var pathConstraints = skeleton.PathConstraints;
for (int i = 0, n = pathConstraints.Count; i < n; i++) {
pathConstraints.Items[i].rotateMix = 0;
pathConstraints.Items[i].translateMix = 0;
pathConstraints.Items[i].RotateMix = 0;
pathConstraints.Items[i].TranslateMix = 0;
}
}
@ -277,7 +277,7 @@ namespace Spine.Unity.Examples {
#endregion
void RecursivelyCreateBoneProxies (Bone b) {
string boneName = b.data.name;
string boneName = b.Data.Name;
if (stopBoneNames.Contains(boneName))
return;
@ -288,7 +288,7 @@ namespace Spine.Unity.Examples {
t.parent = transform;
t.localPosition = new Vector3(b.WorldX, b.WorldY, 0);
t.localRotation = Quaternion.Euler(0, 0, b.WorldRotationX - b.shearX);
t.localRotation = Quaternion.Euler(0, 0, b.WorldRotationX - b.ShearX);
t.localScale = new Vector3(b.WorldScaleX, b.WorldScaleY, 1);
// MITCH: You left "todo: proper ragdoll branching"
@ -350,9 +350,9 @@ namespace Spine.Unity.Examples {
}
}
b.x = Mathf.Lerp(b.x, boneLocalPosition.x, mix);
b.y = Mathf.Lerp(b.y, boneLocalPosition.y, mix);
b.rotation = Mathf.Lerp(b.rotation, boneLocalRotation, mix);
b.X = Mathf.Lerp(b.X, boneLocalPosition.x, mix);
b.Y = Mathf.Lerp(b.Y, boneLocalPosition.y, mix);
b.Rotation = Mathf.Lerp(b.Rotation, boneLocalRotation, mix);
//b.AppliedRotation = Mathf.Lerp(b.AppliedRotation, boneLocalRotation, mix);
}
}
@ -394,7 +394,7 @@ namespace Spine.Unity.Examples {
float a = b.AppliedRotation;
while (parent != null) {
a += parent.AppliedRotation;
parent = parent.parent;
parent = parent.Parent;
}
return a;
}

View File

@ -200,22 +200,22 @@ namespace Spine.Unity.Examples {
if (disableIK) {
var ikConstraints = skeleton.IkConstraints;
for (int i = 0, n = ikConstraints.Count; i < n; i++)
ikConstraints.Items[i].mix = 0;
ikConstraints.Items[i].Mix = 0;
}
if (disableOtherConstraints) {
var transformConstraints = skeleton.transformConstraints;
var transformConstraints = skeleton.TransformConstraints;
for (int i = 0, n = transformConstraints.Count; i < n; i++) {
transformConstraints.Items[i].rotateMix = 0;
transformConstraints.Items[i].scaleMix = 0;
transformConstraints.Items[i].shearMix = 0;
transformConstraints.Items[i].translateMix = 0;
transformConstraints.Items[i].RotateMix = 0;
transformConstraints.Items[i].ScaleMix = 0;
transformConstraints.Items[i].ShearMix = 0;
transformConstraints.Items[i].TranslateMix = 0;
}
var pathConstraints = skeleton.pathConstraints;
var pathConstraints = skeleton.PathConstraints;
for (int i = 0, n = pathConstraints.Count; i < n; i++) {
pathConstraints.Items[i].rotateMix = 0;
pathConstraints.Items[i].translateMix = 0;
pathConstraints.Items[i].RotateMix = 0;
pathConstraints.Items[i].TranslateMix = 0;
}
}
@ -272,7 +272,7 @@ namespace Spine.Unity.Examples {
/// <summary>Generates the ragdoll simulation's Transform and joint setup.</summary>
void RecursivelyCreateBoneProxies (Bone b) {
string boneName = b.data.name;
string boneName = b.Data.Name;
if (stopBoneNames.Contains(boneName))
return;
@ -283,13 +283,13 @@ namespace Spine.Unity.Examples {
t.parent = transform;
t.localPosition = new Vector3(b.WorldX, b.WorldY, 0);
t.localRotation = Quaternion.Euler(0, 0, b.WorldRotationX - b.shearX);
t.localRotation = Quaternion.Euler(0, 0, b.WorldRotationX - b.ShearX);
t.localScale = new Vector3(b.WorldScaleX, b.WorldScaleY, 0);
// MITCH: You left "todo: proper ragdoll branching"
var colliders = AttachBoundingBoxRagdollColliders(b, boneGameObject, skeleton, this.gravityScale);
if (colliders.Count == 0) {
float length = b.data.length;
float length = b.Data.Length;
if (length == 0) {
var circle = boneGameObject.AddComponent<CircleCollider2D>();
circle.radius = thickness * 0.5f;
@ -348,9 +348,9 @@ namespace Spine.Unity.Examples {
}
}
b.x = Mathf.Lerp(b.x, boneLocalPosition.x, mix);
b.y = Mathf.Lerp(b.y, boneLocalPosition.y, mix);
b.rotation = Mathf.Lerp(b.rotation, boneLocalRotation, mix);
b.X = Mathf.Lerp(b.X, boneLocalPosition.x, mix);
b.Y = Mathf.Lerp(b.Y, boneLocalPosition.y, mix);
b.Rotation = Mathf.Lerp(b.Rotation, boneLocalRotation, mix);
//b.AppliedRotation = Mathf.Lerp(b.AppliedRotation, boneLocalRotation, mix);
}
}
@ -362,7 +362,7 @@ namespace Spine.Unity.Examples {
var skinEntries = new List<Skin.SkinEntry>();
foreach (Slot slot in skeleton.Slots) {
if (slot.bone == b) {
if (slot.Bone == b) {
skin.GetAttachments(skeleton.Slots.IndexOf(slot), skinEntries);
bool bbAttachmentAdded = false;
@ -391,7 +391,7 @@ namespace Spine.Unity.Examples {
float a = b.AppliedRotation;
while (parent != null) {
a += parent.AppliedRotation;
parent = parent.parent;
parent = parent.Parent;
}
return a;
}

View File

@ -47,10 +47,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

View File

@ -47,10 +47,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
@ -75,105 +71,6 @@ namespace Spine.Unity.Editor {
SpineBuildEnvUtility.DisableBuildDefine(SPINE_TK2D_DEFINE);
}
}
public static class SpinePackageDependencyUtility
{
public enum RequestState {
NoRequestIssued = 0,
InProgress,
Success,
Failure
}
#if NEW_TIMELINE_AS_PACKAGE
const string SPINE_TIMELINE_PACKAGE_DOWNLOADED_DEFINE = "SPINE_TIMELINE_PACKAGE_DOWNLOADED";
const string TIMELINE_PACKAGE_NAME = "com.unity.timeline";
const string TIMELINE_ASMDEF_DEPENDENCY_STRING = "\"Unity.Timeline\"";
static UnityEditor.PackageManager.Requests.AddRequest timelineRequest = null;
/// <summary>
/// Enables Spine's Timeline components by downloading the Timeline Package in Unity 2019 and newer
/// and setting respective compile definitions once downloaded.
/// </summary>
internal static void EnableTimelineSupport () {
Debug.Log("Downloading Timeline package " + TIMELINE_PACKAGE_NAME + ".");
timelineRequest = UnityEditor.PackageManager.Client.Add(TIMELINE_PACKAGE_NAME);
// Note: unfortunately there is no callback provided, only polling support.
// So polling HandlePendingAsyncTimelineRequest() is necessary.
EditorApplication.update -= UpdateAsyncTimelineRequest;
EditorApplication.update += UpdateAsyncTimelineRequest;
}
public static void UpdateAsyncTimelineRequest () {
HandlePendingAsyncTimelineRequest();
}
public static RequestState HandlePendingAsyncTimelineRequest () {
if (timelineRequest == null)
return RequestState.NoRequestIssued;
var status = timelineRequest.Status;
if (status == UnityEditor.PackageManager.StatusCode.InProgress) {
return RequestState.InProgress;
}
else {
EditorApplication.update -= UpdateAsyncTimelineRequest;
timelineRequest = null;
if (status == UnityEditor.PackageManager.StatusCode.Failure) {
Debug.LogError("Download of package " + TIMELINE_PACKAGE_NAME + " failed!");
return RequestState.Failure;
}
else { // status == UnityEditor.PackageManager.StatusCode.Success
HandleSuccessfulTimelinePackageDownload();
return RequestState.Success;
}
}
}
internal static void DisableTimelineSupport () {
SpineBuildEnvUtility.DisableBuildDefine(SPINE_TIMELINE_PACKAGE_DOWNLOADED_DEFINE);
SpineBuildEnvUtility.RemoveDependencyFromAsmdefFile(TIMELINE_ASMDEF_DEPENDENCY_STRING);
}
internal static void HandleSuccessfulTimelinePackageDownload () {
#if !SPINE_TK2D
SpineBuildEnvUtility.EnableSpineAsmdefFiles();
#endif
SpineBuildEnvUtility.AddDependencyToAsmdefFile(TIMELINE_ASMDEF_DEPENDENCY_STRING);
SpineBuildEnvUtility.EnableBuildDefine(SPINE_TIMELINE_PACKAGE_DOWNLOADED_DEFINE);
ReimportTimelineScripts();
}
internal static void ReimportTimelineScripts () {
// Note: unfortunately AssetDatabase::Refresh is not enough and
// ImportAsset on a dir does not have the desired effect.
List<string> searchStrings = new List<string>();
searchStrings.Add("SpineAnimationStateBehaviour t:script");
searchStrings.Add("SpineAnimationStateClip t:script");
searchStrings.Add("SpineAnimationStateMixerBehaviour t:script");
searchStrings.Add("SpineAnimationStateTrack t:script");
searchStrings.Add("SpineSkeletonFlipBehaviour t:script");
searchStrings.Add("SpineSkeletonFlipClip t:script");
searchStrings.Add("SpineSkeletonFlipMixerBehaviour t:script");
searchStrings.Add("SpineSkeletonFlipTrack t:script");
searchStrings.Add("SkeletonAnimationPlayableHandle t:script");
searchStrings.Add("SpinePlayableHandleBase t:script");
foreach (string searchString in searchStrings) {
string[] guids = AssetDatabase.FindAssets(searchString);
foreach (string guid in guids) {
string currentPath = AssetDatabase.GUIDToAssetPath(guid);
AssetDatabase.ImportAsset(currentPath, ImportAssetOptions.ForceUpdate);
}
}
}
#endif
}
}
public static class SpineBuildEnvUtility
@ -254,69 +151,6 @@ namespace Spine.Unity.Editor {
SetAsmdefFileActive("spine-unity", true);
}
public static void AddDependencyToAsmdefFile (string dependencyName) {
string asmdefName = "spine-unity";
string filePath = FindAsmdefFile(asmdefName);
if (string.IsNullOrEmpty(filePath))
return;
if (System.IO.File.Exists(filePath)) {
string fileContent = File.ReadAllText(filePath);
if (!fileContent.Contains("references")) {
string nameLine = string.Concat("\"name\": \"", asmdefName, "\"");
fileContent = fileContent.Replace(nameLine,
nameLine +
@",\n""references"": []");
}
if (!fileContent.Contains(dependencyName)) {
fileContent = fileContent.Replace(@"""references"": [",
@"""references"": [" + dependencyName);
File.WriteAllText(filePath, fileContent);
}
}
}
public static void RemoveDependencyFromAsmdefFile (string dependencyName) {
string asmdefName = "spine-unity";
string filePath = FindAsmdefFile(asmdefName);
if (string.IsNullOrEmpty(filePath))
return;
if (System.IO.File.Exists(filePath)) {
string fileContent = File.ReadAllText(filePath);
// this simple implementation shall suffice for now.
if (fileContent.Contains(dependencyName)) {
fileContent = fileContent.Replace(dependencyName, "");
File.WriteAllText(filePath, fileContent);
}
}
}
internal static string FindAsmdefFile (string filename) {
string filePath = FindAsmdefFile(filename, isDisabledFile: false);
if (string.IsNullOrEmpty(filePath))
filePath = FindAsmdefFile(filename, isDisabledFile: true);
return filePath;
}
internal static string FindAsmdefFile (string filename, bool isDisabledFile) {
string typeSearchString = isDisabledFile ? " t:TextAsset" : " t:AssemblyDefinitionAsset";
string extension = isDisabledFile ? ".txt" : ".asmdef";
string filenameWithExtension = filename + (isDisabledFile ? ".txt" : ".asmdef");
string[] guids = AssetDatabase.FindAssets(filename + typeSearchString);
foreach (string guid in guids) {
string currentPath = AssetDatabase.GUIDToAssetPath(guid);
if (!string.IsNullOrEmpty(currentPath)) {
if (System.IO.Path.GetFileName(currentPath) == filenameWithExtension)
return currentPath;
}
}
return null;
}
internal static void SetAsmdefFileActive (string filename, bool setActive) {
string typeSearchString = setActive ? " t:TextAsset" : " t:AssemblyDefinitionAsset";

View File

@ -47,10 +47,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

View File

@ -47,10 +47,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

View File

@ -47,10 +47,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

View File

@ -47,10 +47,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
@ -251,22 +247,6 @@ namespace Spine.Unity.Editor {
SceneView.RepaintAll();
}
}
#if NEW_TIMELINE_AS_PACKAGE
GUILayout.Space(20);
EditorGUILayout.LabelField("Timeline Support", EditorStyles.boldLabel);
using (new GUILayout.HorizontalScope()) {
EditorGUILayout.PrefixLabel("Timeline Package Support");
var requestState = SpineEditorUtilities.SpinePackageDependencyUtility.HandlePendingAsyncTimelineRequest();
using (new EditorGUI.DisabledGroupScope(requestState != SpineEditorUtilities.SpinePackageDependencyUtility.RequestState.NoRequestIssued)) {
if (GUILayout.Button("Enable", GUILayout.Width(64)))
SpineEditorUtilities.SpinePackageDependencyUtility.EnableTimelineSupport();
if (GUILayout.Button("Disable", GUILayout.Width(64)))
SpineEditorUtilities.SpinePackageDependencyUtility.DisableTimelineSupport();
}
}
#endif
GUILayout.Space(20);
EditorGUILayout.LabelField("3rd Party Settings", EditorStyles.boldLabel);

View File

@ -50,10 +50,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

View File

@ -47,10 +47,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

View File

@ -35,10 +35,6 @@
#define NEW_PREFERENCES_SETTINGS_PROVIDER
#endif
#if UNITY_2019_1_OR_NEWER
#define NEW_TIMELINE_AS_PACKAGE
#endif
using UnityEngine;
using UnityEditor;
using System.Threading;
@ -171,22 +167,6 @@ namespace Spine.Unity.Editor {
}
}
#if NEW_TIMELINE_AS_PACKAGE
GUILayout.Space(20);
EditorGUILayout.LabelField("Timeline Support", EditorStyles.boldLabel);
using (new GUILayout.HorizontalScope()) {
EditorGUILayout.PrefixLabel("Timeline Package Support");
var requestState = SpineEditorUtilities.SpinePackageDependencyUtility.HandlePendingAsyncTimelineRequest();
using (new EditorGUI.DisabledGroupScope(requestState != SpineEditorUtilities.SpinePackageDependencyUtility.RequestState.NoRequestIssued)) {
if (GUILayout.Button("Enable", GUILayout.Width(64)))
SpineEditorUtilities.SpinePackageDependencyUtility.EnableTimelineSupport();
if (GUILayout.Button("Disable", GUILayout.Width(64)))
SpineEditorUtilities.SpinePackageDependencyUtility.DisableTimelineSupport();
}
}
#endif
GUILayout.Space(20);
EditorGUILayout.LabelField("3rd Party Settings", EditorStyles.boldLabel);
using (new GUILayout.HorizontalScope()) {

View File

@ -222,7 +222,7 @@ namespace Spine.Unity {
#region API
protected Skeleton skeleton;
public Skeleton Skeleton { get { return skeleton; } internal set { skeleton = value; } }
public Skeleton Skeleton { get { return skeleton; } set { skeleton = value; } }
public SkeletonData SkeletonData { get { return skeleton == null ? null : skeleton.data; } }
public bool IsValid { get { return skeleton != null; } }

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 9192f99585e00e2468a2e2592cfce807
folderAsset: yes
timeCreated: 1505434717
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,7 @@
// Upgrade NOTE: upgraded instancing buffer 'PerDrawSprite' to new syntax.
// Upgrade NOTE: upgraded instancing buffer 'PerDrawSprite' to new syntax.
#ifndef SHADER_SHARED_INCLUDED
#define SHADER_SHARED_INCLUDED
@ -11,12 +13,12 @@
#ifdef UNITY_INSTANCING_ENABLED
UNITY_INSTANCING_CBUFFER_START(PerDrawSprite)
UNITY_INSTANCING_BUFFER_START(PerDrawSprite)
// SpriteRenderer.Color while Non-Batched/Instanced.
fixed4 unity_SpriteRendererColorArray[UNITY_INSTANCED_ARRAY_SIZE];
// this could be smaller but that's how bit each entry is regardless of type
float4 unity_SpriteFlipArray[UNITY_INSTANCED_ARRAY_SIZE];
UNITY_INSTANCING_CBUFFER_END
UNITY_INSTANCING_BUFFER_END(PerDrawSprite)
#define _RendererColor unity_SpriteRendererColorArray[unity_InstanceID]
#define _Flip unity_SpriteFlipArray[unity_InstanceID]

View File

@ -27,7 +27,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using UnityEditor;
using UnityEngine;
using UnityEngine.Playables;
@ -53,4 +52,3 @@ public class SpineSkeletonFlipDrawer : PropertyDrawer
EditorGUI.PropertyField(singleFieldRect, flipYProp);
}
}
#endif

View File

@ -0,0 +1,16 @@
{
"name": "spine-timeline-editor",
"references": [
"spine-unity",
"spine-timeline"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1e7d09e628f0eb342b6a8ab5b3c0d487
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,26 @@
# Spine Runtimes License Agreement
Last updated May 1, 2019. Replaces all prior versions.
Copyright (c) 2013-2019, Esoteric Software LLC
Integration of the Spine Runtimes into software or otherwise creating
derivative works of the Spine Runtimes is permitted under the terms and
conditions of Section 2 of the Spine Editor License Agreement:
http://esotericsoftware.com/spine-editor-license
Otherwise, it is permitted to integrate the Spine Runtimes into software
or otherwise create derivative works of the Spine Runtimes (collectively,
"Products"), provided that each user of the Products must obtain their own
Spine Editor license and redistribution of the Products in any form must
include this license and copyright notice.
THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4c940982dfcc1724a93981844b99fa28
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +1,8 @@
fileFormatVersion: 2
guid: b7ef9595ebe8c204a8a4f251a55d4d22
guid: e204f4f677edeef4aa2328ce87780b43
folderAsset: yes
timeCreated: 1527569508
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -53,13 +53,11 @@ namespace Spine.Unity.Playables {
#endregion
public override Skeleton Skeleton { get { return skeletonAnimation.Skeleton; } }
public override SkeletonData SkeletonData { get { return skeletonAnimation.Skeleton.data; } }
public override SkeletonData SkeletonData { get { return skeletonAnimation.Skeleton.Data; } }
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
void Awake () {
if (skeletonAnimation == null)
skeletonAnimation = GetComponent<SkeletonAnimation>();
}
#endif
}
}

View File

@ -27,7 +27,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using System;
using UnityEngine;
using UnityEngine.Playables;
@ -60,4 +59,3 @@ namespace Spine.Unity.Playables {
}
}
#endif

View File

@ -27,7 +27,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using System;
using UnityEngine;
using UnityEngine.Playables;
@ -48,4 +47,3 @@ namespace Spine.Unity.Playables {
}
}
#endif

View File

@ -29,7 +29,6 @@
#define SPINE_EDITMODEPOSE
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using System;
using UnityEngine;
using UnityEngine.Playables;
@ -155,8 +154,8 @@ namespace Spine.Unity.Playables {
dummyAnimationState = dummyAnimationState ?? new AnimationState(spineComponent.skeletonDataAsset.GetAnimationStateData());
var toTrack = dummyAnimationState.GetCurrent(0);
var fromTrack = toTrack != null ? toTrack.mixingFrom : null;
bool isAnimationTransitionMatch = (toTrack != null && toTrack.animation == toAnimation && fromTrack != null && fromTrack.animation == fromAnimation);
var fromTrack = toTrack != null ? toTrack.MixingFrom : null;
bool isAnimationTransitionMatch = (toTrack != null && toTrack.Animation == toAnimation && fromTrack != null && fromTrack.Animation == fromAnimation);
if (!isAnimationTransitionMatch) {
dummyAnimationState.ClearTracks();
@ -167,10 +166,10 @@ namespace Spine.Unity.Playables {
}
// Update track times.
fromTrack.trackTime = fromClipTime;
fromTrack.TrackTime = fromClipTime;
if (toTrack != null) {
toTrack.trackTime = toClipTime;
toTrack.mixTime = toClipTime;
toTrack.TrackTime = toClipTime;
toTrack.MixTime = toClipTime;
}
// Apply Pose
@ -192,4 +191,3 @@ namespace Spine.Unity.Playables {
}
}
#endif

View File

@ -27,7 +27,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
@ -47,4 +46,3 @@ namespace Spine.Unity.Playables {
}
}
}
#endif

View File

@ -27,7 +27,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using System;
using UnityEngine;
using UnityEngine.Playables;
@ -37,4 +36,3 @@ using UnityEngine.Timeline;
public class SpineSkeletonFlipBehaviour : PlayableBehaviour {
public bool flipX, flipY;
}
#endif

View File

@ -27,7 +27,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using System;
using UnityEngine;
using UnityEngine.Playables;
@ -46,4 +45,3 @@ public class SpineSkeletonFlipClip : PlayableAsset, ITimelineClipAsset {
return playable;
}
}
#endif

View File

@ -27,8 +27,7 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using System;
using System;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
@ -105,4 +104,3 @@ namespace Spine.Unity.Playables {
}
}
#endif

View File

@ -27,8 +27,7 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2017 || UNITY_2018 || (UNITY_2019_1_OR_NEWER && SPINE_TIMELINE_PACKAGE_DOWNLOADED)
using UnityEngine;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
using System.Collections.Generic;
@ -64,4 +63,3 @@ namespace Spine.Unity.Playables {
}
}
}
#endif

View File

@ -0,0 +1,16 @@
{
"name": "spine-timeline",
"references": [
"spine-unity",
"Unity.Timeline"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d081815e631c29f46ab6f2ac745854df
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
{
"name": "com.esotericsoftware.spine.timeline",
"displayName": "Spine Timeline Extensions",
"description": "This plugin provides integration of spine-unity for the Unity Timeline.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
"version": "3.8.0",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",
"email": "contact@esotericsoftware.com",
"url": "http://esotericsoftware.com/"
},
"dependencies": {
"com.unity.timeline": "1.0.0"
},
"keywords": [
"spine",
"timeline"
]
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 591b30eac7c750e4d8b4cf9d09a80351
PackageManifestImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: