Example #1
0
        protected void ResizeImple()
        {
            var groupType    = GameViewSizeHelper.GetCurrentGameViewSizeGroupType();
            var gameViewSize = new GameViewSizeHelper.GameViewSize();

            gameViewSize.type     = GameViewSizeHelper.GameViewSizeType.FixedResolution;
            gameViewSize.width    = Window.Orientation == Orientation.Portrait ? Width : Height;
            gameViewSize.height   = Window.Orientation == Orientation.Portrait ? Height : Width;
            gameViewSize.baseText = Label;

            if (!GameViewSizeHelper.Contains(groupType, gameViewSize))
            {
                GameViewSizeHelper.AddCustomSize(groupType, gameViewSize);
            }

            GameViewSizeHelper.ChangeGameViewSize(groupType, gameViewSize);
            Save.Set <string>(GameViewSizeChanger.Key_GameViewSizeChanger_LastLabel, Label);

            // HACK: 2フレーム待たないとSnapZoomが動作しないケースがある
            EditorApplication.delayCall += () =>
            {
                EditorApplication.delayCall += () =>
                {
                    var   flag             = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance;
                    var   assembly         = typeof(Editor).Assembly;
                    var   type             = assembly.GetType("UnityEditor.GameView");
                    var   gameView         = EditorWindow.GetWindow(type, false, "Game", false);
                    var   minScaleProperty = type.GetProperty("minScale", flag);
                    float minScale         = (float)minScaleProperty.GetValue(gameView, null);
                    type.GetMethod("SnapZoom", flag, null, new System.Type[] { typeof(float) }, null).Invoke(gameView, new object[] { minScale });
                    gameView.Repaint();
                    Window.Focus();
                };
            };
        }
 static GameViewSizeInitializer()
 {
     if (!GameViewSizeHelper.Contains(groupType, gameViewSizeType, width, height, text))
     {
         GameViewSizeHelper.AddCustomSize(groupType, gameViewSizeType, width, height, text);
     }
 }
        static IEnumerator CaptureScreenshot(int number)
        {
            string directoryName = "screenshots";

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

            var editorWindowAssembly = typeof(EditorWindow).Assembly;
            var currentSizeGroupType = GetCurrentSizeGroupType(editorWindowAssembly);
            var gameViewType         = editorWindowAssembly.GetType("UnityEditor.GameView");
            var gameViewWindow       = EditorWindow.GetWindow(gameViewType);

            foreach (var customSize in _customSizes)
            {
                if (!GameViewSizeHelper.Contains(currentSizeGroupType, customSize))
                {
                    GameViewSizeHelper.AddCustomSize(currentSizeGroupType, customSize);
                }

                GameViewSizeHelper.ChangeGameViewSize(currentSizeGroupType, customSize);
                var filename = Path.Combine(directoryName, $"{customSize.baseText}_{number}.png");
                EditorApplication.Step();
                EditorApplication.Step();
                ScreenCapture.CaptureScreenshot(filename);
                gameViewWindow.Repaint();
                Debug.Log($">> ScreenshotForAppStore : save to {filename}");
                yield return(null);
            }
        }
    public void PopulatePresetList()
    {
        ClearButtons();
        if (cameraOutputControl != null && cameraOutputControl.outputTextures != null)
        {
            foreach (var tex in cameraOutputControl.outputTextures)
            {
                var button = new Button();
                button.text         = tex.name;
                button.style.height = 30;
                buttons.Add(button);

                button.clicked += (() =>
                {
                    cameraOutputControl.GetComponent <RawImage>().texture = tex;
                    if (!GameViewSizeHelper.Contains(GameViewSizeGroupType.Standalone, GameViewSizeHelper.GameViewSizeType.FixedResolution, tex.width, tex.height, tex.name))
                    {
                        AddGameViewSize(tex.width, tex.height, tex.name);
                    }

                    GameViewSizeHelper.ChangeGameViewSize(GameViewSizeGroupType.Standalone, GameViewSizeHelper.GameViewSizeType.FixedResolution, tex.width, tex.height, tex.name);
                });
                //
            }
        }
        // _iEnumerator = null;
    }
Example #5
0
        void ApplyImpl()
        {
            var gameViewSize = Convert();
            var groupType    = GetCurrentGroupType();

            if (!GameViewSizeHelper.Contains(groupType, gameViewSize))
            {
                GameViewSizeHelper.AddCustomSize(groupType, gameViewSize);
            }
            GameViewSizeHelper.ChangeGameViewSize(groupType, gameViewSize);
        }
Example #6
0
        static IEnumerator CaptureScreenshot(int number)
        {
            string directoryName = "screenshots";

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

            var assembly  = typeof(EditorWindow).Assembly;
            var groupType = currentSizeGroupType(assembly);
            var type      = assembly.GetType("UnityEditor.GameView");
            var gameview  = EditorWindow.GetWindow(type);

            GameViewSize[] customSizes =
            {
                new GameViewSize(1242, 2688, "6.5"),
                new GameViewSize(1242, 2208, "5.5"),
                new GameViewSize(2048, 2732, "12.9"),
            };

            for (int i = 0; i < customSizes.Length; i++)
            {
                var customSize = customSizes[i];
                if (!GameViewSizeHelper.Contains(groupType, customSize))
                {
                    GameViewSizeHelper.AddCustomSize(groupType, customSize);
                }
                GameViewSizeHelper.ChangeGameViewSize(groupType, customSize);
                var filename = $"{directoryName}/{customSize.baseText}_{number}.png";
                EditorApplication.Step();
                EditorApplication.Step();
                ScreenCapture.CaptureScreenshot(filename);
                gameview.Repaint();
                Debug.Log(">> CaptureScreenshotsForAppStore : save to " + filename);
                //GameViewSizeHelper.RemoveCustomSize(groupType, customSize);
                yield return(null);
            }
        }