Skip to content

Commit

Permalink
Merge branch '4.1' into 4.2-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
HaraldCsaszar committed Sep 12, 2023
2 parents 1dad009 + 9d8c32b commit ed1bdc4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ public static GUIStyle PointNameStyle {
}

public static void DrawBoneNames (Transform transform, Skeleton skeleton, float positionScale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

GUIStyle style = BoneNameStyle;
foreach (Bone b in skeleton.Bones) {
if (!b.Active) continue;
Expand All @@ -172,6 +174,8 @@ public static void DrawBoneNames (Transform transform, Skeleton skeleton, float
}

public static void DrawBones (Transform transform, Skeleton skeleton, float positionScale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

float boneScale = 1.8f; // Draw the root bone largest;
DrawCrosshairs2D(skeleton.Bones.Items[0].GetWorldPosition(transform), 0.08f, positionScale);

Expand All @@ -191,6 +195,8 @@ static Vector3[] GetBoneWireBuffer (Matrix4x4 m) {
return _boneWireBuffer;
}
public static void DrawBoneWireframe (Transform transform, Bone b, Color color, float skeletonRenderScale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

Handles.color = color;
Vector3 pos = new Vector3(b.WorldX * skeletonRenderScale, b.WorldY * skeletonRenderScale, 0);
float length = b.Data.Length;
Expand All @@ -211,6 +217,8 @@ public static void DrawBoneWireframe (Transform transform, Bone b, Color color,
}

public static void DrawBone (Transform transform, Bone b, float boneScale, float skeletonRenderScale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

Vector3 pos = new Vector3(b.WorldX * skeletonRenderScale, b.WorldY * skeletonRenderScale, 0);
float length = b.Data.Length;
if (length > 0) {
Expand All @@ -228,6 +236,8 @@ public static void DrawBone (Transform transform, Bone b, float boneScale, float
}

public static void DrawBone (Transform transform, Bone b, float boneScale, Color color, float skeletonRenderScale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

Vector3 pos = new Vector3(b.WorldX * skeletonRenderScale, b.WorldY * skeletonRenderScale, 0);
float length = b.Data.Length;
if (length > 0) {
Expand All @@ -245,6 +255,8 @@ public static void DrawBone (Transform transform, Bone b, float boneScale, Color
}

public static void DrawPaths (Transform transform, Skeleton skeleton) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

foreach (Slot s in skeleton.DrawOrder) {
PathAttachment p = s.Attachment as PathAttachment;
if (p != null) SpineHandles.DrawPath(s, p, transform, true);
Expand All @@ -253,6 +265,8 @@ public static void DrawPaths (Transform transform, Skeleton skeleton) {

static float[] pathVertexBuffer;
public static void DrawPath (Slot s, PathAttachment p, Transform t, bool includeName) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

int worldVerticesLength = p.WorldVerticesLength;

if (pathVertexBuffer == null || pathVertexBuffer.Length < worldVerticesLength)
Expand Down Expand Up @@ -296,17 +310,23 @@ public static void DrawPath (Slot s, PathAttachment p, Transform t, bool include
}

public static void DrawDot (Vector3 position, float size) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

Handles.DotHandleCap(0, position, Quaternion.identity, size * HandleUtility.GetHandleSize(position), EventType.Ignore); //Handles.DotCap(0, position, Quaternion.identity, size * HandleUtility.GetHandleSize(position));
}

public static void DrawBoundingBoxes (Transform transform, Skeleton skeleton) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

foreach (Slot slot in skeleton.Slots) {
BoundingBoxAttachment bba = slot.Attachment as BoundingBoxAttachment;
if (bba != null) SpineHandles.DrawBoundingBox(slot, bba, transform);
}
}

public static void DrawBoundingBox (Slot slot, BoundingBoxAttachment box, Transform t) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

if (box.Vertices.Length <= 2) return; // Handle cases where user creates a BoundingBoxAttachment but doesn't actually define it.

float[] worldVerts = new float[box.WorldVerticesLength];
Expand All @@ -333,6 +353,8 @@ public static void DrawBoundingBox (Slot slot, BoundingBoxAttachment box, Transf
}

public static void DrawPointAttachment (Bone bone, PointAttachment pointAttachment, Transform skeletonTransform) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

if (bone == null) return;
if (pointAttachment == null) return;

Expand All @@ -346,6 +368,8 @@ public static void DrawPointAttachment (Bone bone, PointAttachment pointAttachme
}

public static void DrawConstraints (Transform transform, Skeleton skeleton, float skeletonRenderScale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

Vector3 targetPos;
Vector3 pos;
bool active;
Expand Down Expand Up @@ -425,6 +449,8 @@ public static void DrawConstraints (Transform transform, Skeleton skeleton, floa
}

public static void DrawReferenceRect (SkeletonGraphic skeletonGraphic, Color color) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

RectTransform rectTransform = skeletonGraphic.rectTransform;
Vector2 referenceRectSize = skeletonGraphic.GetReferenceRectSize();
Vector3 position = rectTransform.position;
Expand All @@ -436,6 +462,8 @@ public static void DrawReferenceRect (SkeletonGraphic skeletonGraphic, Color col
}

public static void DrawRectTransformRect (SkeletonGraphic skeletonGraphic, Color color) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

RectTransform rectTransform = skeletonGraphic.rectTransform;
Vector2 rectTransformSize = skeletonGraphic.RectTransformSize;
Vector3 position = rectTransform.position;
Expand All @@ -447,6 +475,8 @@ public static void DrawRectTransformRect (SkeletonGraphic skeletonGraphic, Color
}

public static void DrawRect (Vector3 cornerVertexBL, Vector3 right, Vector3 up, Color color) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

Vector3 v0 = cornerVertexBL;
Vector3 v1 = v0 + right;
Vector3 v2 = v0 + right + up;
Expand All @@ -461,12 +491,16 @@ public static void DrawRect (Vector3 cornerVertexBL, Vector3 right, Vector3 up,
}

static void DrawCrosshairs2D (Vector3 position, float scale, float skeletonRenderScale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

scale *= SpineEditorUtilities.Preferences.handleScale * skeletonRenderScale;
Handles.DrawLine(position + new Vector3(-scale, 0), position + new Vector3(scale, 0));
Handles.DrawLine(position + new Vector3(0, -scale), position + new Vector3(0, scale));
}

static void DrawCrosshairs (Vector3 position, float scale, float a, float b, float c, float d, Transform transform, float skeletonRenderScale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

scale *= SpineEditorUtilities.Preferences.handleScale * skeletonRenderScale;

Vector3 xOffset = (Vector3)(new Vector2(a, c).normalized * scale);
Expand All @@ -479,17 +513,23 @@ static void DrawCrosshairs (Vector3 position, float scale, float a, float b, flo
}

static void DrawArrowhead2D (Vector3 pos, float localRotation, float scale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

scale *= SpineEditorUtilities.Preferences.handleScale;

SpineHandles.IKMaterial.SetPass(0);
Graphics.DrawMeshNow(SpineHandles.ArrowheadMesh, Matrix4x4.TRS(pos, Quaternion.Euler(0, 0, localRotation), new Vector3(scale, scale, scale)));
}

static void DrawArrowhead (Vector3 pos, Quaternion worldQuaternion) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

Graphics.DrawMeshNow(SpineHandles.ArrowheadMesh, pos, worldQuaternion, 0);
}

static void DrawArrowhead (Matrix4x4 m) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

float s = SpineEditorUtilities.Preferences.handleScale;
m.m00 *= s;
m.m01 *= s;
Expand All @@ -506,6 +546,8 @@ static void DrawArrowhead (Matrix4x4 m) {
}

static void DrawBoneCircle (Vector3 pos, Color outlineColor, Vector3 normal, float scale = 1f) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

scale *= SpineEditorUtilities.Preferences.handleScale;

Color o = Handles.color;
Expand All @@ -524,6 +566,8 @@ static void DrawBoneCircle (Vector3 pos, Color outlineColor, Vector3 normal, flo
}

internal static void DrawCubicBezier (Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3) {
if (UnityEngine.Event.current.type != EventType.Repaint) return;

Handles.DrawBezier(p0, p3, p1, p2, Handles.color, Texture2D.whiteTexture, 2f);
// const float dotSize = 0.01f;
// Quaternion q = Quaternion.identity;
Expand Down
2 changes: 1 addition & 1 deletion spine-unity/Assets/Spine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core.",
"version": "4.2.21",
"version": "4.2.22",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",
Expand Down

0 comments on commit ed1bdc4

Please sign in to comment.