mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch '3.8' of https://github.com/EsotericSoftware/spine-runtimes into 3.8
This commit is contained in:
commit
df435cdfc7
@ -160,6 +160,8 @@ namespace Spine {
|
|||||||
copy.regionHeight = regionHeight;
|
copy.regionHeight = regionHeight;
|
||||||
copy.regionOriginalWidth = regionOriginalWidth;
|
copy.regionOriginalWidth = regionOriginalWidth;
|
||||||
copy.regionOriginalHeight = regionOriginalHeight;
|
copy.regionOriginalHeight = regionOriginalHeight;
|
||||||
|
copy.RegionRotate = RegionRotate;
|
||||||
|
copy.RegionDegrees = RegionDegrees;
|
||||||
copy.Path = Path;
|
copy.Path = Path;
|
||||||
copy.r = r;
|
copy.r = r;
|
||||||
copy.g = g;
|
copy.g = g;
|
||||||
@ -195,6 +197,8 @@ namespace Spine {
|
|||||||
mesh.regionHeight = regionHeight;
|
mesh.regionHeight = regionHeight;
|
||||||
mesh.regionOriginalWidth = regionOriginalWidth;
|
mesh.regionOriginalWidth = regionOriginalWidth;
|
||||||
mesh.regionOriginalHeight = regionOriginalHeight;
|
mesh.regionOriginalHeight = regionOriginalHeight;
|
||||||
|
mesh.RegionDegrees = RegionDegrees;
|
||||||
|
mesh.RegionRotate = RegionRotate;
|
||||||
|
|
||||||
mesh.Path = Path;
|
mesh.Path = Path;
|
||||||
mesh.r = r;
|
mesh.r = r;
|
||||||
|
|||||||
@ -170,6 +170,7 @@ namespace Spine.Unity.Examples {
|
|||||||
if (skinName != "")
|
if (skinName != "")
|
||||||
skin = skeletonData.FindSkin(skinName);
|
skin = skeletonData.FindSkin(skinName);
|
||||||
|
|
||||||
|
if (skin != null)
|
||||||
skin.SetAttachment(slotIndex, att.Name, att);
|
skin.SetAttachment(slotIndex, att.Name, att);
|
||||||
|
|
||||||
return att;
|
return att;
|
||||||
|
|||||||
@ -497,13 +497,16 @@ namespace Spine.Unity.Editor {
|
|||||||
using (new SpineInspectorUtility.IndentScope()) {
|
using (new SpineInspectorUtility.IndentScope()) {
|
||||||
{
|
{
|
||||||
skin.GetAttachments(i, slotAttachments);
|
skin.GetAttachments(i, slotAttachments);
|
||||||
|
if (defaultSkin != null) {
|
||||||
if (skin != defaultSkin) {
|
if (skin != defaultSkin) {
|
||||||
defaultSkin.GetAttachments(i, slotAttachments);
|
defaultSkin.GetAttachments(i, slotAttachments);
|
||||||
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int a = 0; a < slotAttachments.Count; a++) {
|
for (int a = 0; a < slotAttachments.Count; a++) {
|
||||||
var skinEntry = slotAttachments[a];
|
var skinEntry = slotAttachments[a];
|
||||||
|
|||||||
@ -39,7 +39,7 @@ namespace Spine.Unity.Editor {
|
|||||||
[CustomEditor(typeof(BoneFollowerGraphic)), CanEditMultipleObjects]
|
[CustomEditor(typeof(BoneFollowerGraphic)), CanEditMultipleObjects]
|
||||||
public class BoneFollowerGraphicInspector : Editor {
|
public class BoneFollowerGraphicInspector : Editor {
|
||||||
|
|
||||||
SerializedProperty boneName, skeletonGraphic, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip;
|
SerializedProperty boneName, skeletonGraphic, followXYPosition, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip;
|
||||||
BoneFollowerGraphic targetBoneFollower;
|
BoneFollowerGraphic targetBoneFollower;
|
||||||
bool needsReset;
|
bool needsReset;
|
||||||
|
|
||||||
@ -73,6 +73,7 @@ namespace Spine.Unity.Editor {
|
|||||||
skeletonGraphic = serializedObject.FindProperty("skeletonGraphic");
|
skeletonGraphic = serializedObject.FindProperty("skeletonGraphic");
|
||||||
boneName = serializedObject.FindProperty("boneName");
|
boneName = serializedObject.FindProperty("boneName");
|
||||||
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
||||||
|
followXYPosition = serializedObject.FindProperty("followXYPosition");
|
||||||
followZPosition = serializedObject.FindProperty("followZPosition");
|
followZPosition = serializedObject.FindProperty("followZPosition");
|
||||||
followLocalScale = serializedObject.FindProperty("followLocalScale");
|
followLocalScale = serializedObject.FindProperty("followLocalScale");
|
||||||
followSkeletonFlip = serializedObject.FindProperty("followSkeletonFlip");
|
followSkeletonFlip = serializedObject.FindProperty("followSkeletonFlip");
|
||||||
@ -166,6 +167,7 @@ namespace Spine.Unity.Editor {
|
|||||||
needsReset |= EditorGUI.EndChangeCheck();
|
needsReset |= EditorGUI.EndChangeCheck();
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(followBoneRotation);
|
EditorGUILayout.PropertyField(followBoneRotation);
|
||||||
|
EditorGUILayout.PropertyField(followXYPosition);
|
||||||
EditorGUILayout.PropertyField(followZPosition);
|
EditorGUILayout.PropertyField(followZPosition);
|
||||||
EditorGUILayout.PropertyField(followLocalScale);
|
EditorGUILayout.PropertyField(followLocalScale);
|
||||||
EditorGUILayout.PropertyField(followSkeletonFlip);
|
EditorGUILayout.PropertyField(followSkeletonFlip);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace Spine.Unity.Editor {
|
|||||||
|
|
||||||
[CustomEditor(typeof(BoneFollower)), CanEditMultipleObjects]
|
[CustomEditor(typeof(BoneFollower)), CanEditMultipleObjects]
|
||||||
public class BoneFollowerInspector : Editor {
|
public class BoneFollowerInspector : Editor {
|
||||||
SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip;
|
SerializedProperty boneName, skeletonRenderer, followXYPosition, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip;
|
||||||
BoneFollower targetBoneFollower;
|
BoneFollower targetBoneFollower;
|
||||||
bool needsReset;
|
bool needsReset;
|
||||||
|
|
||||||
@ -82,6 +82,7 @@ namespace Spine.Unity.Editor {
|
|||||||
skeletonRenderer = serializedObject.FindProperty("skeletonRenderer");
|
skeletonRenderer = serializedObject.FindProperty("skeletonRenderer");
|
||||||
boneName = serializedObject.FindProperty("boneName");
|
boneName = serializedObject.FindProperty("boneName");
|
||||||
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
||||||
|
followXYPosition = serializedObject.FindProperty("followXYPosition");
|
||||||
followZPosition = serializedObject.FindProperty("followZPosition");
|
followZPosition = serializedObject.FindProperty("followZPosition");
|
||||||
followLocalScale = serializedObject.FindProperty("followLocalScale");
|
followLocalScale = serializedObject.FindProperty("followLocalScale");
|
||||||
followSkeletonFlip = serializedObject.FindProperty("followSkeletonFlip");
|
followSkeletonFlip = serializedObject.FindProperty("followSkeletonFlip");
|
||||||
@ -172,6 +173,7 @@ namespace Spine.Unity.Editor {
|
|||||||
needsReset |= EditorGUI.EndChangeCheck();
|
needsReset |= EditorGUI.EndChangeCheck();
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(followBoneRotation);
|
EditorGUILayout.PropertyField(followBoneRotation);
|
||||||
|
EditorGUILayout.PropertyField(followXYPosition);
|
||||||
EditorGUILayout.PropertyField(followZPosition);
|
EditorGUILayout.PropertyField(followZPosition);
|
||||||
EditorGUILayout.PropertyField(followLocalScale);
|
EditorGUILayout.PropertyField(followLocalScale);
|
||||||
EditorGUILayout.PropertyField(followSkeletonFlip);
|
EditorGUILayout.PropertyField(followSkeletonFlip);
|
||||||
|
|||||||
@ -582,7 +582,7 @@ namespace Spine.Unity.Editor {
|
|||||||
attachmentTable.Add(skeleton.Slots.Items[i], attachments);
|
attachmentTable.Add(skeleton.Slots.Items[i], attachments);
|
||||||
// Add skin attachments.
|
// Add skin attachments.
|
||||||
skin.GetAttachments(i, attachments);
|
skin.GetAttachments(i, attachments);
|
||||||
if (notDefaultSkin) // Add default skin attachments.
|
if (notDefaultSkin && defaultSkin != null) // Add default skin attachments.
|
||||||
defaultSkin.GetAttachments(i, attachments);
|
defaultSkin.GetAttachments(i, attachments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,7 @@ namespace Spine.Unity {
|
|||||||
[SpineBone(dataField: "skeletonRenderer")]
|
[SpineBone(dataField: "skeletonRenderer")]
|
||||||
[SerializeField] public string boneName;
|
[SerializeField] public string boneName;
|
||||||
|
|
||||||
|
public bool followXYPosition = true;
|
||||||
public bool followZPosition = true;
|
public bool followZPosition = true;
|
||||||
public bool followBoneRotation = true;
|
public bool followBoneRotation = true;
|
||||||
|
|
||||||
@ -142,7 +143,9 @@ namespace Spine.Unity {
|
|||||||
Transform thisTransform = this.transform;
|
Transform thisTransform = this.transform;
|
||||||
if (skeletonTransformIsParent) {
|
if (skeletonTransformIsParent) {
|
||||||
// Recommended setup: Use local transform properties if Spine GameObject is the immediate parent
|
// Recommended setup: Use local transform properties if Spine GameObject is the immediate parent
|
||||||
thisTransform.localPosition = new Vector3(bone.worldX, bone.worldY, followZPosition ? 0f : thisTransform.localPosition.z);
|
thisTransform.localPosition = new Vector3(followXYPosition ? bone.worldX : thisTransform.localPosition.x,
|
||||||
|
followXYPosition ? bone.worldY : thisTransform.localPosition.y,
|
||||||
|
followZPosition ? 0f : thisTransform.localPosition.z);
|
||||||
if (followBoneRotation) {
|
if (followBoneRotation) {
|
||||||
float halfRotation = Mathf.Atan2(bone.c, bone.a) * 0.5f;
|
float halfRotation = Mathf.Atan2(bone.c, bone.a) * 0.5f;
|
||||||
if (followLocalScale && bone.scaleX < 0) // Negate rotation from negative scaleX. Don't use negative determinant. local scaleY doesn't factor into used rotation.
|
if (followLocalScale && bone.scaleX < 0) // Negate rotation from negative scaleX. Don't use negative determinant. local scaleY doesn't factor into used rotation.
|
||||||
@ -157,6 +160,10 @@ namespace Spine.Unity {
|
|||||||
// For special cases: Use transform world properties if transform relationship is complicated
|
// For special cases: Use transform world properties if transform relationship is complicated
|
||||||
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, 0f));
|
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, 0f));
|
||||||
if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
|
if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
|
||||||
|
if (!followXYPosition) {
|
||||||
|
targetWorldPosition.x = thisTransform.position.x;
|
||||||
|
targetWorldPosition.y = thisTransform.position.y;
|
||||||
|
}
|
||||||
|
|
||||||
float boneWorldRotation = bone.WorldRotationX;
|
float boneWorldRotation = bone.WorldRotationX;
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,7 @@ namespace Spine.Unity {
|
|||||||
public bool followSkeletonFlip = true;
|
public bool followSkeletonFlip = true;
|
||||||
[Tooltip("Follows the target bone's local scale. BoneFollower cannot inherit world/skewed scale because of UnityEngine.Transform property limitations.")]
|
[Tooltip("Follows the target bone's local scale. BoneFollower cannot inherit world/skewed scale because of UnityEngine.Transform property limitations.")]
|
||||||
public bool followLocalScale = false;
|
public bool followLocalScale = false;
|
||||||
|
public bool followXYPosition = true;
|
||||||
public bool followZPosition = true;
|
public bool followZPosition = true;
|
||||||
|
|
||||||
[System.NonSerialized] public Bone bone;
|
[System.NonSerialized] public Bone bone;
|
||||||
@ -134,12 +135,18 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
if (skeletonTransformIsParent) {
|
if (skeletonTransformIsParent) {
|
||||||
// Recommended setup: Use local transform properties if Spine GameObject is the immediate parent
|
// Recommended setup: Use local transform properties if Spine GameObject is the immediate parent
|
||||||
thisTransform.localPosition = new Vector3(bone.worldX * scale, bone.worldY * scale, followZPosition ? 0f : thisTransform.localPosition.z);
|
thisTransform.localPosition = new Vector3(followXYPosition ? bone.worldX * scale : thisTransform.localPosition.x,
|
||||||
|
followXYPosition ? bone.worldY * scale : thisTransform.localPosition.y,
|
||||||
|
followZPosition ? 0f : thisTransform.localPosition.z);
|
||||||
if (followBoneRotation) thisTransform.localRotation = bone.GetQuaternion();
|
if (followBoneRotation) thisTransform.localRotation = bone.GetQuaternion();
|
||||||
} else {
|
} else {
|
||||||
// For special cases: Use transform world properties if transform relationship is complicated
|
// For special cases: Use transform world properties if transform relationship is complicated
|
||||||
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX * scale, bone.worldY * scale, 0f));
|
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX * scale, bone.worldY * scale, 0f));
|
||||||
if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
|
if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
|
||||||
|
if (!followXYPosition) {
|
||||||
|
targetWorldPosition.x = thisTransform.position.x;
|
||||||
|
targetWorldPosition.y = thisTransform.position.y;
|
||||||
|
}
|
||||||
|
|
||||||
float boneWorldRotation = bone.WorldRotationX;
|
float boneWorldRotation = bone.WorldRotationX;
|
||||||
|
|
||||||
|
|||||||
@ -289,7 +289,7 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
var repackedRegions = new List<AtlasRegion>();
|
var repackedRegions = new List<AtlasRegion>();
|
||||||
for (int i = 0, n = originalRegions.Count; i < n; i++) {
|
for (int i = 0, n = originalRegions.Count; i < n; i++) {
|
||||||
var oldRegion = originalRegions[i];
|
var oldRegion = originalRegions[i];
|
||||||
var newRegion = UVRectToAtlasRegion(rects[i], oldRegion.name, page, oldRegion.offsetX, oldRegion.offsetY, oldRegion.rotate);
|
var newRegion = UVRectToAtlasRegion(rects[i], oldRegion, page);
|
||||||
repackedRegions.Add(newRegion);
|
repackedRegions.Add(newRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
var repackedRegions = new List<AtlasRegion>();
|
var repackedRegions = new List<AtlasRegion>();
|
||||||
for (int i = 0, n = originalRegions.Count; i < n; i++) {
|
for (int i = 0, n = originalRegions.Count; i < n; i++) {
|
||||||
var oldRegion = originalRegions[i];
|
var oldRegion = originalRegions[i];
|
||||||
var newRegion = UVRectToAtlasRegion(rects[i], oldRegion.name, page, oldRegion.offsetX, oldRegion.offsetY, oldRegion.rotate);
|
var newRegion = UVRectToAtlasRegion(rects[i], oldRegion, page);
|
||||||
repackedRegions.Add(newRegion);
|
repackedRegions.Add(newRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
CachedRegionTextures.TryGetValue(ar, out output);
|
CachedRegionTextures.TryGetValue(ar, out output);
|
||||||
if (output == null) {
|
if (output == null) {
|
||||||
Texture2D sourceTexture = ar.GetMainTexture();
|
Texture2D sourceTexture = ar.GetMainTexture();
|
||||||
Rect r = ar.GetUnityRect(sourceTexture.height);
|
Rect r = ar.GetUnityRect();
|
||||||
int width = (int)r.width;
|
int width = (int)r.width;
|
||||||
int height = (int)r.height;
|
int height = (int)r.height;
|
||||||
output = new Texture2D(width, height, textureFormat, mipmaps) { name = ar.name };
|
output = new Texture2D(width, height, textureFormat, mipmaps) { name = ar.name };
|
||||||
@ -516,13 +516,13 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new Spine AtlasRegion according to a Unity UV Rect (x-right, y-up, uv-normalized).</summary>
|
/// Creates a new Spine AtlasRegion according to a Unity UV Rect (x-right, y-up, uv-normalized).</summary>
|
||||||
static AtlasRegion UVRectToAtlasRegion (Rect uvRect, string name, AtlasPage page, float offsetX, float offsetY, bool rotate) {
|
static AtlasRegion UVRectToAtlasRegion (Rect uvRect, AtlasRegion referenceRegion, AtlasPage page) {
|
||||||
var tr = UVRectToTextureRect(uvRect, page.width, page.height);
|
var tr = UVRectToTextureRect(uvRect, page.width, page.height);
|
||||||
var rr = tr.SpineUnityFlipRect(page.height);
|
var rr = tr.SpineUnityFlipRect(page.height);
|
||||||
|
|
||||||
int x = (int)rr.x, y = (int)rr.y;
|
int x = (int)rr.x, y = (int)rr.y;
|
||||||
int w, h;
|
int w, h;
|
||||||
if (rotate) {
|
if (referenceRegion.rotate) {
|
||||||
w = (int)rr.height;
|
w = (int)rr.height;
|
||||||
h = (int)rr.width;
|
h = (int)rr.width;
|
||||||
} else {
|
} else {
|
||||||
@ -530,9 +530,14 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
h = (int)rr.height;
|
h = (int)rr.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int originalW = Mathf.RoundToInt((float)w * ((float)referenceRegion.originalWidth / (float)referenceRegion.width));
|
||||||
|
int originalH = Mathf.RoundToInt((float)h * ((float)referenceRegion.originalHeight / (float)referenceRegion.height));
|
||||||
|
int offsetX = Mathf.RoundToInt((float)referenceRegion.offsetX * ((float)w / (float)referenceRegion.width));
|
||||||
|
int offsetY = Mathf.RoundToInt((float)referenceRegion.offsetY * ((float)h / (float)referenceRegion.height));
|
||||||
|
|
||||||
return new AtlasRegion {
|
return new AtlasRegion {
|
||||||
page = page,
|
page = page,
|
||||||
name = name,
|
name = referenceRegion.name,
|
||||||
|
|
||||||
u = uvRect.xMin,
|
u = uvRect.xMin,
|
||||||
u2 = uvRect.xMax,
|
u2 = uvRect.xMax,
|
||||||
@ -542,15 +547,15 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
index = -1,
|
index = -1,
|
||||||
|
|
||||||
width = w,
|
width = w,
|
||||||
originalWidth = w,
|
originalWidth = originalW,
|
||||||
height = h,
|
height = h,
|
||||||
originalHeight = h,
|
originalHeight = originalH,
|
||||||
offsetX = offsetX,
|
offsetX = offsetX,
|
||||||
offsetY = offsetY,
|
offsetY = offsetY,
|
||||||
x = x,
|
x = x,
|
||||||
y = y,
|
y = y,
|
||||||
|
|
||||||
rotate = rotate
|
rotate = referenceRegion.rotate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
var defaultSkin = skeleton.data.DefaultSkin;
|
var defaultSkin = skeleton.data.DefaultSkin;
|
||||||
var activeSkin = skeleton.skin;
|
var activeSkin = skeleton.skin;
|
||||||
|
|
||||||
if (includeDefaultSkin)
|
if (includeDefaultSkin && defaultSkin != null)
|
||||||
defaultSkin.CopyTo(newSkin, true, cloneAttachments, cloneMeshesAsLinked);
|
defaultSkin.CopyTo(newSkin, true, cloneAttachments, cloneMeshesAsLinked);
|
||||||
|
|
||||||
if (activeSkin != null)
|
if (activeSkin != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user