Merge branch '3.6' into 3.7-beta

This commit is contained in:
badlogic 2017-08-03 11:19:06 +02:00
commit a2b203f947
6 changed files with 35 additions and 19 deletions

View File

@ -6523,7 +6523,8 @@ var spine;
ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY); ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
ctx.translate(attachment.offset[0], attachment.offset[1]); ctx.translate(attachment.offset[0], attachment.offset[1]);
ctx.rotate(attachment.rotation * Math.PI / 180); ctx.rotate(attachment.rotation * Math.PI / 180);
ctx.scale(attachment.scaleX, attachment.scaleY); var atlasScale = att.width / w;
ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
ctx.translate(w / 2, h / 2); ctx.translate(w / 2, h / 2);
if (attachment.region.rotate) { if (attachment.region.rotate) {
var t = w; var t = w;

File diff suppressed because one or more lines are too long

View File

@ -6523,7 +6523,8 @@ var spine;
ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY); ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
ctx.translate(attachment.offset[0], attachment.offset[1]); ctx.translate(attachment.offset[0], attachment.offset[1]);
ctx.rotate(attachment.rotation * Math.PI / 180); ctx.rotate(attachment.rotation * Math.PI / 180);
ctx.scale(attachment.scaleX, attachment.scaleY); var atlasScale = att.width / w;
ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
ctx.translate(w / 2, h / 2); ctx.translate(w / 2, h / 2);
if (attachment.region.rotate) { if (attachment.region.rotate) {
var t = w; var t = w;

File diff suppressed because one or more lines are too long

View File

@ -88,7 +88,8 @@ module spine.canvas {
ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY); ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
ctx.translate(attachment.offset[0], attachment.offset[1]); ctx.translate(attachment.offset[0], attachment.offset[1]);
ctx.rotate(attachment.rotation * Math.PI / 180); ctx.rotate(attachment.rotation * Math.PI / 180);
ctx.scale(attachment.scaleX, attachment.scaleY); let atlasScale = att.width / w;
ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
ctx.translate(w / 2, h / 2); ctx.translate(w / 2, h / 2);
if (attachment.region.rotate) { if (attachment.region.rotate) {
let t = w; let t = w;

View File

@ -541,6 +541,16 @@ namespace Spine.Unity.Editor {
bool m_requireRefresh; bool m_requireRefresh;
Color m_originColor = new Color(0.3f, 0.3f, 0.3f, 1); Color m_originColor = new Color(0.3f, 0.3f, 0.3f, 1);
Camera PreviewUtilityCamera {
get {
#if UNITY_2017_1_OR_NEWER
return m_previewUtility.camera;
#else
return m_previewUtility.m_Camera;
#endif
}
}
void StopAnimation () { void StopAnimation () {
if (m_skeletonAnimation == null) { if (m_skeletonAnimation == null) {
Debug.LogWarning("Animation was stopped but preview doesn't exist. It's possible that the Preview Panel is closed."); Debug.LogWarning("Animation was stopped but preview doesn't exist. It's possible that the Preview Panel is closed.");
@ -577,7 +587,7 @@ namespace Spine.Unity.Editor {
if (this.m_previewUtility == null) { if (this.m_previewUtility == null) {
this.m_lastTime = Time.realtimeSinceStartup; this.m_lastTime = Time.realtimeSinceStartup;
this.m_previewUtility = new PreviewRenderUtility(true); this.m_previewUtility = new PreviewRenderUtility(true);
var c = this.m_previewUtility.m_Camera; var c = this.PreviewUtilityCamera;
c.orthographic = true; c.orthographic = true;
c.orthographicSize = 1; c.orthographicSize = 1;
c.cullingMask = -2147483648; c.cullingMask = -2147483648;
@ -700,16 +710,17 @@ namespace Spine.Unity.Editor {
if (EditorApplication.timeSinceStartup < m_adjustFrameEndTime) if (EditorApplication.timeSinceStartup < m_adjustFrameEndTime)
AdjustCameraGoals(); AdjustCameraGoals();
float orthoSet = Mathf.Lerp(this.m_previewUtility.m_Camera.orthographicSize, m_orthoGoal, 0.1f); var c = this.PreviewUtilityCamera;
float orthoSet = Mathf.Lerp(c.orthographicSize, m_orthoGoal, 0.1f);
this.m_previewUtility.m_Camera.orthographicSize = orthoSet; c.orthographicSize = orthoSet;
float dist = Vector3.Distance(m_previewUtility.m_Camera.transform.position, m_posGoal); float dist = Vector3.Distance(c.transform.position, m_posGoal);
if(dist > 0f) { if(dist > 0f) {
Vector3 pos = Vector3.Lerp(this.m_previewUtility.m_Camera.transform.position, m_posGoal, 0.1f); Vector3 pos = Vector3.Lerp(c.transform.position, m_posGoal, 0.1f);
pos.x = 0; pos.x = 0;
this.m_previewUtility.m_Camera.transform.position = pos; c.transform.position = pos;
this.m_previewUtility.m_Camera.transform.rotation = Quaternion.identity; c.transform.rotation = Quaternion.identity;
m_requireRefresh = true; m_requireRefresh = true;
} }
} }
@ -728,18 +739,20 @@ namespace Spine.Unity.Editor {
if (!EditorApplication.isPlaying) if (!EditorApplication.isPlaying)
m_skeletonAnimation.LateUpdate(); m_skeletonAnimation.LateUpdate();
var c = this.PreviewUtilityCamera;
if (drawHandles) { if (drawHandles) {
Handles.SetCamera(m_previewUtility.m_Camera); Handles.SetCamera(c);
Handles.color = m_originColor; Handles.color = m_originColor;
Handles.DrawLine(new Vector3(-1000 * m_skeletonDataAsset.scale, 0, 0), new Vector3(1000 * m_skeletonDataAsset.scale, 0, 0)); Handles.DrawLine(new Vector3(-1000 * m_skeletonDataAsset.scale, 0, 0), new Vector3(1000 * m_skeletonDataAsset.scale, 0, 0));
Handles.DrawLine(new Vector3(0, 1000 * m_skeletonDataAsset.scale, 0), new Vector3(0, -1000 * m_skeletonDataAsset.scale, 0)); Handles.DrawLine(new Vector3(0, 1000 * m_skeletonDataAsset.scale, 0), new Vector3(0, -1000 * m_skeletonDataAsset.scale, 0));
} }
this.m_previewUtility.m_Camera.Render(); c.Render();
if (drawHandles) { if (drawHandles) {
Handles.SetCamera(m_previewUtility.m_Camera); Handles.SetCamera(c);
SpineHandles.DrawBoundingBoxes(m_skeletonAnimation.transform, m_skeletonAnimation.skeleton); SpineHandles.DrawBoundingBoxes(m_skeletonAnimation.transform, m_skeletonAnimation.skeleton);
if (showAttachments) SpineHandles.DrawPaths(m_skeletonAnimation.transform, m_skeletonAnimation.skeleton); if (showAttachments) SpineHandles.DrawPaths(m_skeletonAnimation.transform, m_skeletonAnimation.skeleton);
} }
@ -922,19 +935,19 @@ namespace Spine.Unity.Editor {
} }
} }
public override Texture2D RenderStaticPreview (string assetPath, UnityEngine.Object[] subAssets, int width, int height) { public override Texture2D RenderStaticPreview (string assetPath, UnityEngine.Object[] subAssets, int width, int height) {
var tex = new Texture2D(width, height, TextureFormat.ARGB32, false); var tex = new Texture2D(width, height, TextureFormat.ARGB32, false);
this.InitPreview(); this.InitPreview();
if (this.m_previewUtility.m_Camera == null) var c = this.PreviewUtilityCamera;
if (c == null)
return null; return null;
m_requireRefresh = true; m_requireRefresh = true;
this.DoRenderPreview(false); this.DoRenderPreview(false);
AdjustCameraGoals(false); AdjustCameraGoals(false);
this.m_previewUtility.m_Camera.orthographicSize = m_orthoGoal / 2; c.orthographicSize = m_orthoGoal / 2;
this.m_previewUtility.m_Camera.transform.position = m_posGoal; c.transform.position = m_posGoal;
this.m_previewUtility.BeginStaticPreview(new Rect(0, 0, width, height)); this.m_previewUtility.BeginStaticPreview(new Rect(0, 0, width, height));
this.DoRenderPreview(false); this.DoRenderPreview(false);
tex = this.m_previewUtility.EndStaticPreview(); tex = this.m_previewUtility.EndStaticPreview();