ColorHelper.cs 586 B

123456789101112131415161718192021222324252627
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Funly.SkyStudio
  5. {
  6. public abstract class ColorHelper
  7. {
  8. public static Color ColorWithHex(uint hex)
  9. {
  10. return ColorWithHexAlpha(hex << 8 | 0x000000FF);
  11. }
  12. public static Color ColorWithHexAlpha(uint hex)
  13. {
  14. float r = ((hex >> 24) & 0xFF) / 255.0f;
  15. float g = ((hex >> 16) & 0xFF) / 255.0f;
  16. float b = ((hex >> 8) & 0xFF) / 255.0f;
  17. float a = ((hex) & 0xFF) / 255.0f;
  18. return new Color(r, g, b, a);
  19. }
  20. }
  21. }