void DrawResolutionPreview(Rect pos, ScreenshotResolution resolution)
        {
            Vector2 size = GetRenderSize(resolution, m_ConfigAsset.m_PreviewZoom, m_ConfigAsset.m_PreviewDisplayMode);

            if (size == Vector2.zero)
            {
                return;
            }

            pos.width  = size.x;
            pos.height = size.y;

            // Center device
            if (pos.width < m_WindowWidth)
            {
                pos.x = (m_WindowWidth - pos.width) / 2;
            }

            // Draw the resolution texture
            if (resolution.m_Texture != null)
            {
                EditorGUI.DrawTextureTransparent(pos, resolution.m_Texture);
            }
            else
            {
                EditorGUI.DrawTextureTransparent(pos, m_BackgroundTexture);
                EditorGUI.LabelField(pos, "Needs to be updated.", m_NameStyle);
            }

            height = (int)Mathf.Max(height, pos.y + size.y);
            width  = (int)Mathf.Max(width, size.x);
        }
Ejemplo n.º 2
0
        public static void RotateTexture(ScreenshotResolution res)
        {
            var rotated = RotateTexture(res.m_Texture);

            // Replace the texture
            DestroyImmediate(res.m_Texture);
            res.m_Texture = rotated;
        }
Ejemplo n.º 3
0
 void DeviceAfterCapture(ScreenshotResolution device)
 {
     // We restore the safe area except if it is a live preview to prevent flickering
     if (DeviceInfo.m_IsLivePreview)
     {
         return;
     }
     Restore();
     m_IsSimulatingDevice = false;
 }
Ejemplo n.º 4
0
        void DeviceEndUpdated(ScreenshotResolution device)
        {
            // When the resize is done we stop the update rights
            m_CanUpdateSafeArea = false;

            // We restore the safe area except if it is a live preview to prevent flickering
            if (!Application.isPlaying || !DeviceInfo.m_IsLivePreview)
            {
                Restore();
            }
        }
Ejemplo n.º 5
0
        void StartCallback(ScreenshotResolution res)
        {
            if (m_SelectionArea == null)
            {
                return;
            }

            if (m_HideSelectionAreaDuringCapture)
            {
                Hide();
            }
        }
Ejemplo n.º 6
0
        void DeviceResized(ScreenshotResolution device)
        {
            // In live preview, we ignore the resize event for non device,
            // to prevent resizing to the device full preview with border
            if (Application.isPlaying && device.m_ResolutionName == "" && DeviceInfo.m_IsLivePreview)
            {
                return;
            }

            m_IsSimulatingDevice = true;
            ApplySafeArea();
        }
Ejemplo n.º 7
0
        Rect DrawResolutionPreview(Rect pos, ScreenshotResolution resolution)
        {
            Vector2 size = GetRenderSize(resolution, m_ConfigAsset.m_PreviewGalleryZoom, m_ConfigAsset.m_GalleryDisplayMode);

            if (size == Vector2.zero)
            {
                return(pos);
            }

            // If can not draw the rect in the current row, create a new row
            if (pos.x > m_ConfigAsset.m_MarginHorizontal && pos.x + size.x + m_ConfigAsset.m_MarginHorizontal > m_WindowWidth)
            {
                pos.x = m_ConfigAsset.m_MarginHorizontal;
                pos.y = height + m_ConfigAsset.m_GalleryPaddingVertical;
            }
            pos.width  = size.x;
            pos.height = size.y;

            // Draw the white background
            Rect borderpos = pos;

            borderpos.x      -= m_ConfigAsset.m_GalleryBorderSize;
            borderpos.y      -= m_ConfigAsset.m_GalleryBorderSize;
            borderpos.width  += 2 * m_ConfigAsset.m_GalleryBorderSize;
            borderpos.height += 2 * m_ConfigAsset.m_GalleryBorderSize + m_ConfigAsset.m_GalleryTextHeight;


            // Draw the resolution texture
            if (resolution.m_Texture != null)
            {
                EditorGUI.DrawTextureTransparent(pos, resolution.m_Texture);
            }
            else
            {
                EditorGUI.DrawTextureTransparent(pos, m_BackgroundTexture);
                EditorGUI.LabelField(pos, "Needs to be updated.", m_NameStyle);
            }

            // Display the resolution name
            Rect labelpos = pos;

            labelpos.y      = pos.y + size.y + 5;
            labelpos.height = m_ConfigAsset.m_GalleryTextHeight;
            EditorGUI.LabelField(labelpos, resolution.ToString(), m_NameStyle);

            // Increment the box position
            pos.x += size.x + m_ConfigAsset.m_GalleryPaddingVertical;
            height = (int)Mathf.Max(height, pos.y + size.y + 5 + m_ConfigAsset.m_GalleryTextHeight);
            width  = (int)Mathf.Max(width, size.x);

            return(pos);
        }
Ejemplo n.º 8
0
        void DeviceStartUpdated(ScreenshotResolution device)
        {
            // In live preview, we ignore the resize event for non device,
            // to prevent resizing to the device full preview with border
            if (Application.isPlaying && device.m_ResolutionName == "" && DeviceInfo.m_IsLivePreview)
            {
                return;
            }
//			Debug.Log ("Start " + device.m_ResolutionName);

            // When a device simulation starts, we allow the safe area to be updated
            m_CanUpdateSafeArea = true;
        }
Ejemplo n.º 9
0
        void EndCallback(ScreenshotResolution res)
        {
            if (m_SelectionArea == null)
            {
                return;
            }

            if (m_HideSelectionAreaDuringCapture)
            {
                Show();
            }
            CropTexture(res);
        }
Ejemplo n.º 10
0
 public static void SetSimulatedDevice(ScreenshotResolution device)
 {
     if (m_CurrentDevice == device)
     {
         return;
     }
     if (m_CurrentDevice != null)
     {
         onSimulationEnd(m_CurrentDevice);
     }
     m_CurrentDevice = device;
     if (m_CurrentDevice != null)
     {
         onSimulationStart(m_CurrentDevice);
     }
 }
Ejemplo n.º 11
0
        void CropTexture(ScreenshotResolution res)
        {
            // Get the selection image coordinates
            Vector3[] corners = new Vector3[4];
            m_SelectionArea.GetWorldCorners(corners);

            // Create cropped texture
            int       x0      = (int)corners [0].x + m_CropBorder;
            int       y0      = (int)corners [0].y + m_CropBorder;
            int       width   = (int)(corners [2].x - corners [0].x) - 2 * m_CropBorder;
            int       height  = (int)(corners [1].y - corners [0].y) - 2 * m_CropBorder;
            Texture2D cropped = new Texture2D(width, height, res.m_Texture.format, false);

            if (width <= 2 || height <= 2)
            {
                return;
            }

            // Copy the content
            Color col;

            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    if (x0 + x >= 0 && x0 + x < res.m_Texture.width &&
                        y0 + y >= 0 && y0 + y < res.m_Texture.height)
                    {
                        col = res.m_Texture.GetPixel(x0 + x, y0 + y);
                    }
                    else
                    {
                        col = Color.black;
                    }
                    cropped.SetPixel(x, y, col);
                }
            }
            cropped.Apply();

            Debug.Log("Screenshot cropped to (" + x0 + ", " + y0 + ", " + (x0 + width - 1) + ", " + (y0 + height - 1) + ")");

            // Replace the texture
            GameObject.DestroyImmediate(res.m_Texture);
            res.m_Texture = cropped;
        }
Ejemplo n.º 12
0
        protected Vector2 GetRenderSize(ScreenshotResolution resolution, float zoom, PreviewConfigAsset.GalleryDisplayMode mode)
        {
            int displayWidth, displayHeight;
            int width  = resolution.ComputeTargetWidth();
            int height = resolution.ComputeTargetHeight();

            if (resolution.m_Texture != null)
            {
                width  = resolution.m_Texture.width;
                height = resolution.m_Texture.height;
            }

            if (width <= 0 || height <= 0)
            {
                EditorGUILayout.LabelField("Invalid dimensions for resolution " + resolution.ToString());
                return(Vector2.zero);
            }

            // Compute the box dimensions depending on the display mode
            if (mode == PreviewConfigAsset.GalleryDisplayMode.RATIOS)
            {
                displayWidth  = (int)((m_WindowWidth - m_ConfigAsset.m_MarginHorizontal) * zoom);
                displayHeight = (int)(displayWidth * height / width);
            }
            else if (mode == PreviewConfigAsset.GalleryDisplayMode.PIXELS || resolution.m_PPI <= 0)
            {
                displayWidth  = (int)(width * zoom / PixelsPerPoint());
                displayHeight = (int)(height * zoom / PixelsPerPoint());
            }
            else
            {
                displayWidth  = (int)(width * zoom / resolution.m_PPI * m_ConfigAsset.m_ScreenPPI / PixelsPerPoint());
                displayHeight = (int)(height * zoom / resolution.m_PPI * m_ConfigAsset.m_ScreenPPI / PixelsPerPoint());
            }

            // Invert the scaling
            displayWidth  = (int)((float)displayWidth / resolution.m_Scale);
            displayHeight = (int)((float)displayHeight / resolution.m_Scale);

            return(new Vector2(displayWidth, displayHeight));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// We force the ConstantPhysicalSize Canvas Scaler
        /// to recompute their scale using a dpi different that the Screen.dpi
        /// </summary>
        static void ForceCanvasScales(ScreenshotResolution res)
        {
            if (res.m_PPI <= 0)
            {
                return;
            }

            float dpi;

            if (res.m_ForcedUnityPPI > 0)
            {
                // If the PPI returned by the Device to Unity by Screen.dpi is bad,
                // we use that dpi for the preview instead of the real one.
                dpi = res.m_ForcedUnityPPI;
            }
            else
            {
                dpi = res.m_PPI;
            }

            ForceCanvasScales(dpi);
        }
Ejemplo n.º 14
0
 void Show(ScreenshotResolution res)
 {
     this.gameObject.SetActive(true);
 }
Ejemplo n.º 15
0
 void Hide(ScreenshotResolution res)
 {
     this.gameObject.SetActive(false);
 }
Ejemplo n.º 16
0
 void OnResolutionUpdateEnd(ScreenshotResolution res)
 {
     Restore();
 }
Ejemplo n.º 17
0
        protected override void DrawToolBarGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);


            // Safe selection
            if (m_ConfigAsset.m_Selected >= m_ConfigAsset.m_Config.GetActiveResolutions().Count)
            {
                m_ConfigAsset.m_Selected = 0;
            }


            // BUTTONS
            if (GUILayout.Button("Update", EditorStyles.toolbarButton))
            {
                UpdateWindowResolutions();
            }

            if (GUILayout.Button("Export to file(s)", EditorStyles.toolbarButton))
            {
                Export();
            }

            // SPACE
            GUILayout.FlexibleSpace();



            // SAFE AREA
            if (m_ConfigAsset.m_DrawSafeArea)
            {
                if (GUILayout.Button("Safe Area (ON)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }
            else
            {
                if (GUILayout.Button("Safe Area (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }

            // ORIENTATION
            if (m_ConfigAsset.m_Config.GetActiveResolutions().Count > 0 && m_ConfigAsset.m_Config.GetActiveResolutions() [m_ConfigAsset.m_Selected].m_Orientation == ScreenshotResolution.Orientation.LANDSCAPE)
            {
                if (GUILayout.Button("LANDSCAPE", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_Config.SetAllPortait();
//					m_ConfigAsset.m_Config.GetActiveResolutions () [m_ConfigAsset.m_Selected].m_Orientation = ScreenshotResolution.Orientation.PORTRAIT;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }
            else
            {
                if (GUILayout.Button("PORTAIT", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_Config.SetAllLandscape();
//					m_ConfigAsset.m_Config.GetActiveResolutions () [m_ConfigAsset.m_Selected].m_Orientation = ScreenshotResolution.Orientation.LANDSCAPE;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }



            // MODE
            EditorGUILayout.LabelField("Display mode", GUILayout.MaxWidth(85));
            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_PreviewDisplayMode"), GUIContent.none, GUILayout.MaxWidth(70));


            // MODE
            EditorGUILayout.LabelField("Drawing mode", GUILayout.MaxWidth(85));
            var previousDrawing = m_ConfigAsset.m_DrawingMode;

            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_DrawingMode"), GUIContent.none, GUILayout.MaxWidth(100));
            m_SerializedConfig.ApplyModifiedProperties();
            if (previousDrawing != m_ConfigAsset.m_DrawingMode)
            {
                UpdateWindowResolutions();
            }



            if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                ResolutionSettingsWindow.Init();
            }

            // ABOUT
            if (GUILayout.Button("About", EditorStyles.toolbarButton))
            {
                UniversalDevicePreview.About();
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);


            // AUTO REFRESH
            if (m_ConfigAsset.m_AutoRefresh)
            {
                if (GUILayout.Button("Auto refresh (ON)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            else
            {
                if (GUILayout.Button("Auto refresh (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            EditorGUILayout.LabelField("Refresh delay (s)", GUILayout.MaxWidth(110));
            float delay = EditorGUILayout.Slider(m_ConfigAsset.m_RefreshDelay, 0.01f, 10f, GUILayout.MaxWidth(200));

            if (delay != m_ConfigAsset.m_RefreshDelay)
            {
                m_ConfigAsset.m_RefreshDelay = delay;
                EditorUtility.SetDirty(m_ConfigAsset);
            }



            // SPACE
            GUILayout.FlexibleSpace();

            // ZOOM
            EditorGUILayout.LabelField("Zoom", GUILayout.MaxWidth(40));
            float zoom = EditorGUILayout.Slider(m_ConfigAsset.m_PreviewZoom, 0.05f, 4f);

            if (zoom != m_ConfigAsset.m_PreviewZoom)
            {
                m_ConfigAsset.m_PreviewZoom = zoom;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            if (GUILayout.Button("1:1", EditorStyles.toolbarButton))
            {
                m_ConfigAsset.m_PreviewZoom = 1f;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);



            GUILayout.FlexibleSpace();

            // SELECTION
            List <string> names = new List <string> ();

            foreach (ScreenshotResolution resolution in m_ConfigAsset.m_Config.GetActiveResolutions())
            {
                names.Add(resolution.ToString());
            }
            int selected = EditorGUILayout.Popup(m_ConfigAsset.m_Selected, names.ToArray(), GUILayout.MinWidth(300));

            if (m_ConfigAsset.m_Config.GetActiveResolutions().Count > 0)
            {
                m_SelectedResolution = m_ConfigAsset.m_Config.GetActiveResolutions() [selected];
            }
            else
            {
                m_SelectedResolution = null;
            }


            // Call update if selected changed
            if (selected != m_ConfigAsset.m_Selected)
            {
                m_ConfigAsset.m_Selected = selected;
                EditorUtility.SetDirty(m_ConfigAsset);
                UpdateWindowResolutions();
            }



            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
        }
        protected IEnumerator CaptureMasks(ScreenshotResolution res)
        {
            if (m_ConfigAsset.m_DeviceRendererCamera == null)
            {
                yield break;
            }


            // Init camera
            m_Camera                 = GameObject.Instantiate(m_ConfigAsset.m_DeviceRendererCamera);
            m_Camera.clearFlags      = CameraClearFlags.Color;
            m_Camera.backgroundColor = EditorGUIUtility.isProSkin
                ? new Color32(56, 56, 56, (byte)(m_ConfigAsset.m_TransparentDeviceBackground ? 0 : 255))
                : new Color32(194, 194, 194, (byte)(m_ConfigAsset.m_TransparentDeviceBackground ? 0 : 255));

            // Init canvas instance
            m_Canvas = res.m_DeviceCanvas;
            if (m_Canvas == null)
            {
                m_Canvas = m_ConfigAsset.m_DefaultDeviceCanvas;
            }
            if (m_Canvas == null)
            {
                yield break;
            }
            m_Canvas = GameObject.Instantiate(m_Canvas);

            // Texture
            MaskRenderer mask = m_Canvas.GetComponent <MaskRenderer>();

            mask.m_Texture.texture = res.m_Texture;

            if (m_ConfigAsset.m_DrawingMode == PreviewConfigAsset.DrawingMode.SCREEN_MASK)
            {
                mask.m_Mask.rectTransform.anchoredPosition = Vector2.zero;
                mask.m_Device.gameObject.SetActive(false);
                if (mask.m_BorderTop)
                {
                    mask.m_BorderTop.gameObject.SetActive(false);
                    mask.m_BorderLeft.gameObject.SetActive(false);
                    mask.m_BorderRight.gameObject.SetActive(false);
                    mask.m_BorderBottom.gameObject.SetActive(false);
                }
            }

            // Scale the UI
            Vector3 panelScale       = Vector3.one;
            int     widthWithDevice  = res.ComputeTargetWidth();
            int     heightWithDevice = res.ComputeTargetHeight();


            if (res.m_Orientation == ScreenshotResolution.Orientation.PORTRAIT)
            {
                // Resize the whole canvas
                panelScale.x            = (float)res.ComputeTargetWidth() / (float)mask.m_Mask.GetComponent <RectTransform>().rect.width;
                panelScale.y            = (float)res.ComputeTargetHeight() / (float)mask.m_Mask.GetComponent <RectTransform>().rect.height;
                mask.m_Panel.localScale = panelScale;

                // Add the border margin
                if (m_ConfigAsset.m_DrawingMode == PreviewConfigAsset.DrawingMode.FULL_DEVICE)
                {
                    widthWithDevice  = (int)(mask.m_Device.GetComponent <RectTransform>().rect.width *panelScale.x);
                    heightWithDevice = (int)(mask.m_Device.GetComponent <RectTransform>().rect.height *panelScale.y);
                }
            }
            else
            {
                // Rotate the whole canvas
                mask.m_Panel.localRotation = Quaternion.AngleAxis(90f, Vector3.forward);

                // Resize the whole canvas
                panelScale.x            = (float)res.ComputeTargetWidth() / (float)mask.m_Mask.GetComponent <RectTransform>().rect.height;
                panelScale.y            = (float)res.ComputeTargetHeight() / (float)mask.m_Mask.GetComponent <RectTransform>().rect.width;
                mask.m_Panel.localScale = new Vector3(panelScale.y, panelScale.x, 1f);

                // Rotate the texture and scale it to match the screen size
                mask.m_Texture.transform.localRotation = Quaternion.AngleAxis(-90f, Vector3.forward);
                float tmp = mask.m_Texture.rectTransform.sizeDelta.x;
                mask.m_Texture.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, mask.m_Texture.rectTransform.sizeDelta.y);
                mask.m_Texture.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, tmp);

                // Add the border margin
                if (m_ConfigAsset.m_DrawingMode == PreviewConfigAsset.DrawingMode.FULL_DEVICE)
                {
                    widthWithDevice  = (int)(mask.m_Device.GetComponent <RectTransform>().rect.height *panelScale.x);
                    heightWithDevice = (int)(mask.m_Device.GetComponent <RectTransform>().rect.width *panelScale.y);
                }
            }

            // Compute target resolution
            if (m_ConfigAsset.m_DrawingMode == PreviewConfigAsset.DrawingMode.SCREEN_MASK)
            {
                mask.m_Device.gameObject.SetActive(false);
            }
            else
            {
                mask.m_Device.gameObject.SetActive(true);
            }

            // Capture the device
            Texture2D texClone = new Texture2D(1, 1);

            yield return(m_ScreenshotTaker.StartCoroutine(m_ScreenshotTaker.CaptureToTextureCoroutine(texClone, widthWithDevice, heightWithDevice,
                                                                                                      new List <Camera> {
                m_Camera
            }, new List <Canvas> {
                m_Canvas
            },
                                                                                                      ScreenshotTaker.CaptureMode.GAMEVIEW_RESIZING, 8, false, ScreenshotTaker.ColorFormat.RGBA, false)));

            // Replace the texture
            GameObject.DestroyImmediate(res.m_Texture);
            res.m_Texture = texClone;

            // Clean
            GameObject.DestroyImmediate(m_Camera.gameObject);
            GameObject.DestroyImmediate(m_Canvas.gameObject);
        }
Ejemplo n.º 19
0
 public void ExportSuccessCallback(ScreenshotResolution resolution)
 {
     DisplayMessage("Screenshot created : " + resolution.m_FileName);
 }
        protected override void DrawToolBarGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);


            // Safe selection
            if (m_ConfigAsset.m_Selected >= m_ConfigAsset.m_Config.m_Resolutions.Count)
            {
                m_ConfigAsset.m_Selected = 0;
            }


            // BUTTONS
            var col = GUI.color;

            GUI.color = new Color(0.6f, 1f, 0.6f, 1.0f);
            if (GUILayout.Button("  Update Preview  ", EditorStyles.toolbarButton))
            {
                UpdateWindowResolutions();
            }
            GUI.color = col;

            if (GUILayout.Button("Export to file(s)", EditorStyles.toolbarButton))
            {
                Export();
            }

            // SPACE
            GUILayout.FlexibleSpace();



            // SAFE AREA
            if (m_ConfigAsset.m_DrawSafeArea)
            {
                if (GUILayout.Button("Safe Area (ON)  ", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }
            else
            {
                if (GUILayout.Button("Safe Area (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }

            // ORIENTATION
            var previousOrientation     = ScreenshotResolution.Orientation.LANDSCAPE;
            ScreenshotResolution device = null;

            if (m_ConfigAsset.m_Config.m_Resolutions.Count > m_ConfigAsset.m_Selected)
            {
                device = m_ConfigAsset.m_Config.m_Resolutions[m_ConfigAsset.m_Selected];
            }
            if (device != null)
            {
                previousOrientation = device.m_Orientation;
                var newOrientation = (ScreenshotResolution.Orientation)EditorGUILayout.EnumPopup("", m_ConfigAsset.m_Config.GetFirstActiveResolution().m_Orientation);
                if (newOrientation != previousOrientation)
                {
                    if (newOrientation == ScreenshotResolution.Orientation.LANDSCAPE)
                    {
                        m_ConfigAsset.m_Config.SetAllLandscape();
                    }
                    else if (newOrientation == ScreenshotResolution.Orientation.LANDSCAPE_RIGHT)
                    {
                        m_ConfigAsset.m_Config.SetAllLandscapeRight();
                    }
                    else
                    {
                        m_ConfigAsset.m_Config.SetAllPortait();
                    }
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }

            // MODE
            EditorGUILayout.LabelField("Display mode", GUILayout.MaxWidth(85));
            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_PreviewDisplayMode"), GUIContent.none, GUILayout.MaxWidth(70));


            // MODE
            EditorGUILayout.LabelField("Drawing mode", GUILayout.MaxWidth(85));
            var previousDrawing = m_ConfigAsset.m_DrawingMode;

            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_DrawingMode"), GUIContent.none, GUILayout.MaxWidth(100));
            m_SerializedConfig.ApplyModifiedProperties();
            if (previousDrawing != m_ConfigAsset.m_DrawingMode)
            {
                UpdateWindowResolutions();
            }



            if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                ResolutionSettingsWindow.Init();
            }

            // ABOUT
            if (GUILayout.Button("About", EditorStyles.toolbarButton))
            {
                UniversalDevicePreview.About();
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);


            // AUTO REFRESH
            if (m_ConfigAsset.m_AutoRefresh)
            {
                if (GUILayout.Button("Auto refresh (ON)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            else
            {
                if (GUILayout.Button("Auto refresh (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            EditorGUILayout.LabelField("Refresh delay (s)", GUILayout.MaxWidth(110));
            float delay = EditorGUILayout.Slider(m_ConfigAsset.m_RefreshDelay, 0.01f, 10f, GUILayout.MaxWidth(200));

            if (delay != m_ConfigAsset.m_RefreshDelay)
            {
                m_ConfigAsset.m_RefreshDelay = delay;
                EditorUtility.SetDirty(m_ConfigAsset);
            }



            // SPACE
            GUILayout.FlexibleSpace();

            // ZOOM
            EditorGUILayout.LabelField("Zoom", GUILayout.MaxWidth(40));
            float zoom = EditorGUILayout.Slider(m_ConfigAsset.m_PreviewZoom, 0.05f, 4f);

            if (zoom != m_ConfigAsset.m_PreviewZoom)
            {
                m_ConfigAsset.m_PreviewZoom = zoom;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            if (GUILayout.Button("1:1", EditorStyles.toolbarButton))
            {
                m_ConfigAsset.m_PreviewZoom = 1f;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            EditorGUILayout.EndHorizontal();



            // DEVICES
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.FlexibleSpace();

            // SELECTION
            List <string> names    = m_ConfigAsset.m_Config.m_Resolutions.Select(x => x.ToString()).ToList();
            int           selected = EditorGUILayout.Popup(m_ConfigAsset.m_Selected, names.ToArray(), GUILayout.MinWidth(400));

            if (m_ConfigAsset.m_Config.m_Resolutions.Count > 0)
            {
                m_SelectedResolution = m_ConfigAsset.m_Config.m_Resolutions[selected];
            }
            else
            {
                m_SelectedResolution = null;
            }


            // Call update if selected changed
            if (selected != m_ConfigAsset.m_Selected)
            {
                m_ConfigAsset.m_Selected = selected;
                EditorUtility.SetDirty(m_ConfigAsset);
                if (m_ConfigAsset.m_AutoGenerateEmptyPreview)
                {
                    UpdateWindowResolutions();
                }
            }


            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 21
0
 void EndCallback(ScreenshotResolution res)
 {
     RotateTexture(res);
 }
Ejemplo n.º 22
0
 void DeviceBeforeCapture(ScreenshotResolution device)
 {
 }
Ejemplo n.º 23
0
 public void ExportFailureCallback(ScreenshotResolution resolution)
 {
     DisplayMessage("FAILED to create : " + resolution.m_FileName);
 }
Ejemplo n.º 24
0
 void DeviceResized(ScreenshotResolution device)
 {
 }
Ejemplo n.º 25
0
 public override void Process(ScreenshotResolution res)
 {
     Debug.Log("Change language process! " + m_LanguageID);
     SimpleLocalizationLanguagesAsset.SetLanguage(m_LanguageID);
 }
Ejemplo n.º 26
0
 void OnResolutionUpdateStart(ScreenshotResolution res)
 {
     Check();
 }