HDR support in TweenSettings<Color> #103
Answered
by
KyryloKuzyk
KyryloKuzyk
asked this question in
General
-
Is it possible to enable the HDR support in TweenSettings? |
Beta Was this translation helpful? Give feedback.
Answered by
KyryloKuzyk
Sep 17, 2024
Replies: 1 comment
-
Because TweenSettings is a generic struct it doesn't have the ColorUsageAttribute on its As a workaround, it's possible to create a new TweenSettingsHDR struct that can be used in places where an HDR version of TweenSettings is needed: using System;
using PrimeTween;
using UnityEngine;
[Serializable]
public struct TweenSettingsHDR {
[ColorUsage(true, true)]
public Color startValue, endValue;
public TweenSettings settings;
public static implicit operator TweenSettings<Color>(TweenSettingsHDR hdr) => new TweenSettings<Color>(hdr.startValue, hdr.endValue, hdr.settings);
} Usage example: [SerializeField] TweenSettingsHDR tweenSettingsHDR;
public Tween PlayHDRColorAnimation() {
return Tween.Color(GetComponent<SpriteRenderer>(), tweenSettingsHDR);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
KyryloKuzyk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because TweenSettings is a generic struct it doesn't have the ColorUsageAttribute on its
startValue
andendValue
fields.As a workaround, it's possible to create a new TweenSettingsHDR struct that can be used in places where an HDR version of TweenSettings is needed:
Usage example: