|
@@ -1,6 +1,7 @@
|
|
|
using ET;
|
|
|
using FairyGUI;
|
|
|
using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
|
|
|
namespace GFGGame
|
|
@@ -228,10 +229,83 @@ namespace GFGGame
|
|
|
|
|
|
private void MakeFullScreen(GObject ui)
|
|
|
{
|
|
|
- ui.MakeFullScreen();
|
|
|
+ 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]);
|
|
|
+ listTopImg[i].SetXY(listTopImg[i].x, listTopImg[i].y - offsetY);
|
|
|
+ }
|
|
|
+
|
|
|
+ _adaptFinished = true;
|
|
|
+ }
|
|
|
+
|
|
|
void __addedToStage()
|
|
|
{
|
|
|
DoShowAnimation();
|