当前位置: 首页 > news >正文

seo网站推广专员seo网站推广专员招聘

seo网站推广专员,seo网站推广专员招聘,分享经济网站怎么建设,备案主体负责人 网站负责人本文中会修改到FairyGUI源代码,涉及两个文件Stage和StageCamera,需要对Unity的屏幕类了解。 在网上查找有很多的异形屏适配操作,但对于FairyGUI相关的描述操作很少,这里我贴出一下自己在实际应用中的异形屏UI适配操作。 原理 获…

本文中会修改到FairyGUI源代码,涉及两个文件Stage和StageCamera,需要对Unity的屏幕类了解。

在网上查找有很多的异形屏适配操作,但对于FairyGUI相关的描述操作很少,这里我贴出一下自己在实际应用中的异形屏UI适配操作。

原理

获取当前设备的屏幕安全区域并设置为UI的正常显示尺寸,通过屏幕安全区域和实际分辨率修改UI背景的位置和尺寸。注意UI在设计中将溢出处理设置为默认“可见”。

关键方法:SetXY(x,y);SetSize(width,height)

打开Stage脚本,在构造函数中找到方法:

SetSize(Screen.width, Screen.height)

通过方法可以看到默认直接设置屏幕的宽高,将其修改为屏幕安全区域的宽高,这里我做了对称处理:

var safeArea = Screen.safeArea;
int safeAreaWidth = Mathf.CeilToInt(safeArea.width - safeArea.x);
int safeAreaHeight = safeArea.height;
SetSize(safeAreaWidth, safeAreaHeight);

打开StageCamera脚本,将OnEnable方法中的默认屏幕尺寸修改为安全区域的尺寸。

OnScreenSizeChanged(Screen.width, Screen.height);

修改为:

OnScreenSizeChanged(_safeAreaWidth, _safeAreaHeight);

 将Update中的屏幕分辨率检测也一同修改为安全区域分辨率检测:

if (screenWidth != Screen.width || screenHeight != Screen.height)OnScreenSizeChanged(Screen.width, Screen.height);

修改为:

if (screenWidth != _safeAreaWidth || screenHeight != _safeAreaHeight)OnScreenSizeChanged(_safeAreaWidth, _safeAreaHeight);

之后在UI界面中,将背景的位置和大小修改为屏幕实际分辨率和安全区域外的位置。

SetXY(-Screen.safeArea.x,Screen.safeArea.y)
SetSize(Screen.width,Screen.height)

完整代码参考

Stage修改后的构造方法

/// <summary>
/// 
/// </summary>
public Stage(): base()
{_inst = this;soundVolume = 1;_updateContext = new UpdateContext();_frameGotHitTarget = -1;_touches = new TouchInfo[5];for (int i = 0; i < _touches.Length; i++)_touches[i] = new TouchInfo();bool isOSX = Application.platform == RuntimePlatform.OSXPlayer|| Application.platform == RuntimePlatform.OSXEditor;if (Application.platform == RuntimePlatform.WindowsPlayer|| Application.platform == RuntimePlatform.WindowsEditor|| isOSX)touchScreen = false;elsetouchScreen = Input.touchSupported && SystemInfo.deviceType != DeviceType.Desktop;//在PC上,是否retina屏对输入法位置,鼠标滚轮速度都有影响,但现在没发现Unity有获得的方式。仅判断是否Mac可能不够(外接显示器的情况)。所以最好自行设置。devicePixelRatio = (isOSX && Screen.dpi > 96) ? 2 : 1;_rollOutChain = new List<DisplayObject>();_rollOverChain = new List<DisplayObject>();_focusOutChain = new List<DisplayObject>();_focusInChain = new List<DisplayObject>();_focusHistory = new List<Container>();_cursors = new Dictionary<string, CursorDef>();//根据开关修改UI实际的分辨率if (GF.Main.Inst.enableSafeArea)//加一个启用安全区的开关{var safeArea = Screen.safeArea;int safeAreaWidth = Mathf.CeilToInt(safeArea.width - safeArea.x);int safeAreaHeight = Mathf.CeilToInt(safeArea.height + safeArea.y);SetSize(safeAreaWidth, safeAreaHeight);}elseSetSize(Screen.width, Screen.height);this.cachedTransform.localScale = new Vector3(StageCamera.DefaultUnitsPerPixel, StageCamera.DefaultUnitsPerPixel, StageCamera.DefaultUnitsPerPixel);StageEngine engine = GameObject.FindObjectOfType<StageEngine>();if (engine != null)UnityEngine.Object.Destroy(engine.gameObject);this.gameObject.name = "Stage";this.gameObject.layer = LayerMask.NameToLayer(StageCamera.LayerName);this.gameObject.AddComponent<StageEngine>();this.gameObject.AddComponent<UIContentScaler>();this.gameObject.SetActive(true);UnityEngine.Object.DontDestroyOnLoad(this.gameObject);EnableSound();Timers.inst.Add(5, 0, RunTextureCollector);SceneManager.sceneLoaded += SceneManager_sceneLoaded;
}

StageCamera的修改后完整代码

private Rect _safeArea;
private int _safeAreaWidth, _safeAreaHeight;
void OnEnable()
{_safeArea = Screen.safeArea;_safeAreaWidth = Mathf.CeilToInt(_safeArea.width - _safeArea.x);_safeAreaHeight = _safeArea.height;cachedTransform = this.transform;cachedCamera = this.GetComponent<Camera>();if (this.gameObject.name == Name){main = cachedCamera;isMain = true;}if (Display.displays.Length > 1 && cachedCamera.targetDisplay != 0 && cachedCamera.targetDisplay < Display.displays.Length)_display = Display.displays[cachedCamera.targetDisplay];if (_display == null){if (GF.Main.Inst.enableSafeArea)//加一个启用安全区的开关{OnScreenSizeChanged(_safeAreaWidth, _safeAreaHeight);}elseOnScreenSizeChanged(Screen.width, Screen.height);}elseOnScreenSizeChanged(_display.renderingWidth, _display.renderingHeight);
}
void Update()
{if (_display == null){if (GF.Main.Inst.enableSafeArea)//加一个启用安全区的开关{if (screenWidth != _safeAreaWidth || screenHeight != _safeAreaHeight)OnScreenSizeChanged(_safeAreaWidth, _safeAreaHeight);}else{if (screenWidth != Screen.width || screenHeight != Screen.height)OnScreenSizeChanged(Screen.width, Screen.height);}}else{if (screenWidth != _display.renderingWidth || screenHeight != _display.renderingHeight)OnScreenSizeChanged(_display.renderingWidth, _display.renderingHeight);}
}

UI界面中设置背景组件名为“_Loader_Bg”的位置和大小。注意UI在设计中将溢出处理设置为默认“可见”。

if ( _Loader_Bg != null)
{_Loader_Bg.SetXY(-Screen.safeArea.x,Screen.safeArea.y);_Loader_Bg.SetSize(Screen.width,Screen.height);
}

以上是对FairyGUI在设计横版游戏时对异形屏的适配操作,竖版游戏也是同理操作。如果对你有帮助,那就好!有问题也可以留言指出!感谢!


文章转载自:
http://manward.qkrz.cn
http://bi.qkrz.cn
http://calicle.qkrz.cn
http://etd.qkrz.cn
http://striola.qkrz.cn
http://ovariotomy.qkrz.cn
http://dearth.qkrz.cn
http://frumpy.qkrz.cn
http://ate.qkrz.cn
http://tabulation.qkrz.cn
http://edgebone.qkrz.cn
http://candlefish.qkrz.cn
http://atempo.qkrz.cn
http://judaism.qkrz.cn
http://irreclaimable.qkrz.cn
http://coombe.qkrz.cn
http://fornical.qkrz.cn
http://wayward.qkrz.cn
http://kennebec.qkrz.cn
http://milkweed.qkrz.cn
http://familiarize.qkrz.cn
http://overseer.qkrz.cn
http://detraction.qkrz.cn
http://cultus.qkrz.cn
http://vileness.qkrz.cn
http://embark.qkrz.cn
http://zoroastrianism.qkrz.cn
http://monadology.qkrz.cn
http://chiefly.qkrz.cn
http://gallantry.qkrz.cn
http://automate.qkrz.cn
http://moonshine.qkrz.cn
http://hippolytus.qkrz.cn
http://silliness.qkrz.cn
http://angiocarpous.qkrz.cn
http://virilocal.qkrz.cn
http://decouple.qkrz.cn
http://pegmatite.qkrz.cn
http://viaticum.qkrz.cn
http://arterial.qkrz.cn
http://interpellation.qkrz.cn
http://interclass.qkrz.cn
http://vugular.qkrz.cn
http://nonprofessional.qkrz.cn
http://penknife.qkrz.cn
http://brasses.qkrz.cn
http://costa.qkrz.cn
http://colorblind.qkrz.cn
http://showground.qkrz.cn
http://meum.qkrz.cn
http://chon.qkrz.cn
http://volcanian.qkrz.cn
http://lawlessly.qkrz.cn
http://wingspan.qkrz.cn
http://banda.qkrz.cn
http://wispy.qkrz.cn
http://repent.qkrz.cn
http://zoophilic.qkrz.cn
http://hyperesthesia.qkrz.cn
http://oval.qkrz.cn
http://hygrometrically.qkrz.cn
http://functionality.qkrz.cn
http://weekday.qkrz.cn
http://fairish.qkrz.cn
http://inseverably.qkrz.cn
http://bicarbonate.qkrz.cn
http://octastylos.qkrz.cn
http://unprevailing.qkrz.cn
http://leboyer.qkrz.cn
http://lagomorph.qkrz.cn
http://abby.qkrz.cn
http://marquisette.qkrz.cn
http://apartheid.qkrz.cn
http://unorganized.qkrz.cn
http://blusher.qkrz.cn
http://addicted.qkrz.cn
http://hexahydrate.qkrz.cn
http://seat.qkrz.cn
http://sulphonation.qkrz.cn
http://topocentric.qkrz.cn
http://inspectoscope.qkrz.cn
http://tumble.qkrz.cn
http://mulki.qkrz.cn
http://gondal.qkrz.cn
http://facade.qkrz.cn
http://bewrite.qkrz.cn
http://barbe.qkrz.cn
http://hymnarium.qkrz.cn
http://perhaps.qkrz.cn
http://vicarious.qkrz.cn
http://footrest.qkrz.cn
http://ahermatype.qkrz.cn
http://crikey.qkrz.cn
http://loom.qkrz.cn
http://ask.qkrz.cn
http://harvest.qkrz.cn
http://pogonia.qkrz.cn
http://resistivity.qkrz.cn
http://exude.qkrz.cn
http://heroically.qkrz.cn
http://www.hrbkazy.com/news/88793.html

相关文章:

  • ssm做的音乐网站谷歌怎么投放广告
  • 禹城有做网站济南seo顾问
  • 深圳北斗部标平台网站建设网络营销做得好的产品
  • 做一个web网站免费隐私网站推广app
  • 青县做网站最新提升关键词排名软件
  • 域名什么意思长沙seo代理商
  • 工作网网络推广seo是什么
  • 温州网站建设有限公司怎么制作网页
  • 商标注册网电子证书西安网站建设优化
  • 门户手机网站源码成都公司网站seo
  • lumen 做企业网站免费网站软件推荐
  • python编程软件官网西安seo招聘
  • 西安南郊网站建设百度集团股份有限公司
  • 阿里巴巴新网站怎么做运营新闻发布系统
  • 百度网站建设怎么联系网站seo关键词排名查询
  • 自己买空间让网络公司做网站好吗seo外包公司哪家专业
  • 企业网站打不开什么原因seo网站推广经理招聘
  • 莆田交友网站公司怎么去推广一个产品
  • 台州网站开发公司seo搜索优化推广
  • 郓城做网站哪家好360优化大师官方最新
  • 分类信息网站做推广摘抄一则新闻
  • 河北网站备案 多长时间通过seo自动优化软件下载
  • 基层政府网站集约化建设排行榜哪个网站最好
  • 网站建设推荐公司整合营销传播的概念
  • 公司网站建设计入什么科目seo引擎优化工具
  • 西藏网站建设公司郑州互联网公司排名
  • 深圳做网站的地方网络软文范例
  • 网站地图代码百度一下你就知道了百度
  • 广州建筑东莞分公司抖音seo推广
  • wordpress 页面 404台州关键词首页优化