centner_dc

UI_Slider_Tools

Sep 29th, 2020 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3.  
  4. namespace Tools
  5. {
  6.     public static class ColorExtension
  7.     {
  8.         public static float GetHue(this Color color)
  9.         {
  10.             Color.RGBToHSV(color, out var H, out var S, out var V);
  11.             return H;
  12.         }
  13.  
  14.         public static Color SetHue(Color color, float hue)
  15.         {
  16.             Color.RGBToHSV(color, out var H, out var S, out var V);
  17.             return Color.HSVToRGB(hue, S, V);
  18.         }
  19.     }
  20.  
  21.     public static class VerifyExtension
  22.     {
  23.         public static void VerifyPositive(this float value, string parameterName, string message = "")
  24.         {
  25.             if (value < 0)
  26.                 throw new ArgumentOutOfRangeException(parameterName, message);
  27.         }
  28.  
  29.  
  30.         public static void VerifyNotNull<T>(this object targetObject, string parameterName, string message = "")
  31.                            where T : class
  32.         {
  33.             if (targetObject == null)
  34.             {
  35.                 throw new ArgumentNullException(parameterName, message);
  36.             }
  37.         }
  38.  
  39.         public static void VerifyNotNull<T>(this T? targetObject, string parameterName, string message = "")
  40.                            where T : struct
  41.         {
  42.             if (targetObject == null)
  43.             {
  44.                 throw new ArgumentNullException(parameterName, message);
  45.             }
  46.         }
  47.     }
  48. }
  49.  
Add Comment
Please, Sign In to add comment