Exemple #1
0
    void Update()
    {
        sb.Clear();
        ClearRects();

        sb.AppendLine($"<b>-- PLEASE ROTATE THE DEVICE TO GET BOTH ORIENTATION'S DETAILS! --</b>\n");

#if UNITY_EDITOR
        var safeArea = RealSize(NotchSolutionUtility.SimulatedSafeAreaRelative);
#else
        var safeArea = Screen.safeArea;
#endif
        PlaceRect(safeArea, Color.red);
        if (Screen.orientation != NotchSolutionUtility.GetCurrentOrientation())
        {
            safeArea.Set(Screen.width - safeArea.x, Screen.height - safeArea.y, safeArea.width, safeArea.height);
        }
        sb.AppendLine($"Safe area : {safeArea}\n");

#if UNITY_2019_2_OR_NEWER
#if UNITY_EDITOR
        var         relativeCutouts = NotchSolutionUtility.SimulatedCutoutsRelative;
        List <Rect> rectCutouts     = new List <Rect>();
        foreach (Rect rect in relativeCutouts)
        {
            rectCutouts.Add(RealSize(rect));
        }
        var cutouts = rectCutouts.ToArray();
#else
        var cutouts = Screen.cutouts;
#endif
        foreach (Rect r in cutouts)
        {
            PlaceRect(r, Color.blue);
        }

        if (Screen.orientation != NotchSolutionUtility.GetCurrentOrientation())
        {
            foreach (Rect rect in cutouts)
            {
                rect.Set(Screen.width - rect.x, Screen.height - rect.y, rect.width, rect.height);
            }
        }
        sb.AppendLine($"Cutouts : {string.Join(" / ", cutouts.Select(x => x.ToString()))} \n");
#endif

        sb.AppendLine($"Current resolution : {Screen.currentResolution}\n");
        sb.AppendLine($"All Resolutions : {string.Join(" / ", Screen.resolutions.Select(x => x.ToString()))}\n");
        sb.AppendLine($"DPI : {Screen.dpi} WxH : {Screen.width}x{Screen.height} Orientation : {Screen.orientation}\n");
        var joinedProps = string.Join(" / ", typeof(SystemInfo).GetProperties(BindingFlags.Public | BindingFlags.Static).Select(x => $"{x.Name} : {x.GetValue(null)}"));
        sb.AppendLine(joinedProps);
        debugText.text = sb.ToString();
    }
    void Update()
    {
        sb.Clear();
        ClearRects();

        switch (menu)
        {
        case Menu.Home:
            export.gameObject.SetActive(true);
            sb.AppendLine($"<b>-- PLEASE ROTATE THE DEVICE TO GET BOTH ORIENTATION'S DETAILS! --</b>\n");

            var safeArea = RelativeToReal(NotchSolutionUtility.ShouldUseNotchSimulatorValue ? storedSimulatedSafeAreaRelative : NotchSolutionUtility.ScreenSafeAreaRelative);

            PlaceRect(safeArea, Color.red);
            if (Screen.orientation != NotchSolutionUtility.GetCurrentOrientation())
            {
                safeArea.Set(Screen.width - safeArea.x, Screen.height - safeArea.y, safeArea.width, safeArea.height);
            }
            sb.AppendLine($"Safe area : {safeArea}\n");

#if UNITY_2019_2_OR_NEWER
#if UNITY_EDITOR
            var         relativeCutouts = NotchSolutionUtility.ShouldUseNotchSimulatorValue ? storedSimulatedCutoutsRelative : NotchSolutionUtility.ScreenCutoutsRelative;
            List <Rect> rectCutouts     = new List <Rect>();
            foreach (Rect rect in relativeCutouts)
            {
                rectCutouts.Add(RelativeToReal(rect));
            }
            var cutouts = rectCutouts.ToArray();
#else
            var cutouts = Screen.cutouts;
#endif
            foreach (Rect r in cutouts)
            {
                PlaceRect(r, Color.blue);
            }

            if (Screen.orientation != NotchSolutionUtility.GetCurrentOrientation())
            {
                foreach (Rect rect in cutouts)
                {
                    rect.Set(Screen.width - rect.x, Screen.height - rect.y, rect.width, rect.height);
                }
            }
            sb.AppendLine($"Cutouts : {string.Join(" / ", cutouts.Select(x => x.ToString()))} \n");
#endif

            sb.AppendLine($"Current resolution : {Screen.currentResolution}\n");
            sb.AppendLine($"All Resolutions : {string.Join(" / ", Screen.resolutions.Select(x => x.ToString()))}\n");
            sb.AppendLine($"DPI : {Screen.dpi} WxH : {Screen.width}x{Screen.height} Orientation : {Screen.orientation}\n");
            var joinedProps = string.Join(" / ", typeof(SystemInfo).GetProperties(BindingFlags.Public | BindingFlags.Static).Select(x => $"{x.Name} : {x.GetValue(null)}"));
            sb.AppendLine(joinedProps);

            break;

        case Menu.Extracting:
            var screen = device.Screens.FirstOrDefault();
            export.gameObject.SetActive(false);

            if (screen.orientations.Count == 4)
            {
                string path = Application.persistentDataPath + "/" + device.Meta.friendlyName + ".device.json";
                System.IO.File.WriteAllText(path, JsonUtility.ToJson(device));
                sb.AppendLine("<b>Done</b>");
                sb.AppendLine("");
                sb.AppendLine($"File saved at <i>{path}</i>");
                StartCoroutine(exportDone());
            }
            else
            {
                sb.AppendLine("Extracting...");
            }

            break;
        }
        debugText.text = sb.ToString();
    }