Exemple #1
0
    public static void ClearAllSizes()
    {
        int buildin = (int)SizeHolder.CallMethod("GetBuiltinCount");

        for (int i = buildin; i < (int)SizeHolder.CallMethod("GetTotalCount");)
        {
            SizeHolder.CallMethod("RemoveCustomSize", buildin);
        }
    }
Exemple #2
0
 public static void AddAllSizes(List <ScreenshotData> datas)
 {
     foreach (ScreenshotData data in datas)
     {
         if (!data.isEnabled)
         {
             continue;
         }
         object customSize = GetFixedResolution((int)data.resolution.x, (int)data.resolution.y, data.name);
         SizeHolder.CallMethod("AddCustomSize", customSize);
     }
 }
    private static void CaptureQueuedScreenshots()
    {
        if (queuedScreenshots.Count == 0)
        {
            return;
        }

        ScreenshotData data = queuedScreenshots.Peek();

        int width  = Mathf.RoundToInt(data.resolution.x * data.resolutionMultiplier);
        int height = Mathf.RoundToInt(data.resolution.y * data.resolutionMultiplier);

#if POLYGLOT
        EditorUtility.DisplayProgressBar("Making screenshots", $"{data.targetCamera} {width}x{height} {data.lang}", currentStage / (float)totalStages);
#else
        EditorUtility.DisplayProgressBar("Making screenshots", $"{data.targetCamera} {width}x{height}", currentStage / (float)totalStages);
#endif
        ++currentStage;

        if (!isTakeScreenshot)
        {
            isTakeScreenshot = true;

            if (originalIndex == -1)
            {
                originalIndex = (int)GameView.FetchProperty("selectedSizeIndex");
            }

            object customSize = GetFixedResolution(width, height);
            SizeHolder.CallMethod("AddCustomSize", customSize);
            newIndex        = (int)SizeHolder.CallMethod("IndexOf", customSize) + (int)SizeHolder.CallMethod("GetBuiltinCount");
            resolutionIndex = newIndex;

#if POLYGLOT
            Localization.Instance.SelectedLanguage = data.lang;
#endif

            GameView.CallMethod("SizeSelectionCallback", resolutionIndex, null);
            GameView.Repaint();
        }
        else
        {
            isTakeScreenshot = false;

            if (!data.captureOverlayUI || data.targetCamera == ScreenshooterTargetCamera.SceneView)
            {
                CaptureScreenshotWithoutUI(data);
            }
            else
            {
                CaptureScreenshotWithUI(data);
            }

            SizeHolder.CallMethod("RemoveCustomSize", newIndex);

            queuedScreenshots.Dequeue();
            if (queuedScreenshots.Count == 0)
            {
                resolutionIndex = originalIndex;
                GameView.CallMethod("SizeSelectionCallback", resolutionIndex, null);

#if POLYGLOT
                Localization.Instance.SelectedLanguage = usedLanguage;
#endif

                EditorApplication.update -= CaptureQueuedScreenshots;

                Debug.Log("<b>Saved screenshots:</b> " + usedOutputFolder);
                EditorUtility.ClearProgressBar();
            }
        }
    }