diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index b08e9f00d..9635b5890 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -11,7 +11,7 @@ jobs: - name: Install OS dependencies (needed for act on ubuntu-latest) run: | sudo apt update - sudo apt install -y --force-yes curl xz-utils libicu-dev git dos2unix + sudo apt install -y --force-yes curl xz-utils libicu-dev git dos2unix libncurses5 - uses: actions/checkout@v1 diff --git a/spine-c/spine-c/src/spine/PathConstraint.c b/spine-c/spine-c/src/spine/PathConstraint.c index a69774d51..849dd0260 100644 --- a/spine-c/spine-c/src/spine/PathConstraint.c +++ b/spine-c/spine-c/src/spine/PathConstraint.c @@ -286,7 +286,7 @@ float *spPathConstraint_computeWorldPositions(spPathConstraint *self, spPathAtta float *lengths = path->lengths; curveCount -= closed ? 1 : 2; pathLength = lengths[curveCount]; - if (self->data->positionMode == SP_POSITION_MODE_PERCENT) position += pathLength; + if (self->data->positionMode == SP_POSITION_MODE_PERCENT) position *= pathLength; switch (self->data->spacingMode) { case SP_SPACING_MODE_PERCENT: multiplier = pathLength; diff --git a/spine-c/spine-c/src/spine/SkeletonJson.c b/spine-c/spine-c/src/spine/SkeletonJson.c index f42100774..b897df6fb 100644 --- a/spine-c/spine-c/src/spine/SkeletonJson.c +++ b/spine-c/spine-c/src/spine/SkeletonJson.c @@ -106,7 +106,8 @@ static void toColor2(spColor *color, const char *value, int /*bool*/ hasAlpha) { color->g = toColor(value, 1); color->b = toColor(value, 2); if (hasAlpha) color->a = toColor(value, 3); - else color->a =1.0f; + else + color->a = 1.0f; } static void diff --git a/spine-libgdx/build.gradle b/spine-libgdx/build.gradle index 455ffb870..eeaf4e593 100644 --- a/spine-libgdx/build.gradle +++ b/spine-libgdx/build.gradle @@ -2,7 +2,7 @@ group = "com.esotericsoftware.spine" version = "4.1.0" ext { - libgdxVersion = "1.10.1-SNAPSHOT" + libgdxVersion = "1.11.1-SNAPSHOT" javaVersion = 8 } diff --git a/spine-ts/spine-core/src/Skeleton.ts b/spine-ts/spine-core/src/Skeleton.ts index 025b34f14..00de9e011 100644 --- a/spine-ts/spine-core/src/Skeleton.ts +++ b/spine-ts/spine-core/src/Skeleton.ts @@ -83,13 +83,13 @@ export class Skeleton { /** Scales the entire skeleton on the Y axis. This affects all bones, even if the bone's transform mode disallows scale * inheritance. */ - private _scaleY = 1; + private _scaleY = 1; - public get scaleY() { + public get scaleY () { return Skeleton.yDown ? -this._scaleY : this._scaleY; } - public set scaleY(scaleY: number) { + public set scaleY (scaleY: number) { this._scaleY = scaleY; } diff --git a/spine-ts/spine-phaser/src/SpineGameObject.ts b/spine-ts/spine-phaser/src/SpineGameObject.ts index e332986e4..d034922b1 100644 --- a/spine-ts/spine-phaser/src/SpineGameObject.ts +++ b/spine-ts/spine-phaser/src/SpineGameObject.ts @@ -5,17 +5,17 @@ import { AnimationState, AnimationStateData, Bone, MathUtils, Skeleton, Skin, Ve import { Vector3 } from "@esotericsoftware/spine-webgl"; class BaseSpineGameObject extends Phaser.GameObjects.GameObject { - constructor(scene: Phaser.Scene, type: string) { + constructor (scene: Phaser.Scene, type: string) { super(scene, type); } } export interface SpineGameObjectBoundsProvider { - calculateBounds(gameObject: SpineGameObject): { x: number, y: number, width: number, height: number }; + calculateBounds (gameObject: SpineGameObject): { x: number, y: number, width: number, height: number }; } export class SetupPoseBoundsProvider implements SpineGameObjectBoundsProvider { - calculateBounds(gameObject: SpineGameObject) { + calculateBounds (gameObject: SpineGameObject) { if (!gameObject.skeleton) return { x: 0, y: 0, width: 0, height: 0 }; // Make a copy of animation state and skeleton as this might be called while // the skeleton in the GameObject has already been heavily modified. We can not @@ -28,11 +28,11 @@ export class SetupPoseBoundsProvider implements SpineGameObjectBoundsProvider { } export class SkinsAndAnimationBoundsProvider implements SpineGameObjectBoundsProvider { - constructor(private animation: string, private skins: string[] = [], private timeStep: number = 0.05) { + constructor (private animation: string, private skins: string[] = [], private timeStep: number = 0.05) { } - calculateBounds(gameObject: SpineGameObject): { x: number; y: number; width: number; height: number; } { + calculateBounds (gameObject: SpineGameObject): { x: number; y: number; width: number; height: number; } { if (!gameObject.skeleton || !gameObject.animationState) return { x: 0, y: 0, width: 0, height: 0 }; // Make a copy of animation state and skeleton as this might be called while // the skeleton in the GameObject has already been heavily modified. We can not @@ -87,13 +87,13 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro private _scaleX = 1; private _scaleY = 1; - constructor(scene: Phaser.Scene, private plugin: SpinePlugin, x: number, y: number, dataKey: string, atlasKey: string, public boundsProvider: SpineGameObjectBoundsProvider = new SetupPoseBoundsProvider()) { + constructor (scene: Phaser.Scene, private plugin: SpinePlugin, x: number, y: number, dataKey: string, atlasKey: string, public boundsProvider: SpineGameObjectBoundsProvider = new SetupPoseBoundsProvider()) { super(scene, SPINE_GAME_OBJECT_TYPE); this.setPosition(x, y); x this.setSkeleton(dataKey, atlasKey); } - setSkeleton(dataKey: string, atlasKey: string) { + setSkeleton (dataKey: string, atlasKey: string) { if (dataKey && atlasKey) { this.premultipliedAlpha = this.plugin.isAtlasPremultiplied(atlasKey); this.skeleton = this.plugin.createSkeleton(dataKey, atlasKey); @@ -107,41 +107,41 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro } } - public get displayOriginX() { + public get displayOriginX () { return this._displayOriginX; } - public set displayOriginX(value: number) { + public set displayOriginX (value: number) { this._displayOriginX = value; } - public get displayOriginY() { + public get displayOriginY () { return this._displayOriginY; } - public set displayOriginY(value: number) { + public set displayOriginY (value: number) { this._displayOriginY = value; } - public get scaleX() { + public get scaleX () { return this._scaleX; } - public set scaleX(value: number) { + public set scaleX (value: number) { this._scaleX = value; this.updateSize(); } - public get scaleY() { + public get scaleY () { return this._scaleY; } - public set scaleY(value: number) { + public set scaleY (value: number) { this._scaleY = value; this.updateSize(); } - updateSize() { + updateSize () { if (!this.skeleton) return; let bounds = this.boundsProvider.calculateBounds(this); // For some reason the TS compiler and the ComputedSize mixin don't work well together... @@ -152,7 +152,7 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro this.displayOriginY = -bounds.y; } - skeletonToPhaserWorldCoordinates(point: {x: number, y: number}) { + skeletonToPhaserWorldCoordinates (point: { x: number, y: number }) { let transform = this.getWorldTransformMatrix(); let a = transform.a, b = transform.b, c = transform.c, d = transform.d, tx = transform.tx, ty = transform.ty; let x = point.x @@ -161,7 +161,7 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro point.y = x * b + y * d + ty; } - phaserWorldCoordinatesToSkeleton(point: {x: number, y: number}) { + phaserWorldCoordinatesToSkeleton (point: { x: number, y: number }) { let transform = this.getWorldTransformMatrix(); transform = transform.invert(); let a = transform.a, b = transform.b, c = transform.c, d = transform.d, tx = transform.tx, ty = transform.ty; @@ -171,7 +171,7 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro point.y = x * b + y * d + ty; } - phaserWorldCoordinatesToBone(point: {x: number, y: number}, bone: Bone) { + phaserWorldCoordinatesToBone (point: { x: number, y: number }, bone: Bone) { this.phaserWorldCoordinatesToSkeleton(point); if (bone.parent) { bone.parent.worldToLocal(point as Vector2); @@ -180,7 +180,7 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro } } - preUpdate(time: number, delta: number) { + preUpdate (time: number, delta: number) { if (!this.skeleton || !this.animationState) return; this.animationState.update(delta / 1000); @@ -188,13 +188,13 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro this.skeleton.updateWorldTransform(); } - preDestroy() { + preDestroy () { this.skeleton = null; this.animationState = null; // FIXME tear down any event emitters } - willRender(camera: Phaser.Cameras.Scene2D.Camera) { + willRender (camera: Phaser.Cameras.Scene2D.Camera) { if (!this.visible) return false; var GameObjectRenderMask = 0xf; @@ -203,7 +203,7 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro return result; } - renderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, src: SpineGameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix) { + renderWebGL (renderer: Phaser.Renderer.WebGL.WebGLRenderer, src: SpineGameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix) { if (!this.skeleton || !this.animationState || !this.plugin.webGLRenderer) return; let sceneRenderer = this.plugin.webGLRenderer; @@ -230,7 +230,7 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro } } - renderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer, src: SpineGameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix) { + renderCanvas (renderer: Phaser.Renderer.Canvas.CanvasRenderer, src: SpineGameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix) { if (!this.skeleton || !this.animationState || !this.plugin.canvasRenderer) return; let context = renderer.currentContext; diff --git a/spine-ts/spine-phaser/src/SpinePlugin.ts b/spine-ts/spine-phaser/src/SpinePlugin.ts index 45f240bb4..e9520d7eb 100644 --- a/spine-ts/spine-phaser/src/SpinePlugin.ts +++ b/spine-ts/spine-phaser/src/SpinePlugin.ts @@ -168,7 +168,7 @@ export class SpinePlugin extends Phaser.Plugins.ScenePlugin { if (this.webGLRenderer) this.webGLRenderer.dispose(); } - isAtlasPremultiplied(atlasKey: string) { + isAtlasPremultiplied (atlasKey: string) { let atlasFile = this.game.cache.text.get(atlasKey); if (!atlasFile) return false; return atlasFile.premultipliedAlpha; @@ -305,7 +305,7 @@ export class SpineAtlasFile extends Phaser.Loader.MultiFile { } else { file.data = { data: file.data, - premultipliedAlpha: this.premultipliedAlpha || file.data.indexOf("pma: true") >= 0 + premultipliedAlpha: this.premultipliedAlpha || file.data.indexOf("pma: true") >= 0 }; file.addToCache(); } diff --git a/spine-ts/spine-webgl/src/SceneRenderer.ts b/spine-ts/spine-webgl/src/SceneRenderer.ts index feef35a3e..207e725eb 100644 --- a/spine-ts/spine-webgl/src/SceneRenderer.ts +++ b/spine-ts/spine-webgl/src/SceneRenderer.ts @@ -86,7 +86,7 @@ export class SceneRenderer implements Disposable { this.enableRenderer(this.batcher); } - drawSkeleton (skeleton: Skeleton, premultipliedAlpha = false, slotRangeStart = -1, slotRangeEnd = -1, transform: VertexTransformer | null = null) { + drawSkeleton (skeleton: Skeleton, premultipliedAlpha = false, slotRangeStart = -1, slotRangeEnd = -1, transform: VertexTransformer | null = null) { this.enableRenderer(this.batcher); this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha; this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd, transform); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs index 2904bbdb2..2ea058944 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs @@ -51,6 +51,10 @@ #define PROBLEMATIC_PACKAGE_ASSET_MODIFICATION #endif +#if UNITY_2019_2_OR_NEWER +#define HAS_PACKAGE_INFO +#endif + using System.Collections.Generic; using System.IO; using System.Linq; @@ -114,6 +118,17 @@ namespace Spine.Unity.Editor { } } + public static bool AssetCanBeModified (string assetPath) { +#if HAS_PACKAGE_INFO + UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(assetPath); + return (packageInfo == null || + packageInfo.source == UnityEditor.PackageManager.PackageSource.Embedded || + packageInfo.source == UnityEditor.PackageManager.PackageSource.Local); +#else + return assetPath.StartsWith("Assets"); +#endif + } + #region Match SkeletonData with Atlases static readonly AttachmentType[] AtlasTypes = { AttachmentType.Region, AttachmentType.Linkedmesh, AttachmentType.Mesh }; diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs index 2ec196184..16d60d47f 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs @@ -91,6 +91,8 @@ namespace Spine.Unity.Editor { string[] prefabAssets = AssetDatabase.FindAssets("t:Prefab"); foreach (string asset in prefabAssets) { string assetPath = AssetDatabase.GUIDToAssetPath(asset); + if (!AssetUtility.AssetCanBeModified(assetPath)) continue; + GameObject prefabGameObject = AssetDatabase.LoadAssetAtPath(assetPath); if (SpineEditorUtilities.CleanupSpinePrefabMesh(prefabGameObject)) { #if HAS_SAVE_ASSET_IF_DIRTY @@ -139,6 +141,8 @@ namespace Spine.Unity.Editor { string[] spriteAtlasAssets = AssetDatabase.FindAssets("t:SpineSpriteAtlasAsset"); foreach (string asset in spriteAtlasAssets) { string assetPath = AssetDatabase.GUIDToAssetPath(asset); + if (!AssetUtility.AssetCanBeModified(assetPath)) continue; + SpineSpriteAtlasAsset atlasAsset = AssetDatabase.LoadAssetAtPath(assetPath); if (atlasAsset && atlasAsset.materials.Length > 0) { spriteAtlasTexturesToRestore[assetPath] = AssetDatabase.GetAssetPath(atlasAsset.materials[0].mainTexture);