From 16e3de63cc514253d37781a3f5f3713c647b6a24 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 3 Mar 2021 17:07:42 +0100 Subject: [PATCH] [unity] `NewSkeletonAnimationGameObject` and `Initialize()` now provide a `quiet` parameter to omit material warnings. Closes #1852. --- .../spine-unity/Components/SkeletonAnimation.cs | 14 ++++++++------ .../spine-unity/Components/SkeletonMecanim.cs | 4 ++-- .../spine-unity/Components/SkeletonRenderer.cs | 12 ++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) 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 cfc5ddf29..315f9e37e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs @@ -134,14 +134,16 @@ namespace Spine.Unity { #region Runtime Instantiation /// Adds and prepares a SkeletonAnimation component to a GameObject at runtime. /// The newly instantiated SkeletonAnimation - public static SkeletonAnimation AddToGameObject (GameObject gameObject, SkeletonDataAsset skeletonDataAsset) { - return SkeletonRenderer.AddSpineComponent(gameObject, skeletonDataAsset); + public static SkeletonAnimation AddToGameObject (GameObject gameObject, SkeletonDataAsset skeletonDataAsset, + bool quiet = false) { + return SkeletonRenderer.AddSpineComponent(gameObject, skeletonDataAsset, quiet); } /// Instantiates a new UnityEngine.GameObject and adds a prepared SkeletonAnimation component to it. /// The newly instantiated SkeletonAnimation component. - public static SkeletonAnimation NewSkeletonAnimationGameObject (SkeletonDataAsset skeletonDataAsset) { - return SkeletonRenderer.NewSpineGameObject(skeletonDataAsset); + public static SkeletonAnimation NewSkeletonAnimationGameObject (SkeletonDataAsset skeletonDataAsset, + bool quiet = false) { + return SkeletonRenderer.NewSpineGameObject(skeletonDataAsset, quiet); } #endregion @@ -155,10 +157,10 @@ namespace Spine.Unity { /// /// Initialize this component. Attempts to load the SkeletonData and creates the internal Spine objects and buffers. /// If set to true, force overwrite an already initialized object. - public override void Initialize (bool overwrite) { + public override void Initialize (bool overwrite, bool quiet = false) { if (valid && !overwrite) return; - base.Initialize(overwrite); + base.Initialize(overwrite, quiet); if (!valid) return; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs index c6bf63b27..14b30c7cc 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs @@ -69,11 +69,11 @@ namespace Spine.Unity { public event UpdateBonesDelegate UpdateComplete { add { _UpdateComplete += value; } remove { _UpdateComplete -= value; } } #endregion - public override void Initialize (bool overwrite) { + public override void Initialize (bool overwrite, bool quiet = false) { if (valid && !overwrite) return; - base.Initialize(overwrite); + base.Initialize(overwrite, quiet); if (!valid) return; 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 2fea2f7d4..bf442ce19 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -247,17 +247,17 @@ namespace Spine.Unity { public SkeletonDataAsset SkeletonDataAsset { get { return skeletonDataAsset; } } // ISkeletonComponent #region Runtime Instantiation - public static T NewSpineGameObject (SkeletonDataAsset skeletonDataAsset) where T : SkeletonRenderer { - return SkeletonRenderer.AddSpineComponent(new GameObject("New Spine GameObject"), skeletonDataAsset); + public static T NewSpineGameObject (SkeletonDataAsset skeletonDataAsset, bool quiet = false) where T : SkeletonRenderer { + return SkeletonRenderer.AddSpineComponent(new GameObject("New Spine GameObject"), skeletonDataAsset, quiet); } /// Add and prepare a Spine component that derives from SkeletonRenderer to a GameObject at runtime. /// T should be SkeletonRenderer or any of its derived classes. - public static T AddSpineComponent (GameObject gameObject, SkeletonDataAsset skeletonDataAsset) where T : SkeletonRenderer { + public static T AddSpineComponent (GameObject gameObject, SkeletonDataAsset skeletonDataAsset, bool quiet = false) where T : SkeletonRenderer { var c = gameObject.AddComponent(); if (skeletonDataAsset != null) { c.skeletonDataAsset = skeletonDataAsset; - c.Initialize(false); + c.Initialize(false, quiet); } return c; } @@ -315,7 +315,7 @@ namespace Spine.Unity { /// /// Initialize this component. Attempts to load the SkeletonData and creates the internal Skeleton object and buffers. /// If set to true, it will overwrite internal objects if they were already generated. Otherwise, the initialized component will ignore subsequent calls to initialize. - public virtual void Initialize (bool overwrite) { + public virtual void Initialize (bool overwrite, bool quiet = false) { if (valid && !overwrite) return; @@ -361,7 +361,7 @@ namespace Spine.Unity { #if UNITY_EDITOR if (!Application.isPlaying) { string errorMessage = null; - if (MaterialChecks.IsMaterialSetupProblematic(this, ref errorMessage)) + if (quiet || MaterialChecks.IsMaterialSetupProblematic(this, ref errorMessage)) Debug.LogWarningFormat(this, "Problematic material setup at {0}: {1}", this.name, errorMessage); } #endif