From d252df7eced6aa0830b9659390a5714abb3b9126 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Fri, 24 Jan 2020 13:55:45 +0100 Subject: [PATCH] [unity] Fixed some compiler warnings when building for platforms instead of editor. Closes #1604. --- spine-csharp/src/MathUtils.cs | 6 +++--- .../Getting Started Scripts/SpineboyTargetController.cs | 4 ++-- .../spine-unity/Asset Types/SkeletonDataCompatibility.cs | 5 +++-- .../Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs | 4 ++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/spine-csharp/src/MathUtils.cs b/spine-csharp/src/MathUtils.cs index eb9756a63..ad10ec217 100644 --- a/spine-csharp/src/MathUtils.cs +++ b/spine-csharp/src/MathUtils.cs @@ -38,6 +38,9 @@ namespace Spine { public const float RadDeg = 180f / PI; public const float DegRad = PI / 180; + static Random random = new Random(); + + #if USE_FAST_SIN_COS_ATAN2_APPROXIMATIONS const int SIN_BITS = 14; // 16KB. Adjust for accuracy. const int SIN_MASK = ~(-1 << SIN_BITS); const int SIN_COUNT = SIN_MASK + 1; @@ -47,9 +50,6 @@ namespace Spine { const float DegToIndex = SIN_COUNT / DegFull; static float[] sin = new float[SIN_COUNT]; - static Random random = new Random(); - - #if USE_FAST_SIN_COS_ATAN2_APPROXIMATIONS static MathUtils () { for (int i = 0; i < SIN_COUNT; i++) sin[i] = (float)Math.Sin((i + 0.5f) / SIN_COUNT * RadFull); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs index fbf33436c..7f033d3f7 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs @@ -36,7 +36,7 @@ namespace Spine.Unity.Examples { [SpineBone(dataField:"skeletonAnimation")] public string boneName; - public new Camera camera; + public Camera cam; Bone bone; @@ -50,7 +50,7 @@ namespace Spine.Unity.Examples { void Update () { var mousePosition = Input.mousePosition; - var worldMousePosition = camera.ScreenToWorldPoint(mousePosition); + var worldMousePosition = cam.ScreenToWorldPoint(mousePosition); var skeletonSpacePoint = skeletonAnimation.transform.InverseTransformPoint(worldMousePosition); skeletonSpacePoint.x *= skeletonAnimation.Skeleton.ScaleX; skeletonSpacePoint.y *= skeletonAnimation.Skeleton.ScaleY; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs index 810a5238d..68b78f57c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs @@ -36,10 +36,12 @@ namespace Spine.Unity { public static class SkeletonDataCompatibility { + #if UNITY_EDITOR static readonly int[][] compatibleBinaryVersions = { new[] { 3, 8, 0 } }; static readonly int[][] compatibleJsonVersions = { new[] { 3, 8, 0 } }; static bool wasVersionDialogShown = false; + #endif public enum SourceType { Json, @@ -110,7 +112,6 @@ namespace Spine.Unity { } } - string primaryRuntimeVersionDebugString = compatibleBinaryVersions[0][0] + "." + compatibleBinaryVersions[0][1]; if (string.IsNullOrEmpty(fileVersion.rawVersion)) { // very likely not a Spine skeleton json file at all. return null; @@ -136,7 +137,7 @@ namespace Spine.Unity { info.actualVersion = fileVersion; info.compatibleVersions = (fileVersion.sourceType == SourceType.Binary) ? compatibleBinaryVersions : compatibleJsonVersions; - + foreach (var compatibleVersion in info.compatibleVersions) { bool majorMatch = fileVersion.version[0] == compatibleVersion[0]; bool minorMatch = fileVersion.version[1] == compatibleVersion[1]; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs index 59a2f639e..ed26c37e0 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs @@ -487,6 +487,10 @@ namespace Spine.Unity.AttachmentTools { this.i = i; this.region = region; } + + public override int GetHashCode () { + return i.GetHashCode() * 23 ^ region.GetHashCode(); + } } static Dictionary CachedRegionTextures = new Dictionary(); static List CachedRegionTexturesList = new List();