From 66689b3800bd19b72a48c10ead278434b11ed97f Mon Sep 17 00:00:00 2001 From: pharan Date: Sun, 30 Dec 2018 03:30:36 +0800 Subject: [PATCH] [unity] Make components compatible with new 2018.3 Prefab Mode. --- .../Runtime/spine-unity/Components/BoneFollower.cs | 9 +++++++++ .../Runtime/spine-unity/Components/PointFollower.cs | 12 +++++++++--- .../spine-unity/Components/SkeletonAnimation.cs | 8 ++++++++ .../spine-unity/Components/SkeletonRenderer.cs | 10 +++++++++- .../BoundingBoxFollower/BoundingBoxFollower.cs | 7 +++++++ .../SkeletonRendererCustomMaterials.cs | 7 +++++++ .../Modules/SkeletonGraphic/BoneFollowerGraphic.cs | 12 ++++++++++-- .../Modules/SkeletonGraphic/SkeletonGraphic.cs | 12 ++++++++++-- .../SkeletonRenderSeparator.cs | 10 ++++++++-- .../SkeletonUtilityGroundConstraint.cs | 12 +++++++++++- .../spine-unity/SkeletonUtility/SkeletonUtility.cs | 12 +++++++++--- .../SkeletonUtility/SkeletonUtilityBone.cs | 9 ++++++++- .../SkeletonUtility/SkeletonUtilityConstraint.cs | 12 +++++++++++- 13 files changed, 116 insertions(+), 16 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/BoneFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/BoneFollower.cs index aa33634c8..75b64cbe2 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/BoneFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/BoneFollower.cs @@ -28,12 +28,21 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 +#define NEW_PREFAB_SYSTEM +#endif + using System; using UnityEngine; namespace Spine.Unity { + /// Sets a GameObject's transform to match a bone on a Spine skeleton. + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif [AddComponentMenu("Spine/BoneFollower")] public class BoneFollower : MonoBehaviour { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs index e75309356..91570a00c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs @@ -27,14 +27,20 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; + +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif + using UnityEngine; namespace Spine.Unity { + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif [AddComponentMenu("Spine/Point Follower")] public class PointFollower : MonoBehaviour, IHasSkeletonRenderer, IHasSkeletonComponent { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs index 7988b2680..9d41ffae4 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs @@ -28,11 +28,19 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif + using UnityEngine; namespace Spine.Unity { + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif [AddComponentMenu("Spine/SkeletonAnimation")] public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation, IAnimationStateComponent { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs index f26bcd62b..83817e787 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -28,6 +28,9 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif #define SPINE_OPTIONAL_RENDEROVERRIDE #define SPINE_OPTIONAL_MATERIALOVERRIDE @@ -36,7 +39,12 @@ using UnityEngine; namespace Spine.Unity { /// Base class of animated Spine skeleton components. This component manages and renders a skeleton. - [ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer)), DisallowMultipleComponent] + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else + [ExecuteInEditMode] + #endif + [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer)), DisallowMultipleComponent] [HelpURL("http://esotericsoftware.com/spine-unity-rendering")] public class SkeletonRenderer : MonoBehaviour, ISkeletonComponent, IHasSkeletonDataAsset { [SerializeField] public SkeletonDataAsset skeletonDataAsset; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs index bc52a2c2e..7afdc43c3 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs @@ -27,13 +27,20 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif using UnityEngine; using System.Collections.Generic; namespace Spine.Unity { + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif public class BoundingBoxFollower : MonoBehaviour { internal static bool DebugMessages = true; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.cs index ba8ce0f89..27c59ca1b 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.cs @@ -28,6 +28,9 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif #define SPINE_OPTIONAL_MATERIALOVERRIDE // Contributed by: Lost Polygon @@ -37,7 +40,11 @@ using System.Collections.Generic; using UnityEngine; namespace Spine.Unity.Modules { + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif public class SkeletonRendererCustomMaterials : MonoBehaviour { #region Inspector diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/BoneFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/BoneFollowerGraphic.cs index e833c4453..15d529c56 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/BoneFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/BoneFollowerGraphic.cs @@ -1,9 +1,17 @@ -using System.Collections; -using System.Collections.Generic; + +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif + using UnityEngine; namespace Spine.Unity { + + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif [DisallowMultipleComponent] [AddComponentMenu("Spine/UI/BoneFollowerGraphic")] public class BoneFollowerGraphic : MonoBehaviour { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs index 6b3a43eb4..620d2d940 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs @@ -28,12 +28,20 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif + using UnityEngine; using UnityEngine.UI; -using Spine; namespace Spine.Unity { - [ExecuteInEditMode, RequireComponent(typeof(CanvasRenderer), typeof(RectTransform)), DisallowMultipleComponent] + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else + [ExecuteInEditMode] + #endif + [RequireComponent(typeof(CanvasRenderer), typeof(RectTransform)), DisallowMultipleComponent] [AddComponentMenu("Spine/SkeletonGraphic (Unity UI Canvas)")] public class SkeletonGraphic : MaskableGraphic, ISkeletonComponent, IAnimationStateComponent, ISkeletonAnimation, IHasSkeletonDataAsset { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonRenderSeparator/SkeletonRenderSeparator.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonRenderSeparator/SkeletonRenderSeparator.cs index a0dccf165..1c700c0ba 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonRenderSeparator/SkeletonRenderSeparator.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonRenderSeparator/SkeletonRenderSeparator.cs @@ -28,15 +28,21 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif #define SPINE_OPTIONAL_RENDEROVERRIDE using UnityEngine; using System.Collections.Generic; -using Spine.Unity; namespace Spine.Unity.Modules { - + + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif [HelpURL("http://esotericsoftware.com/spine-unity-skeletonrenderseparator")] public class SkeletonRenderSeparator : MonoBehaviour { public const int DefaultSortingOrderIncrement = 5; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonUtility Modules/SkeletonUtilityGroundConstraint.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonUtility Modules/SkeletonUtilityGroundConstraint.cs index d88c9af78..738ad74ad 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonUtility Modules/SkeletonUtilityGroundConstraint.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonUtility Modules/SkeletonUtilityGroundConstraint.cs @@ -28,10 +28,20 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif + using UnityEngine; namespace Spine.Unity.Modules { - [RequireComponent(typeof(SkeletonUtilityBone)), ExecuteInEditMode] + + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else + [ExecuteInEditMode] + #endif + [RequireComponent(typeof(SkeletonUtilityBone))] public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint { [Tooltip("LayerMask for what objects to raycast against")] diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtility.cs index 28fc69a5b..8913374ab 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtility.cs @@ -28,15 +28,21 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -// Contributed by: Mitch Thompson +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif using UnityEngine; using System.Collections.Generic; -using Spine; namespace Spine.Unity { - [RequireComponent(typeof(ISkeletonAnimation))] + + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif + [RequireComponent(typeof(ISkeletonAnimation))] public sealed class SkeletonUtility : MonoBehaviour { #region BoundingBoxAttachment diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs index 14f24c715..4837ba9ed 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs @@ -28,12 +28,19 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif + using UnityEngine; -using Spine; namespace Spine.Unity { /// Sets a GameObject's transform to match a bone on a Spine skeleton. + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else [ExecuteInEditMode] + #endif [AddComponentMenu("Spine/SkeletonGameObjectsBone")] public class SkeletonUtilityBone : MonoBehaviour { public enum Mode { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityConstraint.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityConstraint.cs index 49fcfc265..f9177114c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityConstraint.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityConstraint.cs @@ -28,10 +28,20 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif + using UnityEngine; namespace Spine.Unity { - [RequireComponent(typeof(SkeletonUtilityBone)), ExecuteInEditMode] + + #if NEW_PREFAB_SYSTEM + [ExecuteAlways] + #else + [ExecuteInEditMode] + #endif + [RequireComponent(typeof(SkeletonUtilityBone))] public abstract class SkeletonUtilityConstraint : MonoBehaviour { protected SkeletonUtilityBone bone;