Demigiant

DOTween HDRP Shadow Dimmer shortcut

Jul 22nd, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.83 KB | None | 0 0
  1. using DG.Tweening;
  2. using DG.Tweening.Core;
  3. using DG.Tweening.Plugins.Options;
  4. using UnityEngine;
  5. using UnityEngine.Rendering.HighDefinition;
  6.  
  7. public static class ExtraDOTweenShortcuts
  8. {
  9.     /// <summary>Tweens a Light's shadowStrength to the given value.
  10.     /// Also stores the light as the tween's target so it can be used for filtered operations.<para/>
  11.     /// Note that this method contains an internal GetComponent call to retrieve
  12.     /// the <see cref="HDAdditionalLightData"/> necessary to tween the shadow dimmer.
  13.     /// To avoid the GetComponent call use the overload that accepts a <see cref="HDAdditionalLightData"/> target.</summary>
  14.     /// <param name="endValue">The end value to reach</param>
  15.     /// <param name="duration">The duration of the tween</param>
  16.     public static TweenerCore<float, float, FloatOptions> DOHDRPShadowDimmer(this Light target, float endValue, float duration)
  17.     {
  18.         HDAdditionalLightData lightData = target.GetComponent<HDAdditionalLightData>();
  19.         TweenerCore<float, float, FloatOptions> t = DOTween.To(() => lightData.shadowDimmer, x => lightData.shadowDimmer = x, endValue, duration);
  20.         t.SetTarget(target);
  21.         return t;
  22.     }
  23.  
  24.     /// <summary>Tweens a Light's shadowStrength to the given value.
  25.     /// Also stores the light as the tween's target so it can be used for filtered operations</summary>
  26.     /// <param name="endValue">The end value to reach</param>
  27.     /// <param name="duration">The duration of the tween</param>
  28.     public static TweenerCore<float, float, FloatOptions> DOHDRPShadowDimmer(this HDAdditionalLightData target, float endValue, float duration)
  29.     {
  30.         TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.shadowDimmer, x => target.shadowDimmer = x, endValue, duration);
  31.         t.SetTarget(target);
  32.         return t;
  33.     }
  34. }
Add Comment
Please, Sign In to add comment