From 14a826951db16c6eae95852078bc3ca79adcde6f Mon Sep 17 00:00:00 2001 From: VladV Date: Fri, 4 Nov 2022 14:43:53 +0400 Subject: [PATCH] Add linear color space support --- Runtime/Scripts/MeshAnimationAsset.cs | 8 ++++++++ Runtime/Scripts/MeshAnimationBaker.cs | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Runtime/Scripts/MeshAnimationAsset.cs b/Runtime/Scripts/MeshAnimationAsset.cs index 8916532..7770ebe 100644 --- a/Runtime/Scripts/MeshAnimationAsset.cs +++ b/Runtime/Scripts/MeshAnimationAsset.cs @@ -23,6 +23,9 @@ public class MeshAnimationAsset : ScriptableObject [SerializeField] internal bool npotBakedTexture = false; + [SerializeField] + internal bool linearColorSpace = false; + [PropertySpace] [Required] [SerializeField] @@ -107,6 +110,11 @@ public string GetValidationMessage() } #if UNITY_EDITOR + private void Reset() + { + linearColorSpace = UnityEditor.PlayerSettings.colorSpace == ColorSpace.Linear; + } + [DisableIf(nameof(IsInvalid))] [PropertySpace(10)] [Button(ButtonSizes.Large, Name = "Bake")] diff --git a/Runtime/Scripts/MeshAnimationBaker.cs b/Runtime/Scripts/MeshAnimationBaker.cs index ff661ef..d170685 100644 --- a/Runtime/Scripts/MeshAnimationBaker.cs +++ b/Runtime/Scripts/MeshAnimationBaker.cs @@ -190,8 +190,9 @@ private static void CreateTexture(MeshAnimationAsset asset, out bool aborted) var texWidth = asset.npotBakedTexture ? vertexCount : Mathf.NextPowerOfTwo(vertexCount); var textHeight = asset.npotBakedTexture ? framesCount : Mathf.NextPowerOfTwo(framesCount); + var linear = asset.linearColorSpace; - var texture = new Texture2D(texWidth, textHeight, TextureFormat.RGB24, false) + var texture = new Texture2D(texWidth, textHeight, TextureFormat.RGB24, false, linear) { name = asset.name + " Texture", hideFlags = HideFlags.NotEditable,