zoukankan      html  css  js  c++  java
  • ngui 适配iphone x

    using UnityEngine;

    using System.Collections;

    [RequireComponent(typeof(UIPanel))]
    public class FixedUIRect : MonoBehaviour
    {
    public enum SAVE_AREA
    {
    FULL_SCREEN,
    SAVE_AREA_WITH_BOTTOM,
    SAVE_AREA,
    }

    public SAVE_AREA type = SAVE_AREA.FULL_SCREEN;
    public float IPHONE_X_SAVE_RASIO = 0.965f;
    private UIPanel panel;

    void OnEnable ()
    {
    FixClipRegion ();
    }

    void Start ()
    {
    FixClipRegion ();
    }

    private bool IsIphoneX()
    {
    return true;
    // return NativeManager.inst.IsIPHONEX ();
    }
    private void FixClipRegion ()
    {
    panel = GetComponent<UIPanel> ();

    UIRoot rt = panel.root;

    if (panel != null && IsIphoneX() && rt != null) {

    panel.clipping = UIDrawCall.Clipping.ConstrainButDontClip;

    if (type == SAVE_AREA.SAVE_AREA_WITH_BOTTOM)
    {
    panel.baseClipRegion = new Vector4 (0, 0, panel.root.manualHeight * (757 / 375f), panel.root.manualHeight);
    }
    else if (type == SAVE_AREA.SAVE_AREA)
    {
    panel.baseClipRegion = new Vector4(0, 0, panel.root.manualHeight * (785 / 375f), panel.root.manualHeight);
    float offsetY = (1 - IPHONE_X_SAVE_RASIO) * panel.root.manualHeight / 2;
    gameObject.transform.localPosition = new Vector3(0,offsetY);

    float scale = IPHONE_X_SAVE_RASIO;
    gameObject.transform.localScale = scale * Vector3.one;

    }
    else
    {
    panel.baseClipRegion = new Vector4 (0, 0, panel.root.manualHeight * (812 / 375f), panel.root.manualHeight);
    }
    }
    }
    }

  • 相关阅读:
    在tmux中如何复制文本并粘贴到某处?
    linux下的用户密码文件/etc/shadow
    linux下openssl命令解析
    第 27 章 CSS 传统布局[下]
    第 27 章 CSS 传统布局[上]
    第 26 章 CSS3 动画效果
    第 25 章 CSS3 过渡效果
    第 24 章 CSS3 变形效果[下]
    第 23 章 CSS3 边框图片效果
    第 22 章 CSS3 渐变效果
  • 原文地址:https://www.cnblogs.com/rexzhao/p/8358431.html
Copyright © 2011-2022 走看看