mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +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.regionOriginalWidth = regionOriginalWidth;
|
||||
copy.regionOriginalHeight = regionOriginalHeight;
|
||||
copy.RegionRotate = RegionRotate;
|
||||
copy.RegionDegrees = RegionDegrees;
|
||||
copy.Path = Path;
|
||||
copy.r = r;
|
||||
copy.g = g;
|
||||
@ -195,6 +197,8 @@ namespace Spine {
|
||||
mesh.regionHeight = regionHeight;
|
||||
mesh.regionOriginalWidth = regionOriginalWidth;
|
||||
mesh.regionOriginalHeight = regionOriginalHeight;
|
||||
mesh.RegionDegrees = RegionDegrees;
|
||||
mesh.RegionRotate = RegionRotate;
|
||||
|
||||
mesh.Path = Path;
|
||||
mesh.r = r;
|
||||
|
||||
@ -170,7 +170,8 @@ namespace Spine.Unity.Examples {
|
||||
if (skinName != "")
|
||||
skin = skeletonData.FindSkin(skinName);
|
||||
|
||||
skin.SetAttachment(slotIndex, att.Name, att);
|
||||
if (skin != null)
|
||||
skin.SetAttachment(slotIndex, att.Name, att);
|
||||
|
||||
return att;
|
||||
}
|
||||
|
||||
@ -497,12 +497,15 @@ namespace Spine.Unity.Editor {
|
||||
using (new SpineInspectorUtility.IndentScope()) {
|
||||
{
|
||||
skin.GetAttachments(i, slotAttachments);
|
||||
if (skin != defaultSkin) {
|
||||
defaultSkin.GetAttachments(i, slotAttachments);
|
||||
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
||||
} else {
|
||||
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
||||
}
|
||||
if (defaultSkin != null) {
|
||||
if (skin != defaultSkin) {
|
||||
defaultSkin.GetAttachments(i, slotAttachments);
|
||||
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
||||
}
|
||||
else {
|
||||
defaultSkin.GetAttachments(i, defaultSkinAttachments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int a = 0; a < slotAttachments.Count; a++) {
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Spine.Unity.Editor {
|
||||
[CustomEditor(typeof(BoneFollowerGraphic)), CanEditMultipleObjects]
|
||||
public class BoneFollowerGraphicInspector : Editor {
|
||||
|
||||
SerializedProperty boneName, skeletonGraphic, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip;
|
||||
SerializedProperty boneName, skeletonGraphic, followXYPosition, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip;
|
||||
BoneFollowerGraphic targetBoneFollower;
|
||||
bool needsReset;
|
||||
|
||||
@ -73,6 +73,7 @@ namespace Spine.Unity.Editor {
|
||||
skeletonGraphic = serializedObject.FindProperty("skeletonGraphic");
|
||||
boneName = serializedObject.FindProperty("boneName");
|
||||
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
||||
followXYPosition = serializedObject.FindProperty("followXYPosition");
|
||||
followZPosition = serializedObject.FindProperty("followZPosition");
|
||||
followLocalScale = serializedObject.FindProperty("followLocalScale");
|
||||
followSkeletonFlip = serializedObject.FindProperty("followSkeletonFlip");
|
||||
@ -166,6 +167,7 @@ namespace Spine.Unity.Editor {
|
||||
needsReset |= EditorGUI.EndChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(followBoneRotation);
|
||||
EditorGUILayout.PropertyField(followXYPosition);
|
||||
EditorGUILayout.PropertyField(followZPosition);
|
||||
EditorGUILayout.PropertyField(followLocalScale);
|
||||
EditorGUILayout.PropertyField(followSkeletonFlip);
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine.Unity.Editor {
|
||||
|
||||
[CustomEditor(typeof(BoneFollower)), CanEditMultipleObjects]
|
||||
public class BoneFollowerInspector : Editor {
|
||||
SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip;
|
||||
SerializedProperty boneName, skeletonRenderer, followXYPosition, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip;
|
||||
BoneFollower targetBoneFollower;
|
||||
bool needsReset;
|
||||
|
||||
@ -82,6 +82,7 @@ namespace Spine.Unity.Editor {
|
||||
skeletonRenderer = serializedObject.FindProperty("skeletonRenderer");
|
||||
boneName = serializedObject.FindProperty("boneName");
|
||||
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
||||
followXYPosition = serializedObject.FindProperty("followXYPosition");
|
||||
followZPosition = serializedObject.FindProperty("followZPosition");
|
||||
followLocalScale = serializedObject.FindProperty("followLocalScale");
|
||||
followSkeletonFlip = serializedObject.FindProperty("followSkeletonFlip");
|
||||
@ -172,6 +173,7 @@ namespace Spine.Unity.Editor {
|
||||
needsReset |= EditorGUI.EndChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(followBoneRotation);
|
||||
EditorGUILayout.PropertyField(followXYPosition);
|
||||
EditorGUILayout.PropertyField(followZPosition);
|
||||
EditorGUILayout.PropertyField(followLocalScale);
|
||||
EditorGUILayout.PropertyField(followSkeletonFlip);
|
||||
|
||||
@ -582,7 +582,7 @@ namespace Spine.Unity.Editor {
|
||||
attachmentTable.Add(skeleton.Slots.Items[i], attachments);
|
||||
// Add skin attachments.
|
||||
skin.GetAttachments(i, attachments);
|
||||
if (notDefaultSkin) // Add default skin attachments.
|
||||
if (notDefaultSkin && defaultSkin != null) // Add default skin attachments.
|
||||
defaultSkin.GetAttachments(i, attachments);
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +59,7 @@ namespace Spine.Unity {
|
||||
[SpineBone(dataField: "skeletonRenderer")]
|
||||
[SerializeField] public string boneName;
|
||||
|
||||
public bool followXYPosition = true;
|
||||
public bool followZPosition = true;
|
||||
public bool followBoneRotation = true;
|
||||
|
||||
@ -142,7 +143,9 @@ namespace Spine.Unity {
|
||||
Transform thisTransform = this.transform;
|
||||
if (skeletonTransformIsParent) {
|
||||
// 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) {
|
||||
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.
|
||||
@ -157,6 +160,10 @@ namespace Spine.Unity {
|
||||
// For special cases: Use transform world properties if transform relationship is complicated
|
||||
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, 0f));
|
||||
if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
|
||||
if (!followXYPosition) {
|
||||
targetWorldPosition.x = thisTransform.position.x;
|
||||
targetWorldPosition.y = thisTransform.position.y;
|
||||
}
|
||||
|
||||
float boneWorldRotation = bone.WorldRotationX;
|
||||
|
||||
|
||||
@ -63,6 +63,7 @@ namespace Spine.Unity {
|
||||
public bool followSkeletonFlip = true;
|
||||
[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 followXYPosition = true;
|
||||
public bool followZPosition = true;
|
||||
|
||||
[System.NonSerialized] public Bone bone;
|
||||
@ -134,12 +135,18 @@ namespace Spine.Unity {
|
||||
|
||||
if (skeletonTransformIsParent) {
|
||||
// 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();
|
||||
} else {
|
||||
// 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));
|
||||
if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
|
||||
if (!followXYPosition) {
|
||||
targetWorldPosition.x = thisTransform.position.x;
|
||||
targetWorldPosition.y = thisTransform.position.y;
|
||||
}
|
||||
|
||||
float boneWorldRotation = bone.WorldRotationX;
|
||||
|
||||
|
||||
@ -289,7 +289,7 @@ namespace Spine.Unity.AttachmentTools {
|
||||
var repackedRegions = new List<AtlasRegion>();
|
||||
for (int i = 0, n = originalRegions.Count; i < n; 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);
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ namespace Spine.Unity.AttachmentTools {
|
||||
var repackedRegions = new List<AtlasRegion>();
|
||||
for (int i = 0, n = originalRegions.Count; i < n; 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);
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ namespace Spine.Unity.AttachmentTools {
|
||||
CachedRegionTextures.TryGetValue(ar, out output);
|
||||
if (output == null) {
|
||||
Texture2D sourceTexture = ar.GetMainTexture();
|
||||
Rect r = ar.GetUnityRect(sourceTexture.height);
|
||||
Rect r = ar.GetUnityRect();
|
||||
int width = (int)r.width;
|
||||
int height = (int)r.height;
|
||||
output = new Texture2D(width, height, textureFormat, mipmaps) { name = ar.name };
|
||||
@ -516,13 +516,13 @@ namespace Spine.Unity.AttachmentTools {
|
||||
|
||||
/// <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 rr = tr.SpineUnityFlipRect(page.height);
|
||||
|
||||
int x = (int)rr.x, y = (int)rr.y;
|
||||
int w, h;
|
||||
if (rotate) {
|
||||
if (referenceRegion.rotate) {
|
||||
w = (int)rr.height;
|
||||
h = (int)rr.width;
|
||||
} else {
|
||||
@ -530,9 +530,14 @@ namespace Spine.Unity.AttachmentTools {
|
||||
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 {
|
||||
page = page,
|
||||
name = name,
|
||||
name = referenceRegion.name,
|
||||
|
||||
u = uvRect.xMin,
|
||||
u2 = uvRect.xMax,
|
||||
@ -542,15 +547,15 @@ namespace Spine.Unity.AttachmentTools {
|
||||
index = -1,
|
||||
|
||||
width = w,
|
||||
originalWidth = w,
|
||||
originalWidth = originalW,
|
||||
height = h,
|
||||
originalHeight = h,
|
||||
originalHeight = originalH,
|
||||
offsetX = offsetX,
|
||||
offsetY = offsetY,
|
||||
x = x,
|
||||
y = y,
|
||||
|
||||
rotate = rotate
|
||||
rotate = referenceRegion.rotate
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ namespace Spine.Unity.AttachmentTools {
|
||||
var defaultSkin = skeleton.data.DefaultSkin;
|
||||
var activeSkin = skeleton.skin;
|
||||
|
||||
if (includeDefaultSkin)
|
||||
if (includeDefaultSkin && defaultSkin != null)
|
||||
defaultSkin.CopyTo(newSkin, true, cloneAttachments, cloneMeshesAsLinked);
|
||||
|
||||
if (activeSkin != null)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user