Browse Source

[unity] SkeletonGraphic: avoid unnecessary redundant mesh update at color change (necessary after commit c36f847). See #2049.

Harald Csaszar 1 year ago
parent
commit
94d8a3a387

+ 1 - 1
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs

@@ -155,7 +155,7 @@ namespace Spine.Unity.Editor {
 
 			// MaskableGraphic
 			material = so.FindProperty("m_Material");
-			color = so.FindProperty("m_Color");
+			color = so.FindProperty("m_SkeletonColor");
 			raycastTarget = so.FindProperty("m_RaycastTarget");
 			maskable = so.FindProperty("m_Maskable");
 

+ 7 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs

@@ -60,6 +60,13 @@ namespace Spine.Unity {
 		public Material multiplyMaterial;
 		public Material screenMaterial;
 
+		/// <summary>Own color to replace <c>Graphic.m_Color</c>.</summary>
+		[UnityEngine.Serialization.FormerlySerializedAs("m_Color")]
+		[SerializeField] protected Color m_SkeletonColor = Color.white;
+		/// <summary>Sets the color of the skeleton. Does not call <see cref="Rebuild"/> and <see cref="UpdateMesh"/>
+		/// unnecessarily as <c>Graphic.color</c> would otherwise do.</summary>
+		override public Color color { get { return m_SkeletonColor; } set { m_SkeletonColor = value; } }
+
 		[SpineSkin(dataField: "skeletonDataAsset", defaultAsEmptyString: true)]
 		public string initialSkinName;
 		public bool initialFlipX, initialFlipY;