Esempio n. 1
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this);
     }
     else
     {
         instance = this;
     }
 }
Esempio n. 2
0
 public static void CalculateCanvasScale(Canvas canvasToCalculateFrom)
 {
     CurrentAspectRatio = GetAspectRatio(Screen.width, Screen.height);
     if (CurrentAspectRatio == HD || CurrentAspectRatio == RHD || CurrentAspectRatio == QXGA || CurrentAspectRatio == RQXGA)
     {
         // Height
         // 3/4
         CurrentGameScale = CanvasScale.Heigth;
     }
     else
     {
         // Width
         // OneTo2 ROneTo2
         // PhoneX
         CurrentGameScale = CanvasScale.Width;
     }
 }
    public static void CalculateCanvasScale(Canvas canvasToCalculateFrom)
    {
        CurrentAspectRatio = GetAspectRatio(Screen.width, Screen.height);
        if (CurrentAspectRatio == HD || CurrentAspectRatio == RHD || CurrentAspectRatio == QXGA || CurrentAspectRatio == RQXGA)
        {
            CurrentGameScale = CanvasScale.Original;
        }
        else
        {
            CurrentGameScale = CanvasScale.Extended;
        }

        // var safeArea = Screen.safeArea;
        // var anchorMin = safeArea.position;
        // var anchorMax = anchorMin + safeArea.size;
        // anchorMin.x /= canvasToCalculateFrom.pixelRect.width;
        // anchorMin.y /= canvasToCalculateFrom.pixelRect.height;
        // anchorMax.x /= canvasToCalculateFrom.pixelRect.width;
        // anchorMax.y /= canvasToCalculateFrom.pixelRect.height;

        // // SaveAreaTransform.anchorMin = anchorMin;
        // // SaveAreaTransform.anchorMax = anchorMax;
        // // SaveAreaTransform.offsetMin = Vector2.zero;
        // // SaveAreaTransform.offsetMax = Vector2.zero;

        // // TO DO : Make NotUsedParts ! x - top , y - left ,z - buttom  ,w - right

        // if (canvasToCalculateFrom.pixelRect.height > (safeArea.size.y + 5))
        // {
        //     Debug.LogWarning("[Canvas] SetSafeArea: changed _canvas.pixelRect.height" + canvasToCalculateFrom.pixelRect.height  + " safeArea.size.y " + safeArea.size.y);

        // }
        // else
        // {
        //     Debug.LogWarning("[Canvas] SetSafeArea:  Alright _canvas.pixelRect.height" + canvasToCalculateFrom.pixelRect.height  + " safeArea.size.y " + safeArea.size.y);

        // }
    }
Esempio n. 4
0
    void Awake()
    {
        Instance = this;

        canvas = GetComponent <CanvasScaler>();
    }