예제 #1
0
    private void AspectGUI()
    {
        EZ_Style.Header("Aspect", false, false);

        if (useBackground)
        {
            backgroundAspect = (EzSS_AspectHelper.Aspects)EditorGUILayout.EnumPopup("Background Aspect:", backgroundAspect);
        }

        if (useMockup)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Mockup Aspect:", GUILayout.Width(148));
            EZ_Style.BeginHorizontalRectBox();
            EditorGUILayout.LabelField(currentAspectName);
            EZ_Style.EndHorizontalRectBox();
            EditorGUILayout.EndHorizontal();
            VerifyAspect(mockupAspect);
        }
        else
        {
            screenshotAspect = (EzSS_AspectHelper.Aspects)EditorGUILayout.EnumPopup("Screenshot Aspect:", screenshotAspect);
            VerifyAspect(screenshotAspect);
        }

        EZ_Style.Footer();
    }
예제 #2
0
    RenderTexture renderTexture;    // = new RenderTexture(imageWidth, imageHeight, 24);

    private void ScreenshotGUI()
    {
        EZ_Style.Header("Screenshot", false, false);
        if (GUILayout.Button("Take Screenshot", GUILayout.Height(30)))
        {
            if (string.IsNullOrEmpty(saveAtPath))
            {
                EditorUtility.DisplayDialog(EzSS_Messages.TITLE_00, EzSS_Messages.ERROR_01, EzSS_Messages.BUTTON_00);
                return;
            }
            TakeScreenshot();
        }
        EZ_Style.Footer();
    }
예제 #3
0
    private void ResolutionsGUI()
    {
        EZ_Style.Header("Resolutions", false, false);

        if (useBackground)
        {
            SetBackgroundSize();
            GUILayout.Space(10);
        }
        if (useMockup)
        {
            SetMockupSize();
        }
        else
        {
            SetScreenshotSize();
        }

        EZ_Style.Footer();
    }
예제 #4
0
    private void OnGUI()
    {
        scrollBar = EditorGUILayout.BeginScrollView(scrollBar);

        BasicSetupGUI();
        GUILayout.Space(10);
        MockupGUI();
        GUILayout.Space(10);
        BackgroundGUI();
        GUILayout.Space(10);
        AspectGUI();
        GUILayout.Space(10);
        ResolutionsGUI();
        GUILayout.Space(10);
        ScreenshotGUI();
        GUILayout.Space(10);

        EZ_Style.DisplayInformation("https://forum.unity3d.com/threads/ez-screenshot.457345/");
        EditorGUILayout.EndScrollView();
    }
예제 #5
0
    private void BackgroundGUI()
    {
        if (useBackground = EZ_Style.Header("Background", true, useBackground))
        {
            backgroundColorOption = (BackgroundColorsOptions)EditorGUILayout.EnumPopup("Background Color:", backgroundColorOption);

            if (backgroundColorOption == BackgroundColorsOptions.black)
            {
                backgroundColor = Color.black;
            }
            else if (backgroundColorOption == BackgroundColorsOptions.transparent)
            {
                backgroundColor = Color.clear;
            }
            else if (backgroundColorOption == BackgroundColorsOptions.white)
            {
                backgroundColor = Color.white;
            }
            else
            {
                if (backgroundColor.a <= 0)
                {
                    backgroundColor = Color.white;
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Color:", GUILayout.Width(148));
                backgroundColor = EditorGUILayout.ColorField(GUIContent.none, backgroundColor, false, false, false, null, GUILayout.MinWidth(10));
                EditorGUILayout.EndHorizontal();
            }


            // If alpha is 0 display the warning
            if (encodeType == EncodeType.JPG && backgroundColor.a <= 0)
            {
                EditorGUILayout.HelpBox(EzSS_Messages.WARNING_01, MessageType.Warning);
            }
            EditorGUILayout.HelpBox(EzSS_Messages.INFO_00, MessageType.Info);
        }
        EZ_Style.Footer();
    }
예제 #6
0
    private string saveAtPath     = ""; // Save the path that the picture will be saved

    private void BasicSetupGUI()
    {
        // Camera
        EZ_Style.Header("Camera", false, false);
        cameraType = (CameraType)EditorGUILayout.EnumPopup("Camera Type:", cameraType);
        // Camera selection for each type
        if (cameraType == CameraType.single)
        {
            camera = EditorGUILayout.ObjectField("Camera:", camera, typeof(Camera), true, null) as Camera;
        }
        else
        {
            EditorGUILayout.HelpBox(EzSS_Messages.INFO_03, MessageType.Info);
            target           = this;
            serializedObject = new SerializedObject(target);
            property         = serializedObject.FindProperty("cameras");
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(property, true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
        EZ_Style.Footer();

        // Encode type
        EZ_Style.Header("Encode", false, false);
        encodeType = (EncodeType)EditorGUILayout.EnumPopup("Encode Type:", encodeType);
        if (encodeType == EncodeType.JPG)
        {
            jpgQuality = EditorGUILayout.IntSlider("Quality", jpgQuality, 1, 100);
        }
        EZ_Style.Footer();

        // Name prefix and configuration
        EZ_Style.Header("Name", false, false);
        fileNamePrefix = EditorGUILayout.TextField("Screenshot Prefix:", fileNamePrefix);
        useDate        = EditorGUILayout.Toggle("Use Date:", useDate);
        useTime        = EditorGUILayout.Toggle("Use Time:", useTime);

        // Cofigurates the name and display it
        finalFileName = fileNamePrefix;
        if (useDate)
        {
            finalFileName = finalFileName + "_" + DateTime.Now.ToString("yy-MMM-dd");
        }
        if (useTime)
        {
            finalFileName = finalFileName + "-" + DateTime.Now.ToString("HH-mm-ss");
        }
        EditorGUILayout.LabelField("File Name:");
        EZ_Style.BeginHorizontalRectBox();
        EditorGUILayout.LabelField(finalFileName);
        EZ_Style.EndHorizontalRectBox();
        EZ_Style.Footer();

        // Save at
        EZ_Style.Header("Save at Destination", false, false);
        // Set the path to save the image
        EditorGUILayout.LabelField("Save at:");
        EZ_Style.rect = EditorGUILayout.BeginVertical();
        GUI.Box(EZ_Style.rect, GUIContent.none);
        if (string.IsNullOrEmpty(saveAtPath))
        {
            EditorGUILayout.LabelField("Browse location using the button bellow");
        }
        else
        {
            EditorGUILayout.LabelField(saveAtPath);
        }
        EditorGUILayout.EndVertical();

        // Path buttons
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Browse"))
        {
            saveAtPath = EditorUtility.SaveFolderPanel("Save At", saveAtPath, Application.dataPath);
        }
        if (GUILayout.Button("Open Folder"))
        {
            Application.OpenURL("file://" + saveAtPath);
        }
        EditorGUILayout.EndHorizontal();
        EZ_Style.Footer();
    }
예제 #7
0
    private void MockupGUI()
    {
        if (useMockup = EZ_Style.Header("Mockup", true, useMockup))
        {
            if (appleManager == null)
            {
                appleManager = new EzSS_AppleManager();
            }

            if (encodeType == EncodeType.JPG)
            {
                encodeType = EncodeType.PNG;
                EditorUtility.DisplayDialog(EzSS_Messages.TITLE_00, EzSS_Messages.WARNING_02, EzSS_Messages.BUTTON_00);
            }

            // Select the brand
            mockupBrand = (MockupBrands)EditorGUILayout.EnumPopup("Brand:", mockupBrand);
            // Select the category
            mockupCategory = (MockupCategories)EditorGUILayout.EnumPopup("Category:", mockupCategory);

            // Select the device
            if (mockupCategory == MockupCategories.smartphone)
            {
                if (mockupBrand == MockupBrands.apple)
                {
                    setMockupOrientation = true;
                    // Mockup configurations
                    selectedMockup   = appleManager.SmartphoneSelector();
                    selectedColor    = appleManager.SmartphoneColorSelector();
                    mockupFixedSize  = appleManager.devicesFixedSizes[appleManager.smartphonesApple.ToString()];
                    mockupAspect     = appleManager.devicesAspects[appleManager.smartphonesApple.ToString()];
                    screenPercentage = appleManager.devicesScreenPercentage[appleManager.smartphonesApple.ToString()];
                    deviceOffset     = appleManager.devicesOffsets[appleManager.smartphonesApple.ToString()];
                }
            }
            else if (mockupCategory == MockupCategories.tablet)
            {
                if (mockupBrand == MockupBrands.apple)
                {
                    setMockupOrientation = true;
                    // Mockup configurations
                    selectedMockup   = appleManager.TabletSelector();
                    selectedColor    = appleManager.TabletColorSelector();
                    mockupFixedSize  = appleManager.devicesFixedSizes[appleManager.tablet.ToString()];
                    mockupAspect     = appleManager.devicesAspects[appleManager.tablet.ToString()];
                    screenPercentage = appleManager.devicesScreenPercentage[appleManager.tablet.ToString()];
                    deviceOffset     = appleManager.devicesOffsets[appleManager.tablet.ToString()];
                }
            }
            else if (mockupCategory == MockupCategories.computer)
            {
                if (mockupBrand == MockupBrands.apple)
                {
                    // Computers has wide aspect ratio, but the orientation is portrait because landcape will invert x and y width and height
                    setMockupOrientation = false;
                    mockupOrientation    = MockupOrientation.portrait;
                    // Mockup configurations
                    selectedMockup   = appleManager.ComputerSelector();
                    selectedColor    = appleManager.ComputerColorSelector();
                    mockupFixedSize  = appleManager.devicesFixedSizes[appleManager.computer.ToString()];
                    mockupAspect     = appleManager.devicesAspects[appleManager.computer.ToString()];
                    screenPercentage = appleManager.devicesScreenPercentage[appleManager.computer.ToString()];
                    deviceOffset     = appleManager.devicesOffsets[appleManager.computer.ToString()];
                }
            }
            else
            {
                if (mockupBrand == MockupBrands.apple)
                {
                    // Watches has just one orientation
                    setMockupOrientation = false;
                    mockupOrientation    = MockupOrientation.portrait;
                    // Mockup configurations
                    selectedMockup   = appleManager.WatchSelector();
                    selectedColor    = appleManager.WatchColorSelector();
                    mockupFixedSize  = appleManager.devicesFixedSizes[appleManager.watch.ToString()];
                    mockupAspect     = appleManager.devicesAspects[appleManager.watch.ToString()];
                    screenPercentage = appleManager.devicesScreenPercentage[appleManager.watch.ToString()];
                    deviceOffset     = appleManager.devicesOffsets[appleManager.watch.ToString()];
                }
            }

            if (setMockupOrientation)
            {
                mockupOrientation   = (MockupOrientation)EditorGUILayout.EnumPopup("Orientation:", mockupOrientation);
                selectedOrientation = mockupOrientation.ToString();

                if (EzSS_AspectHelper.AspectsResults[mockupAspect] < 1 && (mockupOrientation == MockupOrientation.landscapeLeft || mockupOrientation == MockupOrientation.landscapeRight))
                {
                    mockupAspect = EzSS_AspectHelper.AspectsInverted[appleManager.devicesAspects[selectedMockup]];
                }
            }
            else
            {
                selectedOrientation = "";
            }

            // Mockup image path
            selectedBrand    = mockupBrand.ToString();
            selectedCategory = mockupCategory.ToString();
            if (!string.IsNullOrEmpty(selectedColor))
            {
                selectedColor = "-" + selectedColor;
            }
            if (!string.IsNullOrEmpty(selectedOrientation))
            {
                selectedOrientation = "-" + selectedOrientation;
            }
            string _finalPath = mockupsPath + selectedBrand + "/" + selectedCategory + "/" + selectedMockup + selectedColor + selectedOrientation + ".png";
            // Load the image
            mockupImage = (Texture2D)AssetDatabase.LoadAssetAtPath(_finalPath, typeof(Texture2D));

            // Display the image
            float _offsetX = mockupPreviewPreviewOffset[mockupCategory].x;
            float _offsetY = mockupPreviewPreviewOffset[mockupCategory].y;
            EditorGUILayout.LabelField("Mockup Preview:");
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (mockupOrientation == MockupOrientation.portrait)
            {
                GUILayout.Label(mockupImage, GUILayout.Width(_offsetX), GUILayout.Height(_offsetY));
            }
            else
            {
                GUILayout.Label(mockupImage, GUILayout.Width(_offsetY), GUILayout.Height(_offsetX));
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        EZ_Style.Footer();
    }