ExampleColorReceiver.cs 479 B

1234567891011121314151617181920212223
  1. using UnityEngine;
  2. public class ExampleColorReceiver : MonoBehaviour {
  3. Color color;
  4. void OnColorChange(HSBColor color)
  5. {
  6. this.color = color.ToColor();
  7. }
  8. void OnGUI()
  9. {
  10. var r = Camera.main.pixelRect;
  11. var rect = new Rect(r.center.x + r.height / 6 + 50, r.center.y, 100, 100);
  12. GUI.Label (rect, "#" + ToHex(color.r) + ToHex(color.g) + ToHex(color.b));
  13. }
  14. string ToHex(float n)
  15. {
  16. return ((int)(n * 255)).ToString("X").PadLeft(2, '0');
  17. }
  18. }