Пример #1
0
    public static void SetSize(int width, int height)
    {
        GameViewSizeGroupType currentType = GameViewUtils.GetCurrentGroupType();
        bool addToList = false;

        if (!GameViewUtils.SizeExists(currentType, width, height))
        {
            string viewName = GetViewName(width, height);
            GameViewUtils.AddCustomSize(GameViewUtils.GameViewSizeType.FixedResolution, currentType, width, height, viewName);
            addToList = true;
        }

        int index = GameViewUtils.FindSize(currentType, width, height);

        if (index < 0)
        {
            Debug.LogError("Cannot find Game View Size for width: " + width.ToString() + "  height: " + height.ToString());
        }
        else
        {
            if (addToList)
            {
                indices.Add(index);
            }

            GameViewUtils.SetSize(index);
        }
    }
    private async Task PerformShot()
    {
        if (this.bundleType == ScreenshotBundleType.None)
        {
            int width  = resWidth * scale;
            int height = resHeight * scale;
            this.Capture(width, height, ScreenShotName(width, height));
        }
        else
        {
            var screenshotBundle = ScreenshotBundle.ByType(this.bundleType);
            foreach (var screenshotDefinition in screenshotBundle.definitions)
            {
                int width  = screenshotDefinition.width * scale;
                int height = screenshotDefinition.height * scale;

                if (GameViewUtils.FindSize(GameViewUtils.GetCurrentGroupType(), width, height) == -1)
                {
                    GameViewUtils.AddCustomSize(GameViewSizeType.FixedResolution, GameViewUtils.GetCurrentGroupType(), width, height, screenshotDefinition.suffix);
                }
                GameViewUtils.SetSize(GameViewUtils.FindSize(GameViewUtils.GetCurrentGroupType(), width, height));

                await Task.Delay(ShutterDelay);

                var directory = screenshotBundle.GetDirectory(screenshotDefinition);
                this.PrepareDirectory(path + "/", directory);
                var fullPath = $"{path}/{directory}";

                var fileName = string.Format("{0}{1}_{2}.png",
                                             fullPath,
                                             screenshotDefinition.Name,
                                             System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
                this.Capture(width, height, fileName);
            }
        }
    }