Beispiel #1
0
    void OnGUI()
    {
        var gameView = Utilities.GetMainGameView();
        if(gameView == null)
            return;

        Vector2 viewRect = new Vector2(gameView.position.width, gameView.position.height - 17);

        bool matches = true;
        if (viewRect.y != _size.y || viewRect.x != _size.x)
        {
            matches = false;
        }

        GUI.color = matches ? Color.white : Color.red;

        _size.x = EditorGUILayout.IntField ("X (" + viewRect.x  + ")", (int)_size.x);
        _size.y = EditorGUILayout.IntField ("Y (" + viewRect.y + ")", (int)_size.y);

        GUI.color = Color.white;

        _invert = EditorGUILayout.Toggle("Invert", _invert);
        _superSizeScale = EditorGUILayout.IntSlider("Supersize", _superSizeScale, 1, 4);

        GUILayout.Space(10.0f);
        ScreenshotSize newSize = (ScreenshotSize)EditorGUILayout.EnumPopup("iOS screenshot size", size);
        if(newSize != size)
        {
            size = newSize;
            Vector2 desiredSize = nameToSize[newSize];
            if(_invert)
            {
                Vector2 invert = desiredSize;
                desiredSize.x = invert.y;
                desiredSize.y = invert.x;
            }

            desiredSize.x /= (float)_superSizeScale;
            desiredSize.y /= (float)_superSizeScale;

            _size = desiredSize;

            UtilitiesScreenshot.SetGameViewSize(_size);
            Repaint();
        }
        GUILayout.Space(10.0f);

        GUI.color = Color.white;

        if (GUILayout.Button ("Set"))
        {
            UtilitiesScreenshot.SetGameViewSize(_size);
            Repaint();
        }

        if(GUILayout.Button ("Screenshot"))
            TakeScreenshot();

        GUILayout.Label("If this doesn't work, try turning on Stats in the GameView and dragging the window until it's the size you want.");
    }
Beispiel #2
0
        private static string GetScreenshotPath(Guid appGuid, string fileName, ScreenshotSize screenshotSize)
        {
            var directoryPath = $@"{ConfigurationReader.AppsDirectoryPath}\{appGuid}\Screenshots\{screenshotSize}\";

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            return($"{directoryPath}{fileName}");
        }
Beispiel #3
0
        public async Task WarmUpAsync(string url, ScreenshotSize size)
        {
            using (var page = await this.browser.NewPageAsync())
            {
                await page.SetViewportAsync(new ViewPortOptions
                {
                    Width             = size.Width,
                    Height            = size.Height,
                    DeviceScaleFactor = size.Scale / 100.0
                });

                await page.GoToAsync(url, 90000, new[] { WaitUntilNavigation.Load });
            }
        }
Beispiel #4
0
        public async Task ScreenshotAsync(string url, ScreenshotSize size, string outFilePath)
        {
            using (var page = await this.browser.NewPageAsync())
            {
                await page.SetViewportAsync(new ViewPortOptions
                {
                    Width             = size.Width,
                    Height            = size.Height,
                    DeviceScaleFactor = size.Scale / 100.0
                });

                await page.GoToAsync(url, 60000, new[] { WaitUntilNavigation.Load });

                await Task.Delay(2000);

                await page.ScreenshotAsync(outFilePath, new ScreenshotOptions()
                {
                    Type = ScreenshotType.Png
                });
            }
        }
Beispiel #5
0
        public static Uri GetScreenshotDownloadUri(Guid appId, int index, ScreenshotType type, ScreenshotSize size)
        {
            var url = $"http://{host}/appcode/httphandler/AppScreenshotDownload.ashx?appId={appId}&index={index}&type={type}&size={size}";

            return(new Uri(url, UriKind.Absolute));
        }
Beispiel #6
0
        public string GetAppScreenshotFilePath(Guid appGuid, ScreenshotType screenshotType, ScreenshotSize screenshotSize, int screenshotIndex)
        {
            var appScreenshot = _context.Apps
                                .Single(app => app.Guid == appGuid)
                                .Screenshots
                                .Where(screenshot => screenshot.Type == screenshotType)
                                .Skip(screenshotIndex)
                                .Take(1)
                                .Single();

            return
                ($@"{ConfigurationReader.AppsDirectoryPath}\{appGuid}\Screenshots\{screenshotSize}\{
                    appScreenshot.FileName}");
        }
Beispiel #7
0
        public byte[] GetAppScreenshot(Guid appGuid, ScreenshotType screenshotType, ScreenshotSize screenshotSize, int screenshotIndex)
        {
            var path = GetAppScreenshotFilePath(appGuid, screenshotType, screenshotSize, screenshotIndex);

            return(File.ReadAllBytes(path));
        }
Beispiel #8
0
 public string GetAppScreenshotFilePath(Guid appGuid, ScreenshotType screenshotType, ScreenshotSize screenshotSize, int screenshotIndex)
 {
     return(AppBiz.GetAppScreenshotFilePath(appGuid, screenshotType, screenshotSize, screenshotIndex));
 }