This commit is contained in:
badlogic 2018-04-20 13:58:45 +02:00
commit ae58c8232f
9 changed files with 118 additions and 18 deletions

View File

@ -47,16 +47,16 @@ namespace Spine {
public float DefaultMix { get { return defaultMix; } set { defaultMix = value; } }
public AnimationStateData (SkeletonData skeletonData) {
if (skeletonData == null) throw new ArgumentException ("skeletonData cannot be null.");
if (skeletonData == null) throw new ArgumentException("skeletonData cannot be null.", "skeletonData");
this.skeletonData = skeletonData;
}
/// <summary>Sets a mix duration by animation names.</summary>
public void SetMix (string fromName, string toName, float duration) {
Animation from = skeletonData.FindAnimation(fromName);
if (from == null) throw new ArgumentException("Animation not found: " + fromName);
if (from == null) throw new ArgumentException("Animation not found: " + fromName, "fromName");
Animation to = skeletonData.FindAnimation(toName);
if (to == null) throw new ArgumentException("Animation not found: " + toName);
if (to == null) throw new ArgumentException("Animation not found: " + toName, "toName");
SetMix(from, to, duration);
}
@ -83,7 +83,7 @@ namespace Spine {
return defaultMix;
}
struct AnimationPair {
public struct AnimationPair {
public readonly Animation a1;
public readonly Animation a2;
@ -98,8 +98,8 @@ namespace Spine {
}
// Avoids boxing in the dictionary.
class AnimationPairComparer : IEqualityComparer<AnimationPair> {
internal static readonly AnimationPairComparer Instance = new AnimationPairComparer();
public class AnimationPairComparer : IEqualityComparer<AnimationPair> {
public static readonly AnimationPairComparer Instance = new AnimationPairComparer();
bool IEqualityComparer<AnimationPair>.Equals (AnimationPair x, AnimationPair y) {
return ReferenceEquals(x.a1, y.a1) && ReferenceEquals(x.a2, y.a2);

View File

@ -173,16 +173,12 @@ namespace Spine {
d = ld;
worldX = x + skeleton.x;
worldY = y + skeleton.y;
// worldSignX = Math.Sign(scaleX);
// worldSignY = Math.Sign(scaleY);
return;
}
float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
worldX = pa * x + pb * y + parent.worldX;
worldY = pc * x + pd * y + parent.worldY;
// worldSignX = parent.worldSignX * Math.Sign(scaleX);
// worldSignY = parent.worldSignY * Math.Sign(scaleY);
switch (data.transformMode) {
case TransformMode.Normal: {

View File

@ -27,7 +27,7 @@ namespace Spine.Unity.Examples {
hipBone = skeleton.FindBone(hip);
headBone = skeleton.FindBone(head);
baseHeadRotation = headBone.rotation;
baseHeadRotation = headBone.Rotation;
skeletonAnimation.UpdateLocal += UpdateLocal;
}
@ -35,8 +35,8 @@ namespace Spine.Unity.Examples {
private void UpdateLocal (ISkeletonAnimation animated) {
hipRotationTarget = planter.Balance * hipTiltScale;
hipRotationSmoothed = Mathf.MoveTowards(hipRotationSmoothed, hipRotationTarget, Time.deltaTime * hipRotationMoveScale * Mathf.Abs(2f * planter.Balance / planter.offBalanceThreshold));
hipBone.rotation = hipRotationSmoothed;
headBone.rotation = baseHeadRotation + (-hipRotationSmoothed * headTiltScale);
hipBone.Rotation = hipRotationSmoothed;
headBone.Rotation = baseHeadRotation + (-hipRotationSmoothed * headTiltScale);
}
}

View File

@ -48,11 +48,11 @@ namespace Spine.Unity.Examples {
shockTimer -= Time.deltaTime;
if (shockTimer > 0) {
eyeSlot.attachment = shockEye;
mouthSlot.attachment = shockMouth;
eyeSlot.Attachment = shockEye;
mouthSlot.Attachment = shockMouth;
} else {
eyeSlot.attachment = normalEye;
mouthSlot.attachment = normalMouth;
eyeSlot.Attachment = normalEye;
mouthSlot.Attachment = normalMouth;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

View File

@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: d7a76922e4dd9fa429da15c018ff127f
timeCreated: 1524196821
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -238,6 +238,12 @@ namespace Spine.Unity.Editor {
AssetDatabase.CreateAsset(newAsset, assetPath);
}
}
var folderObject = AssetDatabase.LoadAssetAtPath(dataPath, typeof(UnityEngine.Object));
if (folderObject != null) {
Selection.activeObject = folderObject;
EditorGUIUtility.PingObject(folderObject);
}
}
void OnInspectorGUIMulti () {

View File

@ -75,6 +75,7 @@ namespace Spine.Unity.Editor {
}
SerializedProperty dataField = property.FindBaseOrSiblingProperty(TargetAttribute.dataField);
if (dataField != null) {
var objectReferenceValue = dataField.objectReferenceValue;
if (objectReferenceValue is SkeletonDataAsset) {

View File

@ -61,6 +61,7 @@ namespace Spine.Unity.Editor {
public static Texture2D image;
public static Texture2D genericAttachment;
public static Texture2D boundingBox;
public static Texture2D point;
public static Texture2D mesh;
public static Texture2D weights;
public static Texture2D path;
@ -102,6 +103,7 @@ namespace Spine.Unity.Editor {
genericAttachment = LoadIcon("icon-attachment.png");
image = LoadIcon("icon-image.png");
boundingBox = LoadIcon("icon-boundingBox.png");
point = LoadIcon("icon-point.png");
mesh = LoadIcon("icon-mesh.png");
weights = LoadIcon("icon-weights.png");
path = LoadIcon("icon-path.png");
@ -140,6 +142,8 @@ namespace Spine.Unity.Editor {
return ((MeshAttachment)attachment).IsWeighted() ? Icons.weights : Icons.mesh;
else if (attachment is BoundingBoxAttachment)
return Icons.boundingBox;
else if (attachment is PointAttachment)
return Icons.point;
else if (attachment is PathAttachment)
return Icons.path;
else if (attachment is ClippingAttachment)
@ -284,7 +288,6 @@ namespace Spine.Unity.Editor {
defaultShader = shader != null ? shader.name : DEFAULT_DEFAULT_SHADER;
if (EditorGUI.EndChangeCheck())
EditorPrefs.SetString(DEFAULT_SHADER_KEY, defaultShader);
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
setTextureImporterSettings = EditorGUILayout.Toggle(new GUIContent("Apply Atlas Texture Settings", "Apply the recommended settings for Texture Importers."), showHierarchyIcons);
@ -292,6 +295,8 @@ namespace Spine.Unity.Editor {
EditorPrefs.SetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, showHierarchyIcons);
}
EditorGUILayout.Space();
EditorGUILayout.LabelField("Editor Instantiation", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
defaultZSpacing = EditorGUILayout.Slider("Default Slot Z-Spacing", defaultZSpacing, -0.1f, 0f);