| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 | 
							- using ET;
 
- using FairyGUI;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     /// <summary>
 
-     /// 视图基类,界面不可以直接继承
 
-     /// </summary>
 
-     public class UIView : IUIView
 
-     {
 
-         private string _descFilePath;
 
-         private EnumViewAnimationType _viewAnimationType = EnumViewAnimationType.None;
 
-         /// <summary>
 
-         /// 打开视图传递的参数
 
-         /// </summary>
 
-         public object viewData { get; set; }
 
-         public string viewName { get; set; }
 
-         /// <summary>
 
-         /// 设置视图组件
 
-         /// </summary>
 
-         public virtual GComponent viewCom { get; set; }
 
-         /// <summary>
 
-         /// 设置是否全屏自适应
 
-         /// </summary>
 
-         public bool isfullScreen { get; set; }
 
-         /// <summary>
 
-         /// 设置是否可以返回界面
 
-         /// </summary>
 
-         public bool isReturnView { get; set; }
 
-         /// <summary>
 
-         /// 设置是否可以返回窗口
 
-         /// </summary>
 
-         public bool isReturnWindow { get; set; }
 
-         /// <summary>
 
-         /// 设置返回界面是否刷新
 
-         /// </summary>
 
-         public bool backRefresh { get; set; }
 
-         /// <summary>
 
-         /// FairyGUI包名
 
-         /// </summary>
 
-         public string packageName
 
-         {
 
-             get
 
-             {
 
-                 return _descFilePath;
 
-             }
 
-             set
 
-             {
 
-                 _descFilePath = ResPathUtil.GetUIPackagePath(value);
 
-                 GFGUIPackage.AddPackage(_descFilePath);
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 界面关闭时间
 
-         /// </summary>
 
-         /// <value></value>
 
-         public long closeTime { get; set; }
 
-         /// <summary>
 
-         /// 是否显示中
 
-         /// </summary>
 
-         public bool isShowing
 
-         {
 
-             get { return viewCom != null && viewCom.onStage; }
 
-         }
 
-         /// <summary>
 
-         /// 设置视图显示和隐藏的动画类型
 
-         /// </summary>
 
-         protected EnumViewAnimationType viewAnimationType
 
-         {
 
-             set
 
-             {
 
-                 _viewAnimationType = value;
 
-             }
 
-         }
 
-         public UIView()
 
-         {
 
-             //
 
-             Init();
 
-             OnInit();
 
-             if (viewCom != null)
 
-             {
 
-                 viewCom.onAddedToStage.Add(__addedToStage);
 
-                 viewCom.onRemovedFromStage.Add(__removeFromStage);
 
-             }
 
-         }
 
-         public virtual void Dispose()
 
-         {
 
-             if (viewCom != null)
 
-             {
 
-                 viewCom.RemoveFromParent();
 
-                 viewCom.Dispose();
 
-                 viewCom = null;
 
-             }
 
-             if (_descFilePath != null)
 
-             {
 
-                 if (packageName != ResPathUtil.GetUIPackagePath("CommonGame") && packageName != ResPathUtil.GetUIPackagePath("Common") && packageName != ResPathUtil.GetUIPackagePath("Main"))
 
-                 {
 
-                     GFGUIPackage.ReleasePackage(_descFilePath);
 
-                 } //这几个包不释放
 
-             }
 
-             _descFilePath = null;
 
-             viewData = null;
 
-             ViewManager.ClearUIView(viewName);
 
-         }
 
-         virtual protected void Init()
 
-         {
 
-         }
 
-         virtual protected void OnInit()
 
-         {
 
-         }
 
-         /// <summary>
 
-         /// 界面打开状态刷新界面
 
-         /// </summary>
 
-         virtual public void Refresh()
 
-         {
 
-             object temp = viewData;
 
-             this.OnHide();
 
-             this.viewData = temp;
 
-             this.BringToFront();
 
-             this.OnShown();
 
-         }
 
-         public virtual void Show()
 
-         {
 
-         }
 
-         virtual protected void BringToFront()
 
-         {
 
-         }
 
-         public virtual void Hide()
 
-         {
 
-             // UIPackageManager.Instance.RemovePackageView(_descFilePath, viewName);
 
-             // UIPackageManager.Instance.AddCloseTime(_descFilePath);
 
-             closeTime = TimeHelper.ClientNowSeconds();
 
-             DoHideAnimation();
 
-             ViewManager.HideWin(this.viewName);
 
-             EventAgent.DispatchEvent(ConstMessage.VIEW_CLOSED);
 
-         }
 
-         virtual protected void OnShown()
 
-         {
 
-             if (isfullScreen)
 
-             {
 
-                 MakeFullScreen(viewCom);
 
-             }
 
-             AddEventListener();
 
-             // if (GuideController.IsGuide())
 
-             // {
 
-             //     Timers.inst.AddUpdate(UpdateToCheckGuide);
 
-             // }
 
-         }
 
-         virtual protected void OnHide()
 
-         {
 
-             viewData = null;
 
-             RemoveEventListener();
 
-             // Timers.inst.Remove(UpdateToCheckGuide);
 
-             TryCompleteGuide();
 
-         }
 
-         virtual protected void RemoveEventListener()
 
-         {
 
-         }
 
-         virtual protected void AddEventListener()
 
-         {
 
-         }
 
-         virtual protected void UpdateToCheckGuide(object param)
 
-         {
 
-         }
 
-         virtual protected void TryCompleteGuide()
 
-         {
 
-         }
 
-         protected virtual void DoShowAnimation()
 
-         {
 
-             OnShown();
 
-             switch (_viewAnimationType)
 
-             {
 
-                 case EnumViewAnimationType.ZOOM_CENTER:
 
-                     ViewAnimationFactory.ZoomInCenter(this.viewCom);
 
-                     break;
 
-                 default:
 
-                     break;
 
-             }
 
-         }
 
-         protected virtual void DoHideAnimation()
 
-         {
 
-             switch (_viewAnimationType)
 
-             {
 
-                 case EnumViewAnimationType.ZOOM_CENTER:
 
-                     ViewAnimationFactory.ZoomOutCenter(this.viewCom, this.OnDoHideAnimationCompleted);
 
-                     break;
 
-                 default:
 
-                     this.OnDoHideAnimationCompleted();
 
-                     break;
 
-             }
 
-         }
 
-         protected virtual void OnDoHideAnimationCompleted()
 
-         {
 
-             if (this.viewCom != null)
 
-             {
 
-                 this.viewCom.RemoveFromParent();
 
-             }
 
-         }
 
-         private void MakeFullScreen(GObject ui)
 
-         {
 
-             // 摘星界面特殊处理
 
-             if (viewName == "LuckyBoxView")
 
-             {
 
-                 ui.MakeFullScreen();
 
-             }
 
-             else
 
-             {
 
-                 MakeUIFullScreen(ui);
 
-             }
 
-             
 
-             ui.AddRelation(GRoot.inst, RelationType.Size);
 
-         }
 
-         private bool _adaptFinished = false;
 
-         public void MakeUIFullScreen(GObject ui)
 
-         {
 
-             if (_adaptFinished)
 
-             {
 
-                 return;
 
-             }
 
-             //这里做了最大宽度适配
 
-             float targetWidth;
 
-             float maxAspectRatio = 1080 * 1.0f / 1920;
 
-             if (Screen.width * 1.0f / Screen.height > maxAspectRatio)
 
-             {
 
-                 targetWidth = GRoot.inst.height * maxAspectRatio;
 
-                 ui.Center();
 
-             }
 
-             else
 
-             {
 
-                 targetWidth = GRoot.inst.width;
 
-             }
 
-             GameObject uiObj = viewCom.displayObject.gameObject;
 
-             List<GObject> listTopImg = new List<GObject>();
 
-             float offsetY = ViewGlobal.GetRealTopOffset();
 
-             // 处理全屏显示的背景图/遮罩
 
-             List<Transform> list = ViewGlobal.FindAllGLoaderInTrans(uiObj.transform);
 
-             for (int i = 0; i < list.Count; i++)
 
-             {
 
-                 GameObject bg = list[i].gameObject;
 
-                 DisplayObjectInfo bgInfo = bg.GetComponent<DisplayObjectInfo>();
 
-                 GObject obj = GRoot.inst.DisplayObjectToGObject(bgInfo.displayObject);
 
-                 if (obj != null)
 
-                 {
 
-                     if (ViewGlobal.IsFullScreenPic(obj.name) && obj.height >= 1920)
 
-                     {
 
-                         obj.AddRelation(ui, RelationType.Center_Center);
 
-                         obj.SetSize(1080, 2400);
 
-                         obj.SetXY(obj.x, obj.y - offsetY / 2);
 
-                     }
 
-                     else if (obj.name.Contains("Top_img"))
 
-                     {
 
-                         listTopImg.Add(obj);
 
-                     }
 
-                 }
 
-             }
 
-             // 保存未适配时,不需要改变位置的UI的信息(适配部分存在拉伸效果的UI)
 
-             ui.SetSize(targetWidth, GRoot.inst.height);
 
-             List<float> heightList = new List<float>();
 
-             for (int i = 0; i < listTopImg.Count; i++)
 
-             {
 
-                 listTopImg[i].RemoveRelation(ui, RelationType.Center_Center);
 
-                 heightList.Add(listTopImg[i].height);
 
-             }
 
-             // UI整体高度缩放
 
-             ui.SetSize(targetWidth, ViewGlobal.GetUIHeight());
 
-             // UI整体下移动
 
-             ui.SetXY(ui.x, offsetY);
 
-             // 还原不需要适配的UI
 
-             for (int i = 0; i < listTopImg.Count; i++)
 
-             {
 
-                 listTopImg[i].SetSize(listTopImg[i].width, heightList[i] + offsetY * 2);
 
-                 listTopImg[i].SetXY(listTopImg[i].x, listTopImg[i].y - offsetY);
 
-             }
 
-             _adaptFinished = true;
 
-         }
 
-         void __addedToStage()
 
-         {
 
-             DoShowAnimation();
 
-         }
 
-         void __removeFromStage()
 
-         {
 
-             OnHide();
 
-             if (_descFilePath == ResPathUtil.GetUIPackagePath("Login") || _descFilePath == ResPathUtil.GetUIPackagePath("Loading") || _descFilePath == ResPathUtil.GetUIPackagePath("CreateRole"))//这几个界面关闭后立即释放
 
-             {
 
-                 Dispose();
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |