PhotographSaveView.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections;
  3. using System.IO;
  4. using ET;
  5. using FairyGUI;
  6. using UI.DressUp;
  7. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. public class PhotographSaveView : BaseView
  11. {
  12. private UI_PhotographSaveUI _ui;
  13. protected override void OnInit()
  14. {
  15. base.OnInit();
  16. packageName = UI_PhotographUI.PACKAGE_NAME;
  17. _ui = UI_PhotographSaveUI.Create();
  18. viewCom = _ui.target;
  19. isfullScreen = true;
  20. _ui.m_btnClose.onClick.Add(this.Hide);
  21. _ui.m_btnSave.onClick.Add(this.OnClickBtnSave);
  22. }
  23. protected override void OnShown()
  24. {
  25. base.OnShown();
  26. Texture2D tex = this.viewData as Texture2D;
  27. _ui.m_imgRes.texture = new NTexture(tex);
  28. float width = _ui.m_imgBorder.width;
  29. float height = width * tex.height / tex.width;
  30. _ui.m_imgRes.SetSize(width, height);
  31. _ui.m_imgBorder.SetSize(width, height + 12);
  32. }
  33. protected override void OnHide()
  34. {
  35. base.OnHide();
  36. }
  37. public override void Dispose()
  38. {
  39. if (_ui != null)
  40. {
  41. _ui.Dispose();
  42. _ui = null;
  43. }
  44. base.Dispose();
  45. }
  46. private void OnClickBtnSave()
  47. {
  48. Texture2D tex = this.viewData as Texture2D;
  49. PoemPhotoDataManager.Instance.SavePicturoToLocal(tex);
  50. }
  51. }
  52. }