UISendGreetings.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEngine;
  2. using System.Collections;
  3. public class UISendGreetings : MonoBehaviour
  4. {
  5. public UIButton mail;
  6. public UIButton cancel;
  7. public UIButton open;
  8. public UIInput input;
  9. public UILabel label;
  10. public static bool Visible { get; private set; }
  11. // Use this for initialization
  12. void Start ()
  13. {
  14. mail.onClick.Add(new EventDelegate(OnMail));
  15. cancel.onClick.Add(new EventDelegate(OnCancel));
  16. open.onClick.Add(new EventDelegate(OnOpen));
  17. OnCancel();
  18. }
  19. private void Update()
  20. {
  21. if (Visible)
  22. {
  23. input.transform.localScale = new Vector3(0.25f,0.25f,1);
  24. label.maxLineCount = 10;
  25. }
  26. }
  27. private void OnMail()
  28. {
  29. var subject = WWW.EscapeURL("Jólakveðja fyrir pakkaleikinn").Replace("+", "%20");
  30. var email = "kringlan@kringlan.is";
  31. var body = WWW.EscapeURL(input.value).Replace("+", "%20");
  32. var url = "mailto:" + email + "?subject=" + subject + "&body=" + body;
  33. Debug.Log(url);
  34. Application.OpenURL(url);
  35. gameObject.SetActive(false);
  36. Visible = false;
  37. }
  38. private void OnCancel()
  39. {
  40. gameObject.SetActive(false);
  41. Visible = false;
  42. }
  43. private void OnOpen()
  44. {
  45. if (Visible)
  46. {
  47. OnCancel();
  48. }
  49. else
  50. {
  51. gameObject.SetActive(true);
  52. Visible = true;
  53. }
  54. }
  55. }