UICoupones.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5. public class UICoupones : MonoBehaviour {
  6. // Use this for initialization
  7. public List<GameObject> items = new List<GameObject>();
  8. public GameObject CouponePrefab;
  9. public Transform Scroll;
  10. public UIButton BackButton;
  11. void Start()
  12. {
  13. BackButton.onClick.Add(new EventDelegate(OnBack));
  14. }
  15. private void OnBack()
  16. {
  17. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Menu);
  18. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.Coupones);
  19. }
  20. void OnEnable ()
  21. {
  22. CouponePrefab.SetActive(true);
  23. foreach (var item in items)
  24. {
  25. Destroy(item);
  26. }
  27. items.Clear();
  28. for (int i = 0; i < ServerGiftManager.Instance.Coupons.Count; i++)
  29. {
  30. var go = (GameObject)Instantiate(CouponePrefab);
  31. go.AddComponent<UIDragPanelContents>();
  32. go.transform.parent = Scroll.transform;
  33. go.transform.localScale = Vector3.one;
  34. go.transform.localPosition = new Vector3(0,0,-0.5f);
  35. go.GetComponent<UIButtonCouponeInfo>().Rename(ServerGiftManager.Instance.Coupons[i].name);
  36. go.GetComponent<UIButtonCouponeInfo>().CouponeIndex= i;
  37. go.GetComponent<UIButton>().onClick.Add(new EventDelegate(OnCoupone));
  38. items.Add(go);
  39. Scroll.GetComponent<UIGrid>().repositionNow = true;
  40. }
  41. CouponePrefab.SetActive(false);
  42. }
  43. private void OnCoupone()
  44. {
  45. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.CouponeGet);
  46. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.Coupones);
  47. //NGUIMenuScript.Instance.UiGetCoupone.CouponeInit(couponInfo);
  48. }
  49. /*private static EventDelegate.Callback OnCoupone(ServerGiftManager.CouponInfo couponInfo)
  50. {
  51. return NGUIMenuScript.Instance.UiGetCoupone.CouponeInit(couponInfo);
  52. }*/
  53. // Update is called once per frame
  54. void Update () {
  55. }
  56. }